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


Copyright 2021. All rights reserved.

Posted 11 August 2025 by admin in category "simple memo

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.