1 /*****************************************************************************
3 * Nagios check_ntp_peer plugin
6 * Copyright (c) 2006 Sean Finney <seanius@seanius.net>
7 * Copyright (c) 2006-2008 Nagios Plugins Development Team
11 * This file contains the check_ntp_peer plugin
13 * This plugin checks an NTP server independent of any commandline
14 * programs or external libraries.
16 * Use this plugin to check the health of an NTP server. It supports
17 * checking the offset with the sync peer, the jitter and stratum. This
18 * plugin will not check the clock offset between the local host and NTP
19 * server; please use check_ntp_time for that purpose.
22 * This program is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <http://www.gnu.org/licenses/>.
36 *****************************************************************************/
38 const char *progname
= "check_ntp_peer";
39 const char *copyright
= "2006-2008";
40 const char *email
= "nagiosplug-devel@lists.sourceforge.net";
46 static char *server_address
=NULL
;
50 static short do_offset
=0;
51 static char *owarn
="60";
52 static char *ocrit
="120";
53 static short do_stratum
=0;
54 static char *swarn
="-1:16";
55 static char *scrit
="-1:16";
56 static short do_jitter
=0;
57 static char *jwarn
="-1:5000";
58 static char *jcrit
="-1:10000";
59 static short do_truechimers
=0;
60 static char *twarn
="0:";
61 static char *tcrit
="0:";
62 static int syncsource_found
=0;
63 static int li_alarm
=0;
65 int process_arguments (int, char **);
66 thresholds
*offset_thresholds
= NULL
;
67 thresholds
*jitter_thresholds
= NULL
;
68 thresholds
*stratum_thresholds
= NULL
;
69 thresholds
*truechimer_thresholds
= NULL
;
70 void print_help (void);
71 void print_usage (void);
73 /* max size of control message data */
74 #define MAX_CM_SIZE 468
76 /* this structure holds everything in an ntp control message as per rfc1305 */
78 uint8_t flags
; /* byte with leapindicator,vers,mode. see macros */
79 uint8_t op
; /* R,E,M bits and Opcode */
80 uint16_t seq
; /* Packet sequence */
81 uint16_t status
; /* Clock status */
82 uint16_t assoc
; /* Association */
83 uint16_t offset
; /* Similar to TCP sequence # */
84 uint16_t count
; /* # bytes of data */
85 char data
[MAX_CM_SIZE
]; /* ASCII data of the request */
86 /* NB: not necessarily NULL terminated! */
87 } ntp_control_message
;
89 /* this is an association/status-word pair found in control packet reponses */
93 } ntp_assoc_status_pair
;
95 /* bits 1,2 are the leap indicator */
97 #define LI(x) ((x&LI_MASK)>>6)
98 #define LI_SET(x,y) do{ x |= ((y<<6)&LI_MASK); }while(0)
99 /* and these are the values of the leap indicator */
100 #define LI_NOWARNING 0x00
101 #define LI_EXTRASEC 0x01
102 #define LI_MISSINGSEC 0x02
103 #define LI_ALARM 0x03
104 /* bits 3,4,5 are the ntp version */
106 #define VN(x) ((x&VN_MASK)>>3)
107 #define VN_SET(x,y) do{ x |= ((y<<3)&VN_MASK); }while(0)
108 #define VN_RESERVED 0x02
109 /* bits 6,7,8 are the ntp mode */
110 #define MODE_MASK 0x07
111 #define MODE(x) (x&MODE_MASK)
112 #define MODE_SET(x,y) do{ x |= (y&MODE_MASK); }while(0)
113 /* here are some values */
114 #define MODE_CLIENT 0x03
115 #define MODE_CONTROLMSG 0x06
116 /* In control message, bits 8-10 are R,E,M bits */
117 #define REM_MASK 0xe0
118 #define REM_RESP 0x80
119 #define REM_ERROR 0x40
120 #define REM_MORE 0x20
121 /* In control message, bits 11 - 15 are opcode */
123 #define OP_SET(x,y) do{ x |= (y&OP_MASK); }while(0)
124 #define OP_READSTAT 0x01
125 #define OP_READVAR 0x02
126 /* In peer status bytes, bits 6,7,8 determine clock selection status */
127 #define PEER_SEL(x) ((ntohs(x)>>8)&0x07)
128 #define PEER_TRUECHIMER 0x02
129 #define PEER_INCLUDED 0x04
130 #define PEER_SYNCSOURCE 0x06
132 /* NTP control message header is 12 bytes, plus any data in the data
133 * field, plus null padding to the nearest 32-bit boundary per rfc.
135 #define SIZEOF_NTPCM(m) (12+ntohs(m.count)+((ntohs(m.count)%4)?4-(ntohs(m.count)%4):0))
137 /* finally, a little helper or two for debugging: */
138 #define DBG(x) do{if(verbose>1){ x; }}while(0);
139 #define PRINTSOCKADDR(x) \
141 printf("%u.%u.%u.%u", (x>>24)&0xff, (x>>16)&0xff, (x>>8)&0xff, x&0xff);\
144 void print_ntp_control_message(const ntp_control_message
*p
){
146 const ntp_assoc_status_pair
*peer
=NULL
;
148 printf("control packet contents:\n");
149 printf("\tflags: 0x%.2x , 0x%.2x\n", p
->flags
, p
->op
);
150 printf("\t li=%d (0x%.2x)\n", LI(p
->flags
), p
->flags
&LI_MASK
);
151 printf("\t vn=%d (0x%.2x)\n", VN(p
->flags
), p
->flags
&VN_MASK
);
152 printf("\t mode=%d (0x%.2x)\n", MODE(p
->flags
), p
->flags
&MODE_MASK
);
153 printf("\t response=%d (0x%.2x)\n", (p
->op
&REM_RESP
)>0, p
->op
&REM_RESP
);
154 printf("\t more=%d (0x%.2x)\n", (p
->op
&REM_MORE
)>0, p
->op
&REM_MORE
);
155 printf("\t error=%d (0x%.2x)\n", (p
->op
&REM_ERROR
)>0, p
->op
&REM_ERROR
);
156 printf("\t op=%d (0x%.2x)\n", p
->op
&OP_MASK
, p
->op
&OP_MASK
);
157 printf("\tsequence: %d (0x%.2x)\n", ntohs(p
->seq
), ntohs(p
->seq
));
158 printf("\tstatus: %d (0x%.2x)\n", ntohs(p
->status
), ntohs(p
->status
));
159 printf("\tassoc: %d (0x%.2x)\n", ntohs(p
->assoc
), ntohs(p
->assoc
));
160 printf("\toffset: %d (0x%.2x)\n", ntohs(p
->offset
), ntohs(p
->offset
));
161 printf("\tcount: %d (0x%.2x)\n", ntohs(p
->count
), ntohs(p
->count
));
162 numpeers
=ntohs(p
->count
)/(sizeof(ntp_assoc_status_pair
));
163 if(p
->op
&REM_RESP
&& p
->op
&OP_READSTAT
){
164 peer
=(ntp_assoc_status_pair
*)p
->data
;
165 for(i
=0;i
<numpeers
;i
++){
166 printf("\tpeer id %.2x status %.2x",
167 ntohs(peer
[i
].assoc
), ntohs(peer
[i
].status
));
168 if(PEER_SEL(peer
[i
].status
) >= PEER_SYNCSOURCE
){
169 printf(" <-- current sync source");
170 } else if(PEER_SEL(peer
[i
].status
) >= PEER_INCLUDED
){
171 printf(" <-- current sync candidate");
172 } else if(PEER_SEL(peer
[i
].status
) >= PEER_TRUECHIMER
){
173 printf(" <-- outlyer, but truechimer");
181 setup_control_request(ntp_control_message
*p
, uint8_t opcode
, uint16_t seq
){
182 memset(p
, 0, sizeof(ntp_control_message
));
183 LI_SET(p
->flags
, LI_NOWARNING
);
184 VN_SET(p
->flags
, VN_RESERVED
);
185 MODE_SET(p
->flags
, MODE_CONTROLMSG
);
186 OP_SET(p
->op
, opcode
);
188 /* Remaining fields are zero for requests */
191 /* This function does all the actual work; roughly here's what it does
192 * beside setting the offest, jitter and stratum passed as argument:
193 * - offset can be negative, so if it cannot get the offset, offset_result
194 * is set to UNKNOWN, otherwise OK.
195 * - jitter and stratum are set to -1 if they cannot be retrieved so any
196 * positive value means a success retrieving the value.
197 * - status is set to WARNING if there's no sync.peer (otherwise OK) and is
198 * the return value of the function.
199 * status is pretty much useless as syncsource_found is a global variable
200 * used later in main to check is the server was synchronized. It works
201 * so I left it alone */
202 int ntp_request(const char *host
, double *offset
, int *offset_result
, double *jitter
, int *stratum
, int *num_truechimers
){
203 int conn
=-1, i
, npeers
=0, num_candidates
=0;
204 double tmp_offset
= 0;
205 int min_peer_sel
=PEER_INCLUDED
;
206 int peers_size
=0, peer_offset
=0;
208 ntp_assoc_status_pair
*peers
=NULL
;
209 ntp_control_message req
;
210 const char *getvar
= "stratum,offset,jitter";
211 char *data
, *value
, *nptr
;
215 *offset_result
= STATE_UNKNOWN
;
216 *jitter
= *stratum
= -1;
217 *num_truechimers
= 0;
219 /* Long-winded explanation:
220 * Getting the sync peer offset, jitter and stratum requires a number of
222 * 1) Send a READSTAT request.
223 * 2) Interpret the READSTAT reply
224 * a) The data section contains a list of peer identifiers (16 bits)
225 * and associated status words (16 bits)
226 * b) We want the value of 0x06 in the SEL (peer selection) value,
227 * which means "current synchronizatin source". If that's missing,
228 * we take anything better than 0x04 (see the rfc for details) but
229 * set a minimum of warning.
230 * 3) Send a READVAR request for information on each peer identified
231 * in 2b greater than the minimum selection value.
232 * 4) Extract the offset, jitter and stratum value from the data[]
235 my_udp_connect(server_address
, port
, &conn
);
237 /* keep sending requests until the server stops setting the
238 * REM_MORE bit, though usually this is only 1 packet. */
240 setup_control_request(&req
, OP_READSTAT
, 1);
241 DBG(printf("sending READSTAT request"));
242 write(conn
, &req
, SIZEOF_NTPCM(req
));
243 DBG(print_ntp_control_message(&req
));
244 /* Attempt to read the largest size packet possible */
245 req
.count
=htons(MAX_CM_SIZE
);
246 DBG(printf("recieving READSTAT response"))
247 if(read(conn
, &req
, SIZEOF_NTPCM(req
)) == -1)
248 die(STATE_CRITICAL
, "NTP CRITICAL: No response from NTP server\n");
249 DBG(print_ntp_control_message(&req
));
250 /* discard obviously invalid packets */
251 if (ntohs(req
.count
) > MAX_CM_SIZE
)
252 die(STATE_CRITICAL
, "NTP CRITICAL: Invalid packet received from NTP server\n");
253 if (LI(req
.flags
) == LI_ALARM
) li_alarm
= 1;
254 /* Each peer identifier is 4 bytes in the data section, which
255 * we represent as a ntp_assoc_status_pair datatype.
257 peers_size
+=ntohs(req
.count
);
258 if((tmp
=realloc(peers
, peers_size
)) == NULL
)
259 free(peers
), die(STATE_UNKNOWN
, "can not (re)allocate 'peers' buffer\n");
261 memcpy((void*)((ptrdiff_t)peers
+peer_offset
), (void*)req
.data
, ntohs(req
.count
));
262 npeers
=peers_size
/sizeof(ntp_assoc_status_pair
);
263 peer_offset
+=ntohs(req
.count
);
264 } while(req
.op
&REM_MORE
);
266 /* first, let's find out if we have a sync source, or if there are
267 * at least some candidates. In the latter case we'll issue
268 * a warning but go ahead with the check on them. */
269 for (i
= 0; i
< npeers
; i
++){
270 if(PEER_SEL(peers
[i
].status
) >= PEER_TRUECHIMER
){
271 (*num_truechimers
)++;
272 if(PEER_SEL(peers
[i
].status
) >= PEER_INCLUDED
){
274 if(PEER_SEL(peers
[i
].status
) >= PEER_SYNCSOURCE
){
276 min_peer_sel
=PEER_SYNCSOURCE
;
281 if(verbose
) printf("%d candidate peers available\n", num_candidates
);
282 if(verbose
&& syncsource_found
) printf("synchronization source found\n");
283 if(! syncsource_found
){
284 status
= STATE_WARNING
;
285 if(verbose
) printf("warning: no synchronization source found\n");
288 status
= STATE_WARNING
;
289 if(verbose
) printf("warning: LI_ALARM bit is set\n");
293 for (i
= 0; i
< npeers
; i
++){
294 /* Only query this server if it is the current sync source */
295 /* If there's no sync.peer, query all candidates and use the best one */
296 if (PEER_SEL(peers
[i
].status
) >= min_peer_sel
){
297 if(verbose
) printf("Getting offset, jitter and stratum for peer %.2x\n", ntohs(peers
[i
].assoc
));
300 setup_control_request(&req
, OP_READVAR
, 2);
301 req
.assoc
= peers
[i
].assoc
;
302 /* Putting the wanted variable names in the request
303 * cause the server to provide _only_ the requested values.
304 * thus reducing net traffic, guaranteeing us only a single
305 * datagram in reply, and making intepretation much simpler
307 /* Older servers doesn't know what jitter is, so if we get an
308 * error on the first pass we redo it with "dispersion" */
309 strncpy(req
.data
, getvar
, MAX_CM_SIZE
-1);
310 req
.count
= htons(strlen(getvar
));
311 DBG(printf("sending READVAR request...\n"));
312 write(conn
, &req
, SIZEOF_NTPCM(req
));
313 DBG(print_ntp_control_message(&req
));
315 req
.count
= htons(MAX_CM_SIZE
);
316 DBG(printf("receiving READVAR response...\n"));
317 read(conn
, &req
, SIZEOF_NTPCM(req
));
318 DBG(print_ntp_control_message(&req
));
320 if(!(req
.op
&REM_ERROR
))
321 asprintf(&data
, "%s%s", data
, req
.data
);
322 } while(req
.op
&REM_MORE
);
324 if(req
.op
&REM_ERROR
) {
325 if(strstr(getvar
, "jitter")) {
326 if(verbose
) printf("The command failed. This is usually caused by servers refusing the 'jitter'\nvariable. Restarting with 'dispersion'...\n");
327 getvar
= "stratum,offset,dispersion";
330 } else if(strlen(getvar
)) {
331 if(verbose
) printf("Server didn't like dispersion either; will retrieve everything\n");
339 printf("Server responded: >>>%s<<<\n", data
);
343 printf("parsing offset from peer %.2x: ", ntohs(peers
[i
].assoc
));
345 value
= np_extract_ntpvar(data
, "offset");
347 /* Convert the value if we have one */
349 tmp_offset
= strtod(value
, &nptr
) / 1000;
350 /* If value is null or no conversion was performed */
351 if(value
== NULL
|| value
==nptr
) {
352 if(verbose
) printf("error: unable to read server offset response.\n");
354 if(verbose
) printf("%.10g\n", tmp_offset
);
355 if(*offset_result
== STATE_UNKNOWN
|| fabs(tmp_offset
) < fabs(*offset
)) {
356 *offset
= tmp_offset
;
357 *offset_result
= STATE_OK
;
359 /* Skip this one; move to the next */
367 printf("parsing %s from peer %.2x: ", strstr(getvar
, "dispersion") != NULL
? "dispersion" : "jitter", ntohs(peers
[i
].assoc
));
369 value
= np_extract_ntpvar(data
, strstr(getvar
, "dispersion") != NULL
? "dispersion" : "jitter");
371 /* Convert the value if we have one */
373 *jitter
= strtod(value
, &nptr
);
374 /* If value is null or no conversion was performed */
375 if(value
== NULL
|| value
==nptr
) {
376 if(verbose
) printf("error: unable to read server jitter/dispersion response.\n");
379 printf("%.10g\n", *jitter
);
384 /* get the stratum */
386 printf("parsing stratum from peer %.2x: ", ntohs(peers
[i
].assoc
));
388 value
= np_extract_ntpvar(data
, "stratum");
390 /* Convert the value if we have one */
392 *stratum
= strtol(value
, &nptr
, 10);
393 if(value
== NULL
|| value
==nptr
) {
394 if(verbose
) printf("error: unable to read server stratum response.\n");
397 if(verbose
) printf("%i\n", *stratum
);
400 } /* if (PEER_SEL(peers[i].status) >= min_peer_sel) */
401 } /* for (i = 0; i < npeers; i++) */
404 if(peers
!=NULL
) free(peers
);
409 int process_arguments(int argc
, char **argv
){
412 static struct option longopts
[] = {
413 {"version", no_argument
, 0, 'V'},
414 {"help", no_argument
, 0, 'h'},
415 {"verbose", no_argument
, 0, 'v'},
416 {"use-ipv4", no_argument
, 0, '4'},
417 {"use-ipv6", no_argument
, 0, '6'},
418 {"quiet", no_argument
, 0, 'q'},
419 {"warning", required_argument
, 0, 'w'},
420 {"critical", required_argument
, 0, 'c'},
421 {"swarn", required_argument
, 0, 'W'},
422 {"scrit", required_argument
, 0, 'C'},
423 {"jwarn", required_argument
, 0, 'j'},
424 {"jcrit", required_argument
, 0, 'k'},
425 {"twarn", required_argument
, 0, 'm'},
426 {"tcrit", required_argument
, 0, 'n'},
427 {"timeout", required_argument
, 0, 't'},
428 {"hostname", required_argument
, 0, 'H'},
429 {"port", required_argument
, 0, 'p'},
438 c
= getopt_long (argc
, argv
, "Vhv46qw:c:W:C:j:k:m:n:t:H:p:", longopts
, &option
);
439 if (c
== -1 || c
== EOF
|| c
== 1)
448 print_revision(progname
, NP_VERSION
);
490 if(is_host(optarg
) == FALSE
)
491 usage2(_("Invalid hostname/address"), optarg
);
492 server_address
= strdup(optarg
);
498 socket_timeout
=atoi(optarg
);
501 address_family
= AF_INET
;
505 address_family
= AF_INET6
;
507 usage4 (_("IPv6 support not available"));
511 /* print short usage statement if args not parsable */
517 if(server_address
== NULL
){
518 usage4(_("Hostname was not supplied"));
524 char *perfd_offset (double offset
)
526 return fperfdata ("offset", offset
, "s",
527 TRUE
, offset_thresholds
->warning
->end
,
528 TRUE
, offset_thresholds
->critical
->end
,
532 char *perfd_jitter (double jitter
)
534 return fperfdata ("jitter", jitter
, "",
535 do_jitter
, jitter_thresholds
->warning
->end
,
536 do_jitter
, jitter_thresholds
->critical
->end
,
540 char *perfd_stratum (int stratum
)
542 return perfdata ("stratum", stratum
, "",
543 do_stratum
, (int)stratum_thresholds
->warning
->end
,
544 do_stratum
, (int)stratum_thresholds
->critical
->end
,
548 char *perfd_truechimers (int num_truechimers
)
550 return perfdata ("truechimers", num_truechimers
, "",
551 do_truechimers
, (int)truechimer_thresholds
->warning
->end
,
552 do_truechimers
, (int)truechimer_thresholds
->critical
->end
,
556 int main(int argc
, char *argv
[]){
557 int result
, offset_result
, stratum
, num_truechimers
;
558 double offset
=0, jitter
=0;
559 char *result_line
, *perfdata_line
;
561 setlocale (LC_ALL
, "");
562 bindtextdomain (PACKAGE
, LOCALEDIR
);
563 textdomain (PACKAGE
);
565 /* Parse extra opts if any */
566 argv
=np_extra_opts (&argc
, argv
, progname
);
568 if (process_arguments (argc
, argv
) == ERROR
)
569 usage4 (_("Could not parse arguments"));
571 set_thresholds(&offset_thresholds
, owarn
, ocrit
);
572 set_thresholds(&jitter_thresholds
, jwarn
, jcrit
);
573 set_thresholds(&stratum_thresholds
, swarn
, scrit
);
574 set_thresholds(&truechimer_thresholds
, twarn
, tcrit
);
576 /* initialize alarm signal handling */
577 signal (SIGALRM
, socket_timeout_alarm_handler
);
579 /* set socket timeout */
580 alarm (socket_timeout
);
582 /* This returns either OK or WARNING (See comment preceeding ntp_request) */
583 result
= ntp_request(server_address
, &offset
, &offset_result
, &jitter
, &stratum
, &num_truechimers
);
585 if(offset_result
== STATE_UNKNOWN
) {
586 /* if there's no sync peer (this overrides ntp_request output): */
587 result
= (quiet
== 1 ? STATE_UNKNOWN
: STATE_CRITICAL
);
589 /* Be quiet if there's no candidates either */
590 if (quiet
== 1 && result
== STATE_WARNING
)
591 result
= STATE_UNKNOWN
;
592 result
= max_state_alt(result
, get_status(fabs(offset
), offset_thresholds
));
596 result
= max_state_alt(result
, get_status(num_truechimers
, truechimer_thresholds
));
599 result
= max_state_alt(result
, get_status(stratum
, stratum_thresholds
));
602 result
= max_state_alt(result
, get_status(jitter
, jitter_thresholds
));
605 case STATE_CRITICAL
:
606 asprintf(&result_line
, _("NTP CRITICAL:"));
609 asprintf(&result_line
, _("NTP WARNING:"));
612 asprintf(&result_line
, _("NTP OK:"));
615 asprintf(&result_line
, _("NTP UNKNOWN:"));
618 if(!syncsource_found
)
619 asprintf(&result_line
, "%s %s,", result_line
, _("Server not synchronized"));
621 asprintf(&result_line
, "%s %s,", result_line
, _("Server has the LI_ALARM bit set"));
623 if(offset_result
== STATE_UNKNOWN
){
624 asprintf(&result_line
, "%s %s", result_line
, _("Offset unknown"));
625 asprintf(&perfdata_line
, "");
627 asprintf(&result_line
, "%s %s %.10g secs", result_line
, _("Offset"), offset
);
628 asprintf(&perfdata_line
, "%s", perfd_offset(offset
));
631 asprintf(&result_line
, "%s, jitter=%f", result_line
, jitter
);
632 asprintf(&perfdata_line
, "%s %s", perfdata_line
, perfd_jitter(jitter
));
635 asprintf(&result_line
, "%s, stratum=%i", result_line
, stratum
);
636 asprintf(&perfdata_line
, "%s %s", perfdata_line
, perfd_stratum(stratum
));
638 if (do_truechimers
) {
639 asprintf(&result_line
, "%s, truechimers=%i", result_line
, num_truechimers
);
640 asprintf(&perfdata_line
, "%s %s", perfdata_line
, perfd_truechimers(num_truechimers
));
642 printf("%s|%s\n", result_line
, perfdata_line
);
644 if(server_address
!=NULL
) free(server_address
);
650 void print_help(void){
651 print_revision(progname
, NP_VERSION
);
653 printf ("Copyright (c) 2006 Sean Finney\n");
654 printf (COPYRIGHT
, copyright
, email
);
656 printf ("%s\n", _("This plugin checks the selected ntp server"));
661 printf (UT_HELP_VRSN
);
662 printf (UT_EXTRA_OPTS
);
663 printf (UT_HOST_PORT
, 'p', "123");
664 printf (" %s\n", "-q, --quiet");
665 printf (" %s\n", _("Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized"));
666 printf (" %s\n", "-w, --warning=THRESHOLD");
667 printf (" %s\n", _("Offset to result in warning status (seconds)"));
668 printf (" %s\n", "-c, --critical=THRESHOLD");
669 printf (" %s\n", _("Offset to result in critical status (seconds)"));
670 printf (" %s\n", "-W, --swarn=THRESHOLD");
671 printf (" %s\n", _("Warning threshold for stratum"));
672 printf (" %s\n", "-C, --scrit=THRESHOLD");
673 printf (" %s\n", _("Critical threshold for stratum"));
674 printf (" %s\n", "-j, --jwarn=THRESHOLD");
675 printf (" %s\n", _("Warning threshold for jitter"));
676 printf (" %s\n", "-k, --jcrit=THRESHOLD");
677 printf (" %s\n", _("Critical threshold for jitter"));
678 printf (" %s\n", "-m, --twarn=THRESHOLD");
679 printf (" %s\n", _("Warning threshold for number of usable time sources (\"truechimers\")"));
680 printf (" %s\n", "-n, --tcrit=THRESHOLD");
681 printf (" %s\n", _("Critical threshold for number of usable time sources (\"truechimers\")"));
682 printf (UT_TIMEOUT
, DEFAULT_SOCKET_TIMEOUT
);
686 printf("%s\n", _("This plugin checks an NTP server independent of any commandline"));
687 printf("%s\n\n", _("programs or external libraries."));
689 printf("%s\n", _("Notes:"));
690 printf(" %s\n", _("Use this plugin to check the health of an NTP server. It supports"));
691 printf(" %s\n", _("checking the offset with the sync peer, the jitter and stratum. This"));
692 printf(" %s\n", _("plugin will not check the clock offset between the local host and NTP"));
693 printf(" %s\n", _("server; please use check_ntp_time for that purpose."));
695 printf(UT_THRESHOLDS_NOTES
);
698 printf("%s\n", _("Examples:"));
699 printf(" %s\n", _("Simple NTP server check:"));
700 printf(" %s\n", ("./check_ntp_peer -H ntpserv -w 0.5 -c 1"));
702 printf(" %s\n", _("Check jitter too, avoiding critical notifications if jitter isn't available"));
703 printf(" %s\n", _("(See Notes above for more details on thresholds formats):"));
704 printf(" %s\n", ("./check_ntp_peer -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200"));
706 printf(" %s\n", _("Only check the number of usable time sources (\"truechimers\"):"));
707 printf(" %s\n", ("./check_ntp_peer -H ntpserv -m :5 -n :3"));
709 printf(" %s\n", _("Check only stratum:"));
710 printf(" %s\n", ("./check_ntp_peer -H ntpserv -W 4 -C 6"));
718 printf ("%s\n", _("Usage:"));
719 printf(" %s -H <host> [-w <warn>] [-c <crit>] [-W <warn>] [-C <crit>]\n", progname
);
720 printf(" [-j <warn>] [-k <crit>] [-v verbose]\n");