diff options
Diffstat (limited to 'web/attachments/344028-check_ntp_time.c.diff')
| -rw-r--r-- | web/attachments/344028-check_ntp_time.c.diff | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/web/attachments/344028-check_ntp_time.c.diff b/web/attachments/344028-check_ntp_time.c.diff new file mode 100644 index 0000000..bb07962 --- /dev/null +++ b/web/attachments/344028-check_ntp_time.c.diff | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | Index: check_ntp_time.c | ||
| 2 | =================================================================== | ||
| 3 | --- check_ntp_time.c (revision 2244) | ||
| 4 | +++ check_ntp_time.c (working copy) | ||
| 5 | @@ -48,6 +48,7 @@ | ||
| 6 | static int quiet=0; | ||
| 7 | static char *owarn="60"; | ||
| 8 | static char *ocrit="120"; | ||
| 9 | +static int time_offset=0; | ||
| 10 | |||
| 11 | int process_arguments (int, char **); | ||
| 12 | thresholds *offset_thresholds = NULL; | ||
| 13 | @@ -394,7 +395,7 @@ | ||
| 14 | gettimeofday(&recv_time, NULL); | ||
| 15 | DBG(print_ntp_message(&req[i])); | ||
| 16 | respnum=servers[i].num_responses++; | ||
| 17 | - servers[i].offset[respnum]=calc_offset(&req[i], &recv_time); | ||
| 18 | + servers[i].offset[respnum]=calc_offset(&req[i], &recv_time)+time_offset; | ||
| 19 | if(verbose) { | ||
| 20 | printf("offset %.10g\n", servers[i].offset[respnum]); | ||
| 21 | } | ||
| 22 | @@ -449,6 +450,7 @@ | ||
| 23 | {"use-ipv4", no_argument, 0, '4'}, | ||
| 24 | {"use-ipv6", no_argument, 0, '6'}, | ||
| 25 | {"quiet", no_argument, 0, 'q'}, | ||
| 26 | + {"time-offset", optional_argument, 0, 'o'}, | ||
| 27 | {"warning", required_argument, 0, 'w'}, | ||
| 28 | {"critical", required_argument, 0, 'c'}, | ||
| 29 | {"timeout", required_argument, 0, 't'}, | ||
| 30 | @@ -462,7 +464,7 @@ | ||
| 31 | usage ("\n"); | ||
| 32 | |||
| 33 | while (1) { | ||
| 34 | - c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:", longopts, &option); | ||
| 35 | + c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:o:", longopts, &option); | ||
| 36 | if (c == -1 || c == EOF || c == 1) | ||
| 37 | break; | ||
| 38 | |||
| 39 | @@ -498,6 +500,9 @@ | ||
| 40 | case 't': | ||
| 41 | socket_timeout=atoi(optarg); | ||
| 42 | break; | ||
| 43 | + case 'o': | ||
| 44 | + time_offset=atoi(optarg); | ||
| 45 | + break; | ||
| 46 | case '4': | ||
| 47 | address_family = AF_INET; | ||
| 48 | break; | ||
| 49 | @@ -609,6 +614,8 @@ | ||
| 50 | printf (" %s\n", _("Offset to result in warning status (seconds)")); | ||
| 51 | printf (" %s\n", "-c, --critical=THRESHOLD"); | ||
| 52 | printf (" %s\n", _("Offset to result in critical status (seconds)")); | ||
| 53 | + printf (" %s\n", "-o, --time_offset="); | ||
| 54 | + printf (" %s\n", _("Offset of the ntp server relative to local server(seconds)")); | ||
| 55 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
| 56 | printf (_(UT_VERBOSE)); | ||
| 57 | |||
| 58 | @@ -639,6 +646,6 @@ | ||
| 59 | print_usage(void) | ||
| 60 | { | ||
| 61 | printf (_("Usage:")); | ||
| 62 | - printf(" %s -H <host> [-w <warn>] [-c <crit>] [-v verbose]\n", progname); | ||
| 63 | + printf(" %s -H <host> [-w <warn>] [-c <crit>] [-v verbose] [-o <time offset>]\n", progname); | ||
| 64 | } | ||
| 65 | |||
