Home Directory Plugins Operating Systems Linux check_uptime with full support for notifications

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me
Don't miss your chance to attend the 2014 Nagios World conference!

Don't miss your chance to attend the 2014 Nagios World Conference, Oct 13-16th. Informative Sessions, Networking, Food and Cocktails! Visit go.nagios.com/conference/ for more information or to register.


check_uptime with full support for notifications

Bookmark and Share

Current Version
7
Last Release Date
2013-02-07
Compatible With
  • Nagios 3.x
E-mail
License
GPL
Hits
33120
Files:
FileDescription
nagios-plugins-uptime-7.tar.gzcheck_uptime version 7
This Nagios plugin checks the time the server is running.
It can be used to notify (with a warning or critical exit status) if an host has a boot time lower or greater than a given number of minutes. You can specify the notification ranges by using the standard Nagios syntax: '[@]start:end'.
Usage:
check_uptime [--warning [@]start:end] [--critical [@]start:end]

Examples:
check_uptime
check_uptime --warning 30: --critical 15:

Supported platforms:
* Linux (tested on openmamba GNU/Linux and RHEL 4,5,6)
* FreeBSD 8.2-RELEASE-p10
* AIX 6.1 with gcc 4.2.0
* Solaris 11.1 (SunOS solaris 5.11 11.1) with gcc 4.5.2
* OpenIndiana build 151a7 with gcc 4.3.3
* OpenBSD 5.2 with gcc 4,2,1

Please drop me a note if this plugin does not compile or run on your favorite os!

Note. The corresponding plugin shipped by nagios-plugins 2.0 or better is based on the clock monotonic function (clock_gettime() with clockid_t eq. to CLOCK_MONOTONIC).
According to the POSIX specifications "the value returned by clock_gettime() represents the amount of time (in seconds and nanoseconds) since an unspecified point in the past (for example, system start-time, or the Epoch)".
The (recent) Linux kernels returns a value that is somehow related to the system start-time but can be different from the output of the command uptime (procps), or the first value returned by /proc/uptime.

$ /usr/bin/uptime
18:45:00 up 8:46, 7 users, load average: 0.67, 1.79, 2.49
$ awk '{printf("%02d:%02dn",($1/60/60%24),($1/60%60))}' /proc/uptime
08:46
$ ./clock_monotonic
4 hours 37 min

Conversely, the implementation followed by this Nagios plugins is compatible with uptime and /proc/uptime
Reviews (1)
byphilippe_CANDIDO, January 4, 2013
1 of 1 people found this review helpful
This plugin was successfully tested in our production environment on 800 hosts.

Now we can see when a host reboots unexpectedly. We are using a critical threshold when uptime is less than 15mn.

Thx for your contribution.