diff --git a/uptimekuma.sh b/uptimekuma.sh index 22518da..ff7ee07 100644 --- a/uptimekuma.sh +++ b/uptimekuma.sh @@ -7,6 +7,7 @@ API_URL="https://status.netsyms.net/api/push/" PUSH_KEY="" # The random code in the URL generated by Uptime Kuma +GRAPH="CPU" # Which stat is graphed in Uptime Kuma. Can set to "RAM" for memory usage or to "" to disable. ENABLE_ZFS_MONITOR=1 # Set to 0 if you aren't using ZFS DISK_FULL_ALERT_PERCENT_THRESHOLD=85 # Alerts if any filesystem is fuller than this CPU_USAGE_PERCENT_THRESHOLD=60 # Alerts if CPU usage averages greater than this across 5 minutes @@ -54,9 +55,9 @@ echo "$CPU_STATUS" # Memory usage percentage echo -n "Checking memory usage: " MEM_STATUS="OK" -MEM_PCT=$(free -m | awk 'NR==2{ print $3*100/$2 }') -if [[ $MEM_PCT > $MEM_USAGE_PERCENT_THRESHOLD ]]; then - MEM_STATUS="$MEM_PCT% > $MEM_USAGE_PERCENT_THRESHOLD%" +MEM_PERCENT=$(free -m | awk 'NR==2{ print $3*100/$2 }') +if [[ $MEM_PERCENT > $MEM_USAGE_PERCENT_THRESHOLD ]]; then + MEM_STATUS="$MEM_PERCENT% > $MEM_USAGE_PERCENT_THRESHOLD%" fi echo "$MEM_STATUS" @@ -85,11 +86,17 @@ fi echo -n "Sending status: " +PING_VALUE="" +if [[ $GRAPH == "CPU" ]]; then + PING_VALUE="$CPU_PERCENT" +elif [[ $GRAPH == "RAM" ]]; then + PING_VALUE="$MEM_PERCENT" +fi if [[ $IS_OK == "1" ]]; then echo "OK" - curl -s -o /dev/null -G "$API_URL$PUSH_KEY?status=up&msg=OK&ping=$CPU_PERCENT" + curl -s -o /dev/null -G "$API_URL$PUSH_KEY?status=up&msg=OK&ping=$PING_VALUE" else ERROR_STRING=$(IFS=";"; echo "${ERROR_MESSAGES[*]}") echo $ERROR_STRING - curl -s -o /dev/null -G --data-urlencode "status=down" --data-urlencode "msg=$ERROR_STRING" "$API_URL$PUSH_KEY" + curl -s -o /dev/null -G --data-urlencode "status=down" --data-urlencode "ping=$PING_VALUE" --data-urlencode "msg=$ERROR_STRING" "$API_URL$PUSH_KEY" fi \ No newline at end of file