diff options
author | abrist <abrist@nagios.com> | 2014-02-14 20:04:37 (GMT) |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2014-07-20 21:34:41 (GMT) |
commit | 495cf3b2f8047815cc7de4f8238660f4609e97ca (patch) | |
tree | 3ae5ebc6ff57d21f18a74991a5771edfd8b2b77b /plugins | |
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.
Diffstat (limited to 'plugins')
-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 8dc1978..d3ae599 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c | |||
@@ -560,7 +560,7 @@ char *perfd_truechimers (int num_truechimers) | |||
560 | } | 560 | } |
561 | 561 | ||
562 | int main(int argc, char *argv[]){ | 562 | int main(int argc, char *argv[]){ |
563 | int result, offset_result, stratum, num_truechimers; | 563 | int result, offset_result, stratum, num_truechimers, oresult, jresult, sresult, tresult; |
564 | double offset=0, jitter=0; | 564 | double offset=0, jitter=0; |
565 | char *result_line, *perfdata_line; | 565 | char *result_line, *perfdata_line; |
566 | 566 | ||
@@ -597,15 +597,19 @@ int main(int argc, char *argv[]){ | |||
597 | result = STATE_UNKNOWN; | 597 | result = STATE_UNKNOWN; |
598 | result = max_state_alt(result, get_status(fabs(offset), offset_thresholds)); | 598 | result = max_state_alt(result, get_status(fabs(offset), offset_thresholds)); |
599 | } | 599 | } |
600 | 600 | oresult = result; | |
601 | |||
601 | if(do_truechimers) | 602 | if(do_truechimers) |
602 | result = max_state_alt(result, get_status(num_truechimers, truechimer_thresholds)); | 603 | tresult = get_status(num_truechimers, truechimer_thresholds); |
604 | result = max_state_alt(result, tresult); | ||
603 | 605 | ||
604 | if(do_stratum) | 606 | if(do_stratum) |
605 | result = max_state_alt(result, get_status(stratum, stratum_thresholds)); | 607 | sresult = get_status(stratum, stratum_thresholds); |
608 | result = max_state_alt(result, sresult); | ||
606 | 609 | ||
607 | if(do_jitter) | 610 | if(do_jitter) |
608 | result = max_state_alt(result, get_status(jitter, jitter_thresholds)); | 611 | jresult = get_status(jitter, jitter_thresholds); |
612 | result = max_state_alt(result, jresult); | ||
609 | 613 | ||
610 | switch (result) { | 614 | switch (result) { |
611 | case STATE_CRITICAL : | 615 | case STATE_CRITICAL : |
@@ -629,20 +633,43 @@ int main(int argc, char *argv[]){ | |||
629 | if(offset_result == STATE_UNKNOWN){ | 633 | if(offset_result == STATE_UNKNOWN){ |
630 | xasprintf(&result_line, "%s %s", result_line, _("Offset unknown")); | 634 | xasprintf(&result_line, "%s %s", result_line, _("Offset unknown")); |
631 | xasprintf(&perfdata_line, ""); | 635 | xasprintf(&perfdata_line, ""); |
636 | } else if (oresult == STATE_WARNING) { | ||
637 | xasprintf(&result_line, "%s %s %.10g secs (WARNING)", result_line, _("Offset"), offset); | ||
638 | } else if (oresult == STATE_CRITICAL) { | ||
639 | xasprintf(&result_line, "%s %s %.10g secs (CRITICAL)", result_line, _("Offset"), offset); | ||
632 | } else { | 640 | } else { |
633 | xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset); | 641 | xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset); |
634 | xasprintf(&perfdata_line, "%s", perfd_offset(offset)); | 642 | } |
635 | } | 643 | xasprintf(&perfdata_line, "%s", perfd_offset(offset)); |
644 | |||
636 | if (do_jitter) { | 645 | if (do_jitter) { |
637 | xasprintf(&result_line, "%s, jitter=%f", result_line, jitter); | 646 | if (jresult == STATE_WARNING) { |
647 | xasprintf(&result_line, "%s, jitter=%f (WARNING)", result_line, jitter); | ||
648 | } else if (jresult == STATE_CRITICAL) { | ||
649 | xasprintf(&result_line, "%s, jitter=%f (CRITICAL)", result_line, jitter); | ||
650 | } else { | ||
651 | xasprintf(&result_line, "%s, jitter=%f", result_line, jitter); | ||
652 | } | ||
638 | xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter)); | 653 | xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter)); |
639 | } | 654 | } |
640 | if (do_stratum) { | 655 | if (do_stratum) { |
641 | xasprintf(&result_line, "%s, stratum=%i", result_line, stratum); | 656 | if (sresult == STATE_WARNING) { |
657 | xasprintf(&result_line, "%s, stratum=%i (WARNING)", result_line, stratum); | ||
658 | } else if (sresult == STATE_CRITICAL) { | ||
659 | xasprintf(&result_line, "%s, stratum=%i (CRITICAL)", result_line, stratum); | ||
660 | } else { | ||
661 | xasprintf(&result_line, "%s, stratum=%i", result_line, stratum); | ||
662 | } | ||
642 | xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum)); | 663 | xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum)); |
643 | } | 664 | } |
644 | if (do_truechimers) { | 665 | if (do_truechimers) { |
645 | xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers); | 666 | if (tresult == STATE_WARNING) { |
667 | xasprintf(&result_line, "%s, truechimers=%i (WARNING)", result_line, num_truechimers); | ||
668 | } else if (tresult == STATE_CRITICAL) { | ||
669 | xasprintf(&result_line, "%s, truechimers=%i (CRITICAL)", result_line, num_truechimers); | ||
670 | } else { | ||
671 | xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers); | ||
672 | } | ||
646 | xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers)); | 673 | xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers)); |
647 | } | 674 | } |
648 | printf("%s|%s\n", result_line, perfdata_line); | 675 | printf("%s|%s\n", result_line, perfdata_line); |
@@ -651,8 +678,6 @@ int main(int argc, char *argv[]){ | |||
651 | return result; | 678 | return result; |
652 | } | 679 | } |
653 | 680 | ||
654 | |||
655 | |||
656 | void print_help(void){ | 681 | void print_help(void){ |
657 | print_revision(progname, NP_VERSION); | 682 | print_revision(progname, NP_VERSION); |
658 | 683 | ||