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

check_daytime

Compatible With
  • Nagios 1.x
  • Nagios 2.x
  • Nagios 3.x
  • Nagios XI
  • Nagios Fusion
Owner
License
GPL
Hits
100853
Files:
FileDescription
check_daytime.plcheck_daytime.pl
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
This plugin checks that time on remote host is no more than specified number of seconds different than on nagios server. The time is checked using TCP or UDP using either daytime (port 13) or time (port 37) protocols.

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)
bymaty314, August 9, 2014
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!