diff options
author | abrist <abrist@nagios.com> | 2014-02-14 15:04:37 -0500 |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2014-07-20 23:34:41 +0200 |
commit | 495cf3b2f8047815cc7de4f8238660f4609e97ca (patch) | |
tree | 3ae5ebc6ff57d21f18a74991a5771edfd8b2b77b | |
parent | 50cad9ae5d958f045fcea927b41b52d24ff59b91 (diff) | |
download | monitoring-plugins-495cf3b2f8047815cc7de4f8238660f4609e97ca.tar.gz |
check_ntp_peer - Added specific state output for each metric. It now should be easy to see which check caused the alert.
-rw-r--r-- | plugins/check_ntp_peer.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index 8dc19788..d3ae5999 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c @@ -560,7 +560,7 @@ char *perfd_truechimers (int num_truechimers) } int main(int argc, char *argv[]){ - int result, offset_result, stratum, num_truechimers; + int result, offset_result, stratum, num_truechimers, oresult, jresult, sresult, tresult; double offset=0, jitter=0; char *result_line, *perfdata_line; @@ -597,15 +597,19 @@ int main(int argc, char *argv[]){ result = STATE_UNKNOWN; result = max_state_alt(result, get_status(fabs(offset), offset_thresholds)); } - + oresult = result; + if(do_truechimers) - result = max_state_alt(result, get_status(num_truechimers, truechimer_thresholds)); + tresult = get_status(num_truechimers, truechimer_thresholds); + result = max_state_alt(result, tresult); if(do_stratum) - result = max_state_alt(result, get_status(stratum, stratum_thresholds)); + sresult = get_status(stratum, stratum_thresholds); + result = max_state_alt(result, sresult); if(do_jitter) - result = max_state_alt(result, get_status(jitter, jitter_thresholds)); + jresult = get_status(jitter, jitter_thresholds); + result = max_state_alt(result, jresult); switch (result) { case STATE_CRITICAL : @@ -629,20 +633,43 @@ int main(int argc, char *argv[]){ if(offset_result == STATE_UNKNOWN){ xasprintf(&result_line, "%s %s", result_line, _("Offset unknown")); xasprintf(&perfdata_line, ""); + } else if (oresult == STATE_WARNING) { + xasprintf(&result_line, "%s %s %.10g secs (WARNING)", result_line, _("Offset"), offset); + } else if (oresult == STATE_CRITICAL) { + xasprintf(&result_line, "%s %s %.10g secs (CRITICAL)", result_line, _("Offset"), offset); } else { xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset); - xasprintf(&perfdata_line, "%s", perfd_offset(offset)); - } + } + xasprintf(&perfdata_line, "%s", perfd_offset(offset)); + if (do_jitter) { - xasprintf(&result_line, "%s, jitter=%f", result_line, jitter); + if (jresult == STATE_WARNING) { + xasprintf(&result_line, "%s, jitter=%f (WARNING)", result_line, jitter); + } else if (jresult == STATE_CRITICAL) { + xasprintf(&result_line, "%s, jitter=%f (CRITICAL)", result_line, jitter); + } else { + xasprintf(&result_line, "%s, jitter=%f", result_line, jitter); + } xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter)); } if (do_stratum) { - xasprintf(&result_line, "%s, stratum=%i", result_line, stratum); + if (sresult == STATE_WARNING) { + xasprintf(&result_line, "%s, stratum=%i (WARNING)", result_line, stratum); + } else if (sresult == STATE_CRITICAL) { + xasprintf(&result_line, "%s, stratum=%i (CRITICAL)", result_line, stratum); + } else { + xasprintf(&result_line, "%s, stratum=%i", result_line, stratum); + } xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum)); } if (do_truechimers) { - xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers); + if (tresult == STATE_WARNING) { + xasprintf(&result_line, "%s, truechimers=%i (WARNING)", result_line, num_truechimers); + } else if (tresult == STATE_CRITICAL) { + xasprintf(&result_line, "%s, truechimers=%i (CRITICAL)", result_line, num_truechimers); + } else { + xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers); + } xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers)); } printf("%s|%s\n", result_line, perfdata_line); @@ -651,8 +678,6 @@ int main(int argc, char *argv[]){ return result; } - - void print_help(void){ print_revision(progname, NP_VERSION); |