[Nagiosplug-checkins] nagiosplug/plugins check_dns.c,1.50,1.51

Ton Voon tonvoon at users.sourceforge.net
Wed Mar 22 08:47:02 CET 2006


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7147

Modified Files:
	check_dns.c 
Log Message:
Added warning and critical response times (John Rouillard - 1343159)


Index: check_dns.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dns.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- check_dns.c	22 Mar 2006 14:17:10 -0000	1.50
+++ check_dns.c	22 Mar 2006 16:45:56 -0000	1.51
@@ -45,6 +45,7 @@
 char expected_address[ADDRESS_LENGTH] = "";
 int match_expected_address = FALSE;
 int expect_authority = FALSE;
+thresholds *time_thresholds = NULL;
 
 int
 main (int argc, char **argv)
@@ -183,7 +184,14 @@
     else
       multi_address = TRUE;
 
-    printf ("DNS %s: ", _("OK"));
+    result = get_status(elapsed_time, time_thresholds);
+    if (result == STATE_OK) {
+      printf ("DNS %s: ", _("OK"));
+    } else if (result == STATE_WARNING) {
+      printf ("DNS %s: ", _("WARNING"));
+    } else if (result == STATE_CRITICAL) {
+      printf ("DNS %s: ", _("CRITICAL"));
+    }
     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));
@@ -266,6 +274,8 @@
 process_arguments (int argc, char **argv)
 {
   int c;
+  char *warning = NULL;
+  char *critical = NULL;
 
   int opt_index = 0;
   static struct option long_opts[] = {
@@ -278,6 +288,8 @@
     {"reverse-server", required_argument, 0, 'r'},
     {"expected-address", required_argument, 0, 'a'},
     {"expect-authority", no_argument, 0, 'A'},
+    {"warning", no_argument, 0, 'w'},
+    {"critical", no_argument, 0, 'c'},
     {0, 0, 0, 0}
   };
 
@@ -289,7 +301,7 @@
       strcpy (argv[c], "-t");
 
   while (1) {
-    c = getopt_long (argc, argv, "hVvAt:H:s:r:a:", long_opts, &opt_index);
+    c = getopt_long (argc, argv, "hVvAt:H:s:r:a:w:c:", long_opts, &opt_index);
 
     if (c == -1 || c == EOF)
       break;
@@ -336,6 +348,12 @@
     case 'A': /* expect authority */
       expect_authority = TRUE;
       break;
+    case 'w':
+      warning = optarg;
+      break;
+    case 'c':
+      critical = optarg;
+      break;
     default: /* args not parsable */
       usage_va(_("Unknown argument - %s"), optarg);
     }
@@ -356,6 +374,8 @@
     strcpy (dns_server, argv[c++]);
   }
 
+  set_thresholds(&time_thresholds, warning, critical);
+
   return validate_arguments ();
 }
 
@@ -395,6 +415,10 @@
   printf ("    %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with ."));
   printf (" -A, --expect-authority\n");
   printf ("    %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
+  printf (" -w, --warning=seconds\n");
+  printf ("    %s\n", _("Return warning if elapsed time exceeds value. Default off"));
+  printf (" -c, --critical=seconds\n");
+  printf ("    %s\n", _("Return critical if elapsed time exceeds value. Default off"));
 
   printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
   printf (_(UT_SUPPORT));
@@ -406,5 +430,5 @@
 {
   printf (_("Usage:"));
   
-  printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout]\n", progname);
+  printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit]\n", progname);
 }





More information about the Commits mailing list