ansible-tools/uptime_alarm
2022-09-04 15:57:05 +02:00

15 lines
427 B
Bash
Executable File

#!/bin/bash
minimum=${1:-86400}
cd /etc/ansible/gathered_facts
for f in *; do
g=$(grep ansible_uptime_seconds $f)
if [[ $? > 0 ]]; then
continue
fi
up=$(echo "$g" | sed -e 's/.*"ansible_uptime_seconds":\s*\([0-9]\+\).*/\1/')
if [[ $up -lt $minimum ]]; then
echo $f uptime is $((up / 3600)) hours $(($up % 3600 / 60)) minutes
fi
done
# vim: set tabstop=4 shiftwidth=4 expandtab smarttab: