1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
Index: plugins-scripts/check_ntp.pl
===================================================================
--- plugins-scripts/check_ntp.pl (revision 18)
+++ plugins-scripts/check_ntp.pl (working copy)
@@ -270,11 +270,11 @@
if (/^(\*|\+|\#|o])/) {
++$candidate;
push (@candidates, $_);
- print "Candiate count= $candidate\n" if ($verbose);
+ print "Candidate count= $candidate\n" if ($verbose);
}
# match sys.peer or pps.peer
- if (/^(\*|o)([-0-9.\s]+)\s+([-0-9A-Za-z.]+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) {
+ if (/^(\*|o)([-0-9.]+)\s+(\S+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) {
$syspeer = $2;
$stratum = $4;
$jitter = $11;
@@ -283,11 +283,14 @@
print "Jitter_crit = $11 :$jcrit\n" if ($verbose);
$jitter_error = $ERRORS{'CRITICAL'};
} elsif ($jitter > $jwarn ) {
- print "Jitter_warn = $11 :$jwarn \n" if ($verbose);
+ print "Jitter_warn = $11 :$jwarn\n" if ($verbose);
$jitter_error = $ERRORS{'WARNING'};
} else {
$jitter_error = $ERRORS{'OK'};
}
+ } else {
+ print "No match!\n" if $verbose;
+ $jitter = '(not parsed)';
}
}
@@ -324,53 +327,53 @@
if ($ntpdate_error != $ERRORS{'OK'}) {
$state = $ntpdate_error;
if ($ntpdate_error == $ERRORS{'WARNING'} ) {
- $answer = $msg . "\n";
+ $answer = $msg;
}
else {
- $answer = $msg . "Server for ntp probably down\n";
+ $answer = $msg . "Server for ntp probably down";
}
if (defined($offset) && abs($offset) > $ocrit) {
$state = $ERRORS{'CRITICAL'};
- $answer = "Server Error and offset $offset sec > +/- $ocrit sec\n";
+ $answer = "Server Error and offset $offset sec > +/- $ocrit sec";
} elsif (defined($offset) && abs($offset) > $owarn) {
- $answer = "Server error and offset $offset sec > +/- $owarn sec\n";
+ $answer = "Server error and offset $offset sec > +/- $owarn sec";
} elsif (defined($jitter) && abs($jitter) > $jcrit) {
- $answer = "Server error and jitter $jitter msec > +/- $jcrit msec\n";
+ $answer = "Server error and jitter $jitter msec > +/- $jcrit msec";
} elsif (defined($jitter) && abs($jitter) > $jwarn) {
- $answer = "Server error and jitter $jitter msec > +/- $jwarn msec\n";
+ $answer = "Server error and jitter $jitter msec > +/- $jwarn msec";
}
} elsif ($have_ntpq && $jitter_error != $ERRORS{'OK'}) {
$state = $jitter_error;
- $answer = "Jitter $jitter too high\n";
+ $answer = "Jitter $jitter too high";
if (defined($offset) && abs($offset) > $ocrit) {
$state = $ERRORS{'CRITICAL'};
- $answer = "Jitter error and offset $offset sec > +/- $ocrit sec\n";
+ $answer = "Jitter error and offset $offset sec > +/- $ocrit sec";
} elsif (defined($offset) && abs($offset) > $owarn) {
- $answer = "Jitter error and offset $offset sec > +/- $owarn sec\n";
+ $answer = "Jitter error and offset $offset sec > +/- $owarn sec";
} elsif (defined($jitter) && abs($jitter) > $jcrit) {
- $answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec\n";
+ $answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec";
} elsif (defined($jitter) && abs($jitter) > $jwarn) {
- $answer = "Jitter error and jitter $jitter msec > +/- $jwarn msec\n";
+ $answer = "Jitter error and jitter $jitter msec > +/- $jwarn msec";
}
} elsif( !$have_ntpq ) { # no errors from ntpdate and no ntpq or ntpq timed out
if (abs($offset) > $ocrit) {
$state = $ERRORS{'CRITICAL'};
- $answer = "Offset $offset sec > +/- $ocrit sec\n";
+ $answer = "Offset $offset sec > +/- $ocrit sec";
} elsif (abs($offset) > $owarn) {
$state = $ERRORS{'WARNING'};
- $answer = "Offset $offset sec > +/- $owarn sec\n";
+ $answer = "Offset $offset sec > +/- $owarn sec";
} elsif (( abs($offset) > $owarn) && $def_jitter ) {
$state = $ERRORS{'WARNING'};
- $answer = "Offset $offset sec > +/- $owarn sec, ntpq timed out\n";
+ $answer = "Offset $offset sec > +/- $owarn sec, ntpq timed out";
} elsif ( $def_jitter ) {
$state = $ERRORS{'WARNING'};
- $answer = "Offset $offset secs, ntpq timed out\n";
+ $answer = "Offset $offset secs, ntpq timed out";
} else{
$state = $ERRORS{'OK'};
- $answer = "Offset $offset secs \n";
+ $answer = "Offset $offset secs ";
}
@@ -378,27 +381,27 @@
} else { # no errors from ntpdate or ntpq
if (abs($offset) > $ocrit) {
$state = $ERRORS{'CRITICAL'};
- $answer = "Offset $offset sec > +/- $ocrit sec, jitter $jitter msec\n";
+ $answer = "Offset $offset sec > +/- $ocrit sec, jitter $jitter msec";
} elsif (abs($jitter) > $jcrit ) {
$state = $ERRORS{'CRITICAL'};
- $answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec \n";
+ $answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec";
} elsif (abs($offset) > $owarn) {
$state = $ERRORS{'WARNING'};
- $answer = "Offset $offset sec > +/- $owarn sec, jitter $jitter msec\n";
+ $answer = "Offset $offset sec > +/- $owarn sec, jitter $jitter msec";
} elsif (abs($jitter) > $jwarn ) {
$state = $ERRORS{'WARNING'};
- $answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec \n";
+ $answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec";
} else {
$state = $ERRORS{'OK'};
- $answer = "Offset $offset secs, jitter $jitter msec, peer is stratum $stratum\n";
+ $answer = "Offset $offset secs, jitter $jitter msec, peer is stratum $stratum";
}
}
foreach my $key (keys %ERRORS) {
if ($state==$ERRORS{$key}) {
- print ("NTP $key: $answer");
+ print ("NTP $key: $answer|offset=$offset, jitter=" . $jitter/1000 . "\n");
last;
}
}
|