diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_ntp_time.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index 72dffbd8..d6cf4191 100644 --- a/plugins/check_ntp_time.c +++ b/plugins/check_ntp_time.c | |||
@@ -48,6 +48,7 @@ static int verbose=0; | |||
48 | static int quiet=0; | 48 | static int quiet=0; |
49 | static char *owarn="60"; | 49 | static char *owarn="60"; |
50 | static char *ocrit="120"; | 50 | static char *ocrit="120"; |
51 | static int time_offset=0; | ||
51 | 52 | ||
52 | int process_arguments (int, char **); | 53 | int process_arguments (int, char **); |
53 | thresholds *offset_thresholds = NULL; | 54 | thresholds *offset_thresholds = NULL; |
@@ -400,7 +401,7 @@ double offset_request(const char *host, int *status){ | |||
400 | gettimeofday(&recv_time, NULL); | 401 | gettimeofday(&recv_time, NULL); |
401 | DBG(print_ntp_message(&req[i])); | 402 | DBG(print_ntp_message(&req[i])); |
402 | respnum=servers[i].num_responses++; | 403 | respnum=servers[i].num_responses++; |
403 | servers[i].offset[respnum]=calc_offset(&req[i], &recv_time); | 404 | servers[i].offset[respnum]=calc_offset(&req[i], &recv_time)+time_offset; |
404 | if(verbose) { | 405 | if(verbose) { |
405 | printf("offset %.10g\n", servers[i].offset[respnum]); | 406 | printf("offset %.10g\n", servers[i].offset[respnum]); |
406 | } | 407 | } |
@@ -455,6 +456,7 @@ int process_arguments(int argc, char **argv){ | |||
455 | {"use-ipv4", no_argument, 0, '4'}, | 456 | {"use-ipv4", no_argument, 0, '4'}, |
456 | {"use-ipv6", no_argument, 0, '6'}, | 457 | {"use-ipv6", no_argument, 0, '6'}, |
457 | {"quiet", no_argument, 0, 'q'}, | 458 | {"quiet", no_argument, 0, 'q'}, |
459 | {"time-offset", optional_argument, 0, 'o'}, | ||
458 | {"warning", required_argument, 0, 'w'}, | 460 | {"warning", required_argument, 0, 'w'}, |
459 | {"critical", required_argument, 0, 'c'}, | 461 | {"critical", required_argument, 0, 'c'}, |
460 | {"timeout", required_argument, 0, 't'}, | 462 | {"timeout", required_argument, 0, 't'}, |
@@ -468,7 +470,7 @@ int process_arguments(int argc, char **argv){ | |||
468 | usage ("\n"); | 470 | usage ("\n"); |
469 | 471 | ||
470 | while (1) { | 472 | while (1) { |
471 | c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:", longopts, &option); | 473 | c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:o:", longopts, &option); |
472 | if (c == -1 || c == EOF || c == 1) | 474 | if (c == -1 || c == EOF || c == 1) |
473 | break; | 475 | break; |
474 | 476 | ||
@@ -504,6 +506,9 @@ int process_arguments(int argc, char **argv){ | |||
504 | case 't': | 506 | case 't': |
505 | socket_timeout=atoi(optarg); | 507 | socket_timeout=atoi(optarg); |
506 | break; | 508 | break; |
509 | case 'o': | ||
510 | time_offset=atoi(optarg); | ||
511 | break; | ||
507 | case '4': | 512 | case '4': |
508 | address_family = AF_INET; | 513 | address_family = AF_INET; |
509 | break; | 514 | break; |
@@ -616,6 +621,8 @@ void print_help(void){ | |||
616 | printf (" %s\n", _("Offset to result in warning status (seconds)")); | 621 | printf (" %s\n", _("Offset to result in warning status (seconds)")); |
617 | printf (" %s\n", "-c, --critical=THRESHOLD"); | 622 | printf (" %s\n", "-c, --critical=THRESHOLD"); |
618 | printf (" %s\n", _("Offset to result in critical status (seconds)")); | 623 | printf (" %s\n", _("Offset to result in critical status (seconds)")); |
624 | printf (" %s\n", "-o, --time_offset="); | ||
625 | printf (" %s\n", _("Expected offset of the ntp server relative to local server (seconds)")); | ||
619 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 626 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
620 | printf (UT_VERBOSE); | 627 | printf (UT_VERBOSE); |
621 | 628 | ||
@@ -642,6 +649,6 @@ void | |||
642 | print_usage(void) | 649 | print_usage(void) |
643 | { | 650 | { |
644 | printf ("%s\n", _("Usage:")); | 651 | printf ("%s\n", _("Usage:")); |
645 | printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose]\n", progname); | 652 | printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose] [-o <time offset>]\n", progname); |
646 | } | 653 | } |
647 | 654 | ||