Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_daytime
- Nagios 1.x
- Nagios 2.x
- Nagios 3.x
- Nagios XI
- Nagios Fusion
GPL
107060
File | Description |
---|---|
check_daytime.pl | check_daytime.pl |
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
If you need more precise measurements I suggest instead using NTPd but not everyone wants to bother setting it up and on most unix systems setting up time or utime is very easy with protocols supported as part of base inetd services.
For more information about using this plugin use '-h' option:
# ./check_daytime.pl --help
check_daytime plugin for nagios version 0.2
by William Leibzon - william(at)leibzon.org
Usage: ./check_daytime.pl -v | -h | -P daytime|daytime-udp|time|time-udp -p -H -w -c -t usec -f
This is a nagios plugin that connects to remote host using protocol specified with -P which can be either daytime (port 13) or RRC868 time service (port 37) running on TCP or UDP and then checks that time specified on remote host is no more then seconds different then local time on host executing this plugin. Port numbers (13 or 37) above can optionally be overridden with -p option. If daytime service is used the string returned by remote host should be in the format like '01 JAN 2006 12:01:01 PDT'
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST (STRING)
name or IP address of host to check (required parameter)
-P, --protocol=daytime|daytime-udp|time|time-udp
protocol used to get remote time (required paramter)
note that daytime protocol should give one string like
'01 JAN 2006 12:01:01 PDT'
(its parsed with Date::Parse str2time)
-p, --port=port (INTEGER)
This overrides default values set based on '--protocol'
parameter which are by default 13 for daytime and 37
for time protocols
-w, --warn=variance (INTEGER)
If the difference between remote host and localhost is more
then equal to this number of seconds then cause WARNING
returned to Nagios
-c, --critical=variance (INTEGER)
If the difference between remote host and localhost is more
then equal to this number of seconds then cause CRITICAL
error returned to Nagios
-t, --timeout=seconds (INTEGER)
timeout for network connection (default : 5 seconds)
-f, --perfparse
Causes time & difference not only in main status line
but also as perfparse output
-o, --formout=str|usec
Time printed as output is a readable time string when 'str'
is specified (default) or unix seconds with 1970
(when usec is specified)
Reviews (1)
Very good plugin!
It work perfect in all my servers except one with Ubuntu. In this case the check return "TIME CRITICAL - time is Wed Dec 31 21:00:00 1969".
So after debugging the problem i realized that in the line 197 of the plugin there was a command that changed string to time (str2time) and it was returning empty value.
The problem was the date format from the remote server (09 AUG 2014 16:20:41 ART). More specific it was the "ART" at the end of the date string.
So in my particular case i fixed it adding an if that verify if the command str2time return a empty value, then execute the command chop to the variable that was holding the date four times in way to erase the ART.
With that change it started to work with no problem!
Thanks!
It work perfect in all my servers except one with Ubuntu. In this case the check return "TIME CRITICAL - time is Wed Dec 31 21:00:00 1969".
So after debugging the problem i realized that in the line 197 of the plugin there was a command that changed string to time (str2time) and it was returning empty value.
The problem was the date format from the remote server (09 AUG 2014 16:20:41 ART). More specific it was the "ART" at the end of the date string.
So in my particular case i fixed it adding an if that verify if the command str2time return a empty value, then execute the command chop to the variable that was holding the date four times in way to erase the ART.
With that change it started to work with no problem!
Thanks!