summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: caca7a5)
raw | patch | inline | side by side (parent: caca7a5)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Fri, 23 Nov 2007 04:21:09 +0000 (04:21 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Fri, 23 Nov 2007 04:21:09 +0000 (04:21 +0000) |
- Roll back the stratum check as there were issues with it and a better one is already implemented in check_ntp_peer (about to be included)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1830 f882894a-f735-0410-b71e-b25c423dba1c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1830 f882894a-f735-0410-b71e-b25c423dba1c
NEWS | patch | blob | history | |
plugins/check_ntp.c | patch | blob | history |
index 7a7ef8c01a48f55e25c1acd568048a4e2e02be1c..0c26c8259bf9c254b5888da52d0d6ca62dccc783 100644 (file)
--- a/NEWS
+++ b/NEWS
1.4.11 or 1.5 ??
Fix check_http regression in 1.4.10 where following redirects to
relative URLs on virtual hosts failed if both "-H" and "-I" were used
- Add stratum thresholds support to check_ntp (feature request #1703823)
check_ntp now return UNKNOWN instead of WARNING if jitter is unavailable (jitter=-1.000000)
as long as the thresholds range inculde -1. If no offset threshold is specified
and the offset is unavailable, will return UNKNOWN as well.
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 2854161687cbce9945b9d8e7a3f22a24ab15b390..38562ac90f88dc85553adb68678dddb753306468 100644 (file)
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
static short do_offset=0;
static char *owarn="60";
static char *ocrit="120";
-static short do_stratum=0;
-static char *swarn="16";
-static char *scrit="16";
static short do_jitter=0;
static char *jwarn="5000";
static char *jcrit="10000";
int process_arguments (int, char **);
thresholds *offset_thresholds = NULL;
thresholds *jitter_thresholds = NULL;
-thresholds *stratum_thresholds = NULL;
void print_help (void);
void print_usage (void);
* we don't waste time sitting around waiting for single packets.
* - we also "manually" handle resolving host names and connecting, because
* we have to do it in a way that our lazy macros don't handle currently :( */
-double offset_request(const char *host, int *stratum, int *status){
+double offset_request(const char *host, int *status){
int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
time_t now_time=0, start_ts=0;
respnum=servers[i].num_responses++;
servers[i].offset[respnum]=calc_offset(&req[i], &recv_time);
if(verbose) {
- printf("offset %.10g, stratum %i\n", servers[i].offset[respnum], req[i].stratum);
+ printf("offset %.10g\n", servers[i].offset[respnum]);
}
servers[i].stratum=req[i].stratum;
servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp);
avg_offset+=servers[best_index].offset[j];
}
avg_offset/=servers[best_index].num_responses;
- /* Stratum sent in normal packets is ingreased by 1 (i.e. stratum that
- * would be displayed if we were a server) so we decrease it */
- *stratum = servers[best_index].stratum - 1;
}
/* cleanup */
{"use-ipv6", no_argument, 0, '6'},
{"warning", required_argument, 0, 'w'},
{"critical", required_argument, 0, 'c'},
- {"swarn", required_argument, 0, 'W'},
- {"scrit", required_argument, 0, 'C'},
{"jwarn", required_argument, 0, 'j'},
{"jcrit", required_argument, 0, 'k'},
{"timeout", required_argument, 0, 't'},
usage ("\n");
while (1) {
- c = getopt_long (argc, argv, "Vhv46w:c:W:C:j:k:t:H:", longopts, &option);
+ c = getopt_long (argc, argv, "Vhv46w:c:j:k:t:H:", longopts, &option);
if (c == -1 || c == EOF || c == 1)
break;
do_offset=1;
ocrit = optarg;
break;
- case 'W':
- do_stratum=1;
- swarn = optarg;
- break;
- case 'C':
- do_stratum=1;
- scrit = optarg;
- break;
case 'j':
do_jitter=1;
jwarn = optarg;
TRUE, 0, FALSE, 0);
}
-char *perfd_stratum (int stratum)
-{
- return perfdata ("stratum", stratum, "",
- do_stratum, (int)stratum_thresholds->warning->end,
- do_stratum, (int)stratum_thresholds->critical->end,
- TRUE, 0, TRUE, 16);
-}
-
int main(int argc, char *argv[]){
- int result, offset_result, jitter_result, stratum;
+ int result, offset_result, jitter_result;
double offset=0, jitter=0;
char *result_line, *perfdata_line;
set_thresholds(&offset_thresholds, owarn, ocrit);
set_thresholds(&jitter_thresholds, jwarn, jcrit);
- set_thresholds(&stratum_thresholds, swarn, scrit);
/* initialize alarm signal handling */
signal (SIGALRM, socket_timeout_alarm_handler);
/* set socket timeout */
alarm (socket_timeout);
- offset = offset_request(server_address, &stratum, &offset_result);
+ offset = offset_request(server_address, &offset_result);
+ /* check_ntp used to always return if offset_result == STATE_UNKNOWN.
+ * Now we'll only do that is the offset thresholds were set */
if (do_offset && offset_result == STATE_UNKNOWN) {
result = STATE_CRITICAL;
} else {
result = get_status(fabs(offset), offset_thresholds);
}
- result = max_state(result, offset_result);
- if(do_stratum)
- result = max_state(result, get_status(stratum, stratum_thresholds));
/* If not told to check the jitter, we don't even send packets.
* jitter is checked using NTP control packets, which not all
*/
if(do_jitter){
jitter=jitter_request(server_address, &jitter_result);
- result = max_state(result, get_status(jitter, jitter_thresholds));
+ result = max_state_alt(result, get_status(jitter, jitter_thresholds));
/* -1 indicates that we couldn't calculate the jitter
* Only overrides STATE_OK from the offset */
if(jitter == -1.0 && result == STATE_OK)
result = STATE_UNKNOWN;
}
- result = max_state(result, jitter_result);
+ result = max_state_alt(result, jitter_result);
switch (result) {
case STATE_CRITICAL :
asprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
asprintf(&perfdata_line, "");
} else {
-#if 0 /* 2007-10-25 This can't happen. Leftovers or uninplemented? */
- if(offset_result==STATE_WARNING){
- asprintf(&result_line, "%s %s", result_line, _("Unable to fully sample sync server"));
- }
-#endif
asprintf(&result_line, "%s Offset %.10g secs", result_line, offset);
asprintf(&perfdata_line, "%s", perfd_offset(offset));
}
asprintf(&result_line, "%s, jitter=%f", result_line, jitter);
asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
}
- if (do_stratum) {
- asprintf(&result_line, "%s, stratum=%i", result_line, stratum);
- asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
- }
printf("%s|%s\n", result_line, perfdata_line);
if(server_address!=NULL) free(server_address);
printf (" %s\n", _("Offset to result in warning status (seconds)"));
printf (" %s\n", "-c, --critical=THRESHOLD");
printf (" %s\n", _("Offset to result in critical status (seconds)"));
- printf (" %s\n", "-W, --warning=THRESHOLD");
- printf (" %s\n", _("Warning threshold for stratum"));
- printf (" %s\n", "-W, --critical=THRESHOLD");
- printf (" %s\n", _("Critical threshold for stratum"));
printf (" %s\n", "-j, --warning=THRESHOLD");
printf (" %s\n", _("Warning threshold for jitter"));
printf (" %s\n", "-k, --critical=THRESHOLD");
printf(" %s\n", _("Check jitter too, avoiding critical notifications if jitter isn't available"));
printf(" %s\n", _("(See Notes above for more details on thresholds formats):"));
printf(" %s\n", ("./check_ntp -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200"));
- printf(" %s\n", _("Check only stratum:"));
- printf(" %s\n", ("./check_ntp -H ntpserv -W 4 -C 6"));
printf (_(UT_SUPPORT));
}
print_usage(void)
{
printf (_("Usage:"));
- printf(" %s -H <host> [-w <warn>] [-c <crit>] [-W <warn>] [-C <crit>]\n", progname);
- printf(" [-j <warn>] [-k <crit>] [-v verbose]\n");
+ printf(" %s -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n", progname);
}