From: Stephen L Johnson Date: Tue, 23 Nov 1999 21:06:10 +0000 (+0000) Subject: Initial revision X-Git-Tag: spong-2_6-beta7~11 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01f7c2c302af9f960b67c341840366dde0293b71;p=spong.git Initial revision --- diff --git a/src/lib/Spong/Network/plugins/check_ntp b/src/lib/Spong/Network/plugins/check_ntp new file mode 100755 index 0000000..d6700fd --- /dev/null +++ b/src/lib/Spong/Network/plugins/check_ntp @@ -0,0 +1,39 @@ +# Register the routine with the plugin registry +$PLUGINS{'ntp'} = \&check_ntp; + +# This check will check the status of the NTP service on a system. It uses +# the ntpdate command to query the service. If the offset is more then 1 +# second, it is a yellow status. If the host is not synchonized, it is red +# status + + +sub check_ntp { + my( $host ) = @_; + my( $color, $summary, $message ) = ( "green", "Server OK", "" ); + my( @output,$line ); + + $message = join(//,`$NTPDATE $host 2>&1`); + if ( $? != 0 ) { + $color = "red"; $summary = "NTP server down"; + { + undef $/; + if ($message =~ /server (.*), stratum (.*), offset (.*), delay (.*)/) { + my $offset = $3; my $stratum = $2; + if ( $stratum eq "16" ) { + $color = 'yellow'; + $summary = "Server is running, but not synchronized"; + } elsif (abs($offset) >= 1.0) { + $color = "yellow"; $summary = "server is $offset seconds off"; + } + } + } + } + + &debug( "ntp - $host - $color, $summary" ); + return( $color, $summary, $message ); +} + + + +1; +