August
11
Nagios script to check host uptime
#!/bin/bash
#Simple script to check the server uptime in seconds
#written by Vasyl T.
minimum='86400' # 1 day (24 hours) in seconds
real=$(/usr/bin/awk -F'.' '{print $1}' /proc/uptime)
if [[ "$minimum" -gt "$real" ]];then
echo "CRITICAL. Server uptime is $real seconds, when expected - more than: $minimum"
exit 2;
else
days=$(($real / $minimum))
echo "OK. Server uptime is $real seconds or $days day(s)"
exit 0;
fi