From ac999e40e8eeedf0b5d1b9ecc85b88a4036bd579 Mon Sep 17 00:00:00 2001 From: Jean-Claude Computing Date: Wed, 26 Feb 2014 17:33:40 +0100 Subject: [PATCH 1/2] check_dns: add warning and critical thresholds to perfdata --- plugins/check_dns.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/check_dns.c b/plugins/check_dns.c index eebe72cca..a2a92f410 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -242,7 +242,14 @@ main (int argc, char **argv) } printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time); printf (_(". %s returns %s"), query_address, address); - printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); + if ((time_thresholds->warning == NULL) || (time_thresholds->critical == NULL)) { + printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); + } else { + printf ("|%s\n", fperfdata ("time", elapsed_time, "s", + TRUE, time_thresholds->warning->end, + TRUE, time_thresholds->critical->end, + TRUE, 0, FALSE, 0)); + } } else if (result == STATE_WARNING) printf (_("DNS WARNING - %s\n"), From a0cb2849777f83bdcaaf4803ce142d9734275e4c Mon Sep 17 00:00:00 2001 From: abrist Date: Wed, 26 Feb 2014 12:08:59 -0500 Subject: [PATCH 2/2] check_dns.c Added a bit more logic to thresholds Added two if elses to cover when only one threshold is set. --- plugins/check_dns.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/check_dns.c b/plugins/check_dns.c index a2a92f410..31a953d70 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -242,14 +242,23 @@ main (int argc, char **argv) } printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time); printf (_(". %s returns %s"), query_address, address); - if ((time_thresholds->warning == NULL) || (time_thresholds->critical == NULL)) { - printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); - } else { + if ((time_thresholds->warning != NULL) && (time_thresholds->critical != NULL)) { printf ("|%s\n", fperfdata ("time", elapsed_time, "s", TRUE, time_thresholds->warning->end, TRUE, time_thresholds->critical->end, TRUE, 0, FALSE, 0)); - } + } else if ((time_thresholds->warning == NULL) && (time_thresholds->critical != NULL)) { + printf ("|%s\n", fperfdata ("time", elapsed_time, "s", + FALSE, 0, + TRUE, time_thresholds->critical->end, + TRUE, 0, FALSE, 0)); + } else if ((time_thresholds->warning != NULL) && (time_thresholds->critical == NULL)) { + printf ("|%s\n", fperfdata ("time", elapsed_time, "s", + TRUE, time_thresholds->warning->end, + FALSE, 0, + TRUE, 0, FALSE, 0)); + } else + printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); } else if (result == STATE_WARNING) printf (_("DNS WARNING - %s\n"),