Uptime Checks
Uptime checks can alert you to when a system has rebooted (or has not). The performance data returned can also help identify trends with systems that may be having issues.
The sections below provide examples of how to perform these checks using different methods.
Nagios Plugins
The check_uptime plugin is part of Nagios Plugins. The thresholds for the plugin are triggered if the system uptime is more than the supplied value.
System Uptime Longer Than 1 Day
Unit: | Days |
Critical: | Up more than 1 day |
Command:
./check_uptime -u days -c 1
Output:
Uptime CRITICAL: 25 day(s) 20 hour(s) 11 minute(s) | uptime=25.000000;;1.000000;
System Uptime Shorter Than 1 Day
The check_uptime plugin does not provide this check type, however you can use the negate plugin to invert the returned result from the plugin (hence making CRITICAL an OK state).
Unit: | Days |
Critical: | Up less than 1 day |
Command:
./negate -s ./check_uptime -u days -c 1
Output:
Uptime OK: 25 day(s) 20 hour(s) 14 minute(s) | uptime=25.000000;;1.000000;
NCPA
NPCA includes a system module that allows you to check the uptime, the response returned is in seconds.
System Uptime Longer Than 1 Day
Unit: | Seconds |
Critical: | Up more than 86400 seconds (1 day) |
Command:
./check_ncpa.py -H 10.25.14.91 -t Str0ngT0k3n -M 'system/uptime' --critical 86400
Output:
CRITICAL: Uptime was 1212855.00 s | 'uptime'=1212855.00s;;86400;
System Uptime Shorter Than 1 Day
Unit: | Seconds |
Critical: | Up less than 86400 seconds (1 day) |
Command:
./check_ncpa.py -H 10.25.14.91 -t Str0ngT0k3n -M 'system/uptime' --critical 86400:
Output:
OK: Uptime was 1212902.00 s | 'uptime'=1212902.00s;;86400:;
NSClient++ via check_nt
NSClient++ includes a UPTIME module. The thresholds for the module are triggered if the system uptime is less than the supplied value.
System Uptime Longer Than 1 Day
The UPTIME module does not provide this check type, however you can use the negate plugin to invert the returned result from the plugin (hence making CRITICAL an OK state).
Unit: | Days |
Critical: | Up more than 1 day |
Command:
./negate ./check_nt -H 10.25.14.10 -p 12489 -s 'Str0ngP@ssw0rd' -v UPTIME -l days -c 1
Output:
System Uptime - 6 day(s) 17 hour(s) 7 minute(s) |uptime=6
System Uptime Shorter Than 1 Day
Unit: | Days |
Critical: | Up less than 1 day |
Command:
./check_nt -H 10.25.14.10 -p 12489 -s 'Str0ngP@ssw0rd' -v UPTIME -l days -c 1
Output:
System Uptime - 6 day(s) 17 hour(s) 6 minute(s) |uptime=6
NSClient++ via check_nrpe
NSClient++ includes a check_uptime module.
System Uptime Longer Than 1 Day
Unit: | Days |
Critical: | Up more than 1 day |
Command:
./check_nrpe -H 10.25.11.3 -c check_uptime -a 'warn= uptime > 1d' 'crit= uptime > 1d'
Output:
CRITICAL: uptime: 2w 3d 18:16h, boot: 2017-11-09 06:35:02 (UTC)|'uptime'=1534571s;86400;86400
System Uptime Shorter Than 1 Day
Unit: | Days |
Critical: | Up less than 1 day |
Command:
./check_nrpe -H 10.25.11.3 -c check_uptime -a 'warn= uptime < 1d' 'crit= uptime < 1d'
Output:
OK: uptime: 2w 3d 18:16h, boot: 2017-11-09 06:35:02 (UTC)|'uptime'=1534615s;86400;86400
WMI
Check WMI Plus includes a checkuptime module.
System Uptime Longer Than 1 Day
Unit: | Days |
Critical: | Up more than 1 day |
Command:
./check_wmi_plus.pl -H 10.25.14.3 -u wmiagent -p Str0ngP@ssw0rd -m checkuptime -c 1day
Output:
CRITICAL - [Triggered by _UptimeSec>1day] - System Uptime is 5 days 23:07:54 (8587min).|'Uptime Minutes'=8587min;1440;
System Uptime Shorter Than 1 Day
Unit: | Days |
Critical: | Up less than 1 day |
Command:
./check_wmi_plus.pl -H 10.25.14.3 -u wmiagent -p Str0ngP@ssw0rd -m checkuptime -c 1day:
Output:
OK - System Uptime is 5 days 23:07:50 (8587min).|'Uptime Minutes'=8587min;1440;
SNMP
The check_snmp plugin allows you to check the sysUpTime OID, the response returned is in timeticks.
System Uptime Longer Than 1 Day
Unit: | Timeticks |
Critical: | Up more than 8600000 timeticks (1 day) |
Command:
./check_snmp -H 10.25.4.1 -o sysUpTime.0 -C public -P 2c -l Uptime -c 0:8600000
Output:
SNMP CRITICAL - Uptime *3151082700* | Uptime=3151082700;;8600000;
System Uptime Shorter Than 1 Day
Unit: | Seconds |
Critical: | Up less than 86400 seconds (1 day) |
Command:
./check_snmp -H 10.25.4.1 -o sysUpTime.0 -C public -P 2c -l Uptime -c 8600000:0
Output:
SNMP OK - Uptime 3151084000 | Uptime=3151084000;;8600000;
Final Thoughts
For any support related questions please visit the Nagios Support Forums at: