pull down to refresh

This is how I alert myself, lol:
function ntfy() {
  curl -H "Title: $1" -d "$2" ntfy.sh/ekzyis-id-you-would-like-to-know-was-here
}

some_command || ntfy "some_command failed" "exit code $? :("
This has served me well for a year or more! Very simple, and it's all I need, at least so far.
I used to run Grafana and Prometheus to track CPU, memory, disk I/O, network I/O of my machines, but I realized it's more cool to look at than actually useful for my needs.
Instead, I now have alerts with ntfy.sh for most things I need to respond to.
For example, this is the function I use to keep track of expiring SSL certificates:
check_ssl_expiry () {
    DOMAIN="$1"
    WARNING_THRESHOLD=30
    TIMEOUT=10

    printf "checking ssl expiry of $DOMAIN ... "

    CERT=$(echo "QUIT" | timeout $TIMEOUT openssl s_client -connect "$DOMAIN":443 2>/dev/null)
    RET=$?
    if [ $RET -eq 124 ]; then
      printf_timeout $TIMEOUT
      ntfy "ssl connect timeout" "$DOMAIN
timeout after $TIMEOUT seconds"
      return 124
    fi

    if [ ! $RET -eq 0 ]; then
      printf_color "openssl returned exit code $RET\n" "red"
      ntfy "ssl connect failed" "$DOMAIN: openssl returned exit code $RET"
      return 1
    fi

    EXPIRY=$(echo "$CERT" | openssl x509 -noout -enddate | cut -d'=' -f2)
    EXPIRY_EPOCH=$(date -d "$EXPIRY" +%s)
    NOW_EPOCH=$(date +%s)
    DAYS_LEFT=$(( ($EXPIRY_EPOCH - $NOW_EPOCH) / 86400 ))
    if [ $DAYS_LEFT -lt $WARNING_THRESHOLD ]; then
        printf_color "$DAYS_LEFT days left\n" "red"
        ntfy "ssl expiry" "$DOMAIN: $DAYS_LEFT day(s) left"
        return 1
    fi

    printf_color "$DAYS_LEFT days left\n" "green"
}
50 sats \ 6 replies \ @optimism 19h
Funny how we have functionally the same solution.
I used to run Grafana and Prometheus to track CPU, memory, disk I/O, network I/O of my machines, but I realized it's more cool to look at than actually useful for my needs.
I've gone off it in the past, and had some times of vacuum between solutions before it was a thing. However all my software uses prometheus for monitoring and I don't write anything without finegrained telemetry anymore, so I just have a stable environment for this now.
reply
100 sats \ 5 replies \ @ek 16h
Funny how we have functionally the same solution.
Wdym? You mean wrt alerts?
reply
69 sats \ 4 replies \ @optimism 16h
Yes. If I would rewrite the golang script in bash it would look like yours.
reply
100 sats \ 3 replies \ @ek 16h
Ah, haha
You even also print ASCII art, I also do that if figlet is installed:
#!/usr/bin/env bash

...

command -v figlet > /dev/null
if [ $? -eq 0 ]; then
  figlet -f graffiti bark 2> /dev/null && echo -e "   your network watchdog\n"
fi

...
lol, leaked my ntfy channel id for a second, but wouldn't be a problem, since I could just create a new one
reply
44 sats \ 2 replies \ @optimism 15h
Yes. Evidence of boredom lol
reply
202 sats \ 1 reply \ @ek 15h
Btw, I’d love to open source my script, since I think it’s pretty cool (it even has a cool name: bark), but it has a bunch of my IP addresses in there, and it reveals quite a lot about how I configured my network, and I don’t necessarily want to expose all of that to the public, or make it very configurable so I don’t have to hardcode all my private stuff, haha
Have you ever find yourself in a similar position?
#firstworldproblems
reply
100 sats \ 0 replies \ @optimism 15h
Have you ever find yourself in a similar position?
I used to. However... at several points I had so much stuff running (I think my worst was 60+ servers and hundreds of containers both of the k8s and the lxc kind) that I just spent a month or so on migrating every script I had to take either env, or config files. Nothing hardcoded except maybe listening ports (since I anyway dockerize everything as microservices on k8s, this is not really a problem)
My biggest problem is figuring out whether code is mine or that I wrote it for one of my companies. Most often there's a (c) statement in the header but not always.
I'm pro sharing, but against dumping. I just try to share code sometimes in conversations.
reply