summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2003-03-12 00:08:19 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2003-03-12 00:08:19 (GMT)
commit2eca952f2666244c4dd2c60735e6721134d0de14 (patch)
tree3b5335d386fa3b3d9bbbef5fe9d0c29a88cf4fa4 /plugins
parent8a43edbfb17094c641523427c440dcdc4ab3671a (diff)
downloadmonitoring-plugins-2eca952f2666244c4dd2c60735e6721134d0de14.tar.gz
Timings in milliseconds and nicer output
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@400 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dns.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 7c79893..fd798a6 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -75,6 +75,9 @@ main (int argc, char **argv)
75 char *address = NULL; 75 char *address = NULL;
76 char *temp_buffer = NULL; 76 char *temp_buffer = NULL;
77 int result = STATE_UNKNOWN; 77 int result = STATE_UNKNOWN;
78 double elapsed_time;
79 struct timeval tv;
80 int multi_address;
78 81
79 /* Set signal handling and alarm */ 82 /* Set signal handling and alarm */
80 if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { 83 if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
@@ -91,7 +94,7 @@ main (int argc, char **argv)
91 asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server); 94 asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server);
92 95
93 alarm (timeout_interval); 96 alarm (timeout_interval);
94 time (&start_time); 97 gettimeofday (&tv, NULL);
95 98
96 if (verbose) 99 if (verbose)
97 printf ("%s\n", command_line); 100 printf ("%s\n", command_line);
@@ -180,11 +183,17 @@ main (int argc, char **argv)
180 asprintf(&output, "expected %s but got %s", expected_address, address); 183 asprintf(&output, "expected %s but got %s", expected_address, address);
181 } 184 }
182 185
183 (void) time (&end_time); 186 elapsed_time = delta_time (tv);
184 187
185 if (result == STATE_OK) 188 if (result == STATE_OK) {
186 printf ("DNS ok - %d seconds response time, Address(es) is/are %s\n", 189 if (strchr (address, ',') == NULL)
187 (int) (end_time - start_time), address); 190 multi_address = FALSE;
191 else
192 multi_address = TRUE;
193
194 printf ("DNS ok - %-7.3f seconds response time, address%s %s|time=%-7.3f\n",
195 elapsed_time, (multi_address==TRUE ? "es are" : " is"), address, elapsed_time);
196 }
188 else if (result == STATE_WARNING) 197 else if (result == STATE_WARNING)
189 printf ("DNS WARNING - %s\n", 198 printf ("DNS WARNING - %s\n",
190 !strcmp (output, "") ? " Probably a non-existent host/domain" : output); 199 !strcmp (output, "") ? " Probably a non-existent host/domain" : output);