summaryrefslogtreecommitdiffstats
path: root/plugins-scripts/check_ntp.pl
diff options
context:
space:
mode:
authorSubhendu Ghosh <sghosh@users.sourceforge.net>2002-09-04 02:12:05 +0000
committerSubhendu Ghosh <sghosh@users.sourceforge.net>2002-09-04 02:12:05 +0000
commit91c089475cc8be8531a6f19f2a30a9f0c641e489 (patch)
tree1acdb3ca32e614e266a3226b41f1a97b43765604 /plugins-scripts/check_ntp.pl
parent4a079cf372ddfaaa80ad3843ce7c9a0c5e2700da (diff)
downloadmonitoring-plugins-91c089475cc8be8531a6f19f2a30a9f0c641e489.tar.gz
dispersion check now controlled by warn and crit
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@90 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts/check_ntp.pl')
-rwxr-xr-xplugins-scripts/check_ntp.pl27
1 files changed, 15 insertions, 12 deletions
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl
index fee58e69..dce515ef 100755
--- a/plugins-scripts/check_ntp.pl
+++ b/plugins-scripts/check_ntp.pl
@@ -76,8 +76,8 @@ GetOptions
76 ("V" => \$opt_V, "version" => \$opt_V, 76 ("V" => \$opt_V, "version" => \$opt_V,
77 "h" => \$opt_h, "help" => \$opt_h, 77 "h" => \$opt_h, "help" => \$opt_h,
78 "v" => \$verbose, "verbose" => \$verbose, 78 "v" => \$verbose, "verbose" => \$verbose,
79 "w=s" => \$opt_w, "warning=s" => \$opt_w, # offset|adjust warning if above this number 79 "w=f" => \$opt_w, "warning=f" => \$opt_w, # offset|adjust warning if above this number
80 "c=s" => \$opt_c, "critical=s" => \$opt_c, # offset|adjust critical if above this number 80 "c=f" => \$opt_c, "critical=f" => \$opt_c, # offset|adjust critical if above this number
81 "H=s" => \$opt_H, "hostname=s" => \$opt_H); 81 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
82 82
83if ($opt_V) { 83if ($opt_V) {
@@ -98,13 +98,14 @@ unless ($host) {
98 exit $ERRORS{'UNKNOWN'}; 98 exit $ERRORS{'UNKNOWN'};
99} 99}
100 100
101($opt_w) || ($opt_w = shift) || ($opt_w = 60); 101($opt_w) || ($opt_w = 60);
102my $warning = $1 if ($opt_w =~ /([0-9]+)/); 102my $warning = $1 if ($opt_w =~ /([0-9.]+)/);
103 103
104($opt_c) || ($opt_c = shift) || ($opt_c = 120); 104($opt_c) || ($opt_c = 120);
105my $critical = $1 if ($opt_c =~ /([0-9]+)/); 105my $critical = $1 if ($opt_c =~ /([0-9.]+)/);
106 106
107if ($opt_c < $opt_w) { 107
108if ($critical < $warning ) {
108 print "Critical offset should be larger than warning offset\n"; 109 print "Critical offset should be larger than warning offset\n";
109 print_usage(); 110 print_usage();
110 exit $ERRORS{"UNKNOWN"}; 111 exit $ERRORS{"UNKNOWN"};
@@ -189,11 +190,11 @@ if ($have_ntpdc) {
189 while (<NTPDC>) { 190 while (<NTPDC>) {
190 print $_ if ($verbose); 191 print $_ if ($verbose);
191 if (/([^\s]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) { 192 if (/([^\s]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) {
192 if ($8>15) { 193 if ($8 gt $critical) {
193 print "Dispersion = $8 \n" if ($verbose); 194 print "Dispersion_crit = $8 :$critical\n" if ($verbose);
194 $dispersion_error = $ERRORS{'CRITICAL'}; 195 $dispersion_error = $ERRORS{'CRITICAL'};
195 } elsif ($8>5 && $dispersion_error<$ERRORS{'CRITICAL'}) { 196 } elsif ($8 gt $warning ) {
196 print "Dispersion = $8 \n" if ($verbose); 197 print "Dispersion_warn = $8 :$warning \n" if ($verbose);
197 $dispersion_error = $ERRORS{'WARNING'}; 198 $dispersion_error = $ERRORS{'WARNING'};
198 } else { 199 } else {
199 $dispersion_error = $ERRORS{'OK'}; 200 $dispersion_error = $ERRORS{'OK'};
@@ -252,7 +253,7 @@ foreach $key (keys %ERRORS) {
252exit $state; 253exit $state;
253 254
254sub print_usage () { 255sub print_usage () {
255 print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n"; 256 print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>] [-v verbose]\n";
256} 257}
257 258
258sub print_help () { 259sub print_help () {
@@ -263,5 +264,7 @@ sub print_help () {
263 print "\n"; 264 print "\n";
264 print "<warn> = Clock offset in seconds at which a warning message will be generated.\n Defaults to 60.\n"; 265 print "<warn> = Clock offset in seconds at which a warning message will be generated.\n Defaults to 60.\n";
265 print "<crit> = Clock offset in seconds at which a critical message will be generated.\n Defaults to 120.\n\n"; 266 print "<crit> = Clock offset in seconds at which a critical message will be generated.\n Defaults to 120.\n\n";
267 print "The same warning and critical values are used to check against the dispersion \n";
268 print "column of ntpdc/xntpdc for the host being queried.\n\n";
266 support(); 269 support();
267} 270}