فهرست منبع

check_dns.c Added a bit more logic to thresholds

Added two if elses to cover when only one threshold is set.
abrist 12 سال پیش
والد
کامیت
086e8e1aa3
1فایلهای تغییر یافته به همراه13 افزوده شده و 4 حذف شده
  1. 13 4
      plugins/check_dns.c

+ 13 - 4
plugins/check_dns.c

@@ -322,14 +322,23 @@ main (int argc, char **argv)
     }
     }
     printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
     printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
     printf (_(". %s returns %s"), query_address, address);
     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",
       printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
                                   TRUE, time_thresholds->warning->end,
                                   TRUE, time_thresholds->warning->end,
                                   TRUE, time_thresholds->critical->end,
                                   TRUE, time_thresholds->critical->end,
                                   TRUE, 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",
+                                  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)
   else if (result == STATE_WARNING)
     printf (_("DNS WARNING - %s\n"),
     printf (_("DNS WARNING - %s\n"),