diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-12-04 12:08:34 +0000 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-12-04 12:08:34 +0000 |
commit | d358f1cc95a4c75b8ab443b9e5ce0c5b8b3c8d43 (patch) | |
tree | 0c4afa08b2c53c9fb782bb16f6a2f26e5073f44a /plugins/check_ntp_time.c | |
parent | 6157cdf6e514b23ee20e2bde67eb62757bcdd2f2 (diff) | |
download | monitoring-plugins-d358f1cc95a4c75b8ab443b9e5ce0c5b8b3c8d43.tar.gz |
Add a quiet mode to avoid notification when NTP server isn't sync (check_ntp_peer and heck_ntp_time)
Fix default jitter and stratum ranges not including -1
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/branches/dermoth_ntp_rework@1840 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ntp_time.c')
-rw-r--r-- | plugins/check_ntp_time.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index 85015d65..042d3037 100644 --- a/plugins/check_ntp_time.c +++ b/plugins/check_ntp_time.c | |||
@@ -51,6 +51,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
51 | 51 | ||
52 | static char *server_address=NULL; | 52 | static char *server_address=NULL; |
53 | static int verbose=0; | 53 | static int verbose=0; |
54 | static int quiet=0; | ||
54 | static char *owarn="60"; | 55 | static char *owarn="60"; |
55 | static char *ocrit="120"; | 56 | static char *ocrit="120"; |
56 | 57 | ||
@@ -450,6 +451,7 @@ int process_arguments(int argc, char **argv){ | |||
450 | {"verbose", no_argument, 0, 'v'}, | 451 | {"verbose", no_argument, 0, 'v'}, |
451 | {"use-ipv4", no_argument, 0, '4'}, | 452 | {"use-ipv4", no_argument, 0, '4'}, |
452 | {"use-ipv6", no_argument, 0, '6'}, | 453 | {"use-ipv6", no_argument, 0, '6'}, |
454 | {"quiet", no_argument, 0, 'q'}, | ||
453 | {"warning", required_argument, 0, 'w'}, | 455 | {"warning", required_argument, 0, 'w'}, |
454 | {"critical", required_argument, 0, 'c'}, | 456 | {"critical", required_argument, 0, 'c'}, |
455 | {"timeout", required_argument, 0, 't'}, | 457 | {"timeout", required_argument, 0, 't'}, |
@@ -462,7 +464,7 @@ int process_arguments(int argc, char **argv){ | |||
462 | usage ("\n"); | 464 | usage ("\n"); |
463 | 465 | ||
464 | while (1) { | 466 | while (1) { |
465 | c = getopt_long (argc, argv, "Vhv46w:c:t:H:", longopts, &option); | 467 | c = getopt_long (argc, argv, "Vhv46qw:c:t:H:", longopts, &option); |
466 | if (c == -1 || c == EOF || c == 1) | 468 | if (c == -1 || c == EOF || c == 1) |
467 | break; | 469 | break; |
468 | 470 | ||
@@ -478,6 +480,9 @@ int process_arguments(int argc, char **argv){ | |||
478 | case 'v': | 480 | case 'v': |
479 | verbose++; | 481 | verbose++; |
480 | break; | 482 | break; |
483 | case 'q': | ||
484 | quiet = 1; | ||
485 | break; | ||
481 | case 'w': | 486 | case 'w': |
482 | owarn = optarg; | 487 | owarn = optarg; |
483 | break; | 488 | break; |
@@ -544,7 +549,7 @@ int main(int argc, char *argv[]){ | |||
544 | 549 | ||
545 | offset = offset_request(server_address, &offset_result); | 550 | offset = offset_request(server_address, &offset_result); |
546 | if (offset_result == STATE_UNKNOWN) { | 551 | if (offset_result == STATE_UNKNOWN) { |
547 | result = STATE_CRITICAL; | 552 | result = (quiet == 1 ? STATE_UNKNOWN : STATE_CRITICAL); |
548 | } else { | 553 | } else { |
549 | result = get_status(fabs(offset), offset_thresholds); | 554 | result = get_status(fabs(offset), offset_thresholds); |
550 | } | 555 | } |
@@ -589,6 +594,8 @@ void print_help(void){ | |||
589 | print_usage(); | 594 | print_usage(); |
590 | printf (_(UT_HELP_VRSN)); | 595 | printf (_(UT_HELP_VRSN)); |
591 | printf (_(UT_HOST_PORT), 'p', "123"); | 596 | printf (_(UT_HOST_PORT), 'p', "123"); |
597 | printf (" %s\n", "-q, --quiet"); | ||
598 | printf (" %s\n", _("Returns UNKNOWN instead of CRITICAL if offset cannot be found")); | ||
592 | printf (" %s\n", "-w, --warning=THRESHOLD"); | 599 | printf (" %s\n", "-w, --warning=THRESHOLD"); |
593 | printf (" %s\n", _("Offset to result in warning status (seconds)")); | 600 | printf (" %s\n", _("Offset to result in warning status (seconds)")); |
594 | printf (" %s\n", "-c, --critical=THRESHOLD"); | 601 | printf (" %s\n", "-c, --critical=THRESHOLD"); |