[monitoring-plugins] check_dns.c Added a bit more logic to thresholds

Sven Nierlein git at monitoring-plugins.org
Sat Jun 28 22:10:08 CEST 2014


    Module: monitoring-plugins
    Branch: master
    Commit: e49973493c4ede24f034dc8e54d988404795ae17
    Author: abrist <abrist at nagios.com>
 Committer: Sven Nierlein <sven at nierlein.de>
      Date: Wed Feb 26 12:08:59 2014 -0500
       URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=e499734

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 a2a92f4..31a953d 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"),



More information about the Commits mailing list