From 50e9f7be43abb58b864aacdd5bed4eccf392be47 Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Tue, 23 Nov 1999 21:06:10 +0000 Subject: [PATCH] Initial import --- src/lib/Spong/Network/plugins/check_ntp | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 src/lib/Spong/Network/plugins/check_ntp 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; + -- 2.30.2