chezmoi/scripts/executable_obelisk.status.sh
2020-07-19 17:41:12 +02:00

26 lines
732 B
Bash

#!/bin/bash
STATUSURL=https://obelisk.ilabt.imec.be/api/v2/status
STATUS=$(curl -s $STATUSURL | jq -r '.status' 2>/dev/null)
# colors
HEALTHY="#b8bb26"
DEGRADED="#fe8019"
FAILED="#fb4934"
UNKNOWN="#928374"
# echo the status in polybar format
# the {F}x{F-} syntax allows you to color stuff
# could have failed completely (network down etc)
if [ -z $STATUS ]; then
echo "%{F$UNKNOWN} %{F-} obelisk"
# expected statuses, healthy, degraded, failed
elif [ $STATUS = "healthy" ]; then
echo "%{F$HEALTHY} %{F-} obelisk"
elif [ $STATUS = "degraded" ]; then
echo "%{F$DEGRADED} %{F-} obelisk"
elif [ $STATUS = "failed" ]; then
echo "%{F$FAILED} %{F-} obelisk"
else
echo "%{F$UNKNOWN} %{F-} obelisk"
fi