*** nagios-plugins-1.4.6-orig/plugins/check_ntp.c 2007-01-28 16:46:40.000000000 -0500 --- nagios-plugins-1.4.6/plugins/check_ntp.c 2007-02-17 17:17:20.000000000 -0500 *************** static double ocrit=120; *** 53,58 **** --- 53,62 ---- static short do_jitter=0; static double jwarn=5000; static double jcrit=10000; + static short do_stratum=0; + static int swarn=4; + static int scrit=15; + static int max_stratum=0; int process_arguments (int, char **); void print_help (void); *************** double offset_request(const char *host, *** 447,452 **** --- 451,459 ---- if(verbose) { printf("offset %.10g\n", servers[i].offset[respnum]); } + if (req[i].stratum > max_stratum) { + max_stratum = req[i].stratum; + } servers[i].stratum=req[i].stratum; servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp); servers[i].rtdelay=NTP32asDOUBLE(req[i].rtdelay); *************** int process_arguments(int argc, char **a *** 631,636 **** --- 638,645 ---- {"zero-offset", no_argument, 0, 'O'}, {"jwarn", required_argument, 0, 'j'}, {"jcrit", required_argument, 0, 'k'}, + {"swarn", required_argument, 0, 's'}, + {"scrit", required_argument, 0, 'S'}, {"timeout", required_argument, 0, 't'}, {"hostname", required_argument, 0, 'H'}, {0, 0, 0, 0} *************** int process_arguments(int argc, char **a *** 641,647 **** usage ("\n"); while (1) { ! c = getopt_long (argc, argv, "Vhv46w:c:Oj:k:t:H:", longopts, &option); if (c == -1 || c == EOF || c == 1) break; --- 650,656 ---- usage ("\n"); while (1) { ! c = getopt_long (argc, argv, "Vhv46w:c:Oj:k:t:H:s:S:", longopts, &option); if (c == -1 || c == EOF || c == 1) break; *************** int process_arguments(int argc, char **a *** 671,676 **** --- 680,693 ---- do_jitter=1; jcrit = atof(optarg); break; + case 's': + do_stratum=1; + swarn = atoi(optarg); + break; + case 'S': + do_stratum=1; + scrit = atoi(optarg); + break; case 'H': if(is_host(optarg) == FALSE) usage2(_("Invalid hostname/address"), optarg); *************** int process_arguments(int argc, char **a *** 703,712 **** usage4(_("Critical offset should be larger than warning offset")); } ! if (ocrit < owarn){ usage4(_("Critical jitter should be larger than warning jitter")); } if(server_address == NULL){ usage4(_("Hostname was not supplied")); } --- 720,733 ---- usage4(_("Critical offset should be larger than warning offset")); } ! if (jcrit < jwarn){ usage4(_("Critical jitter should be larger than warning jitter")); } + if (scrit < swarn){ + usage4(_("Critical stratum should be larger than warning stratum")); + } + if(server_address == NULL){ usage4(_("Hostname was not supplied")); } *************** int main(int argc, char *argv[]){ *** 758,763 **** --- 779,792 ---- } result=max_state(result, jitter_result); + if(do_stratum){ + if (max_stratum >= scrit){ + result - max_state(result, STATE_CRITICAL); + } else if(max_stratum >= swarn) { + result = max_state(result, STATE_WARNING); + } + } + switch (result) { case STATE_CRITICAL : printf("NTP CRITICAL: "); *************** int main(int argc, char *argv[]){ *** 778,784 **** if(offset_result==STATE_WARNING){ printf("Unable to fully sample sync server. "); } ! printf("Offset %.10g secs|offset=%.10g", offset, offset); } if (do_jitter) printf(" jitter=%f", jitter); printf("\n"); --- 807,817 ---- if(offset_result==STATE_WARNING){ printf("Unable to fully sample sync server. "); } ! printf("Offset %.10g secs", offset); ! if (do_stratum) { ! printf(", max Stratum %d", max_stratum); ! } ! printf("|offset=%.10g", offset); } if (do_jitter) printf(" jitter=%f", jitter); printf("\n"); *************** void print_help(void){ *** 804,809 **** --- 837,846 ---- printf (_(UT_HOST_PORT), 'p', "123"); printf (_(UT_WARN_CRIT)); printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + printf (" -j, --jwarn=DOUBLE\n Jitter level to result in warning status\n"); + printf (" -k, --jcrit=DOUBLE\n Jitter level to result in critical status\n"); + printf (" -s, --swarn=INTEGER\n Stratum clock level to result in warning status\n"); + printf (" -S, --scrit=INTEGER\n Stratum clock level to result in critical status\n"); printf (_(UT_VERBOSE)); printf (_(UT_SUPPORT)); }