diff options
| author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-22 06:55:07 +0000 |
|---|---|---|
| committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-22 06:55:07 +0000 |
| commit | 8a9ec38fbb780d17241a52c5dd4853cccb800e45 (patch) | |
| tree | 198366a67bb34302b81ebb1655c1537055126c45 | |
| parent | 22bd672d19c378f1e6124ee18e64e5a88cf53739 (diff) | |
| download | monitoring-plugins-8a9ec38fbb780d17241a52c5dd4853cccb800e45.tar.gz | |
- add perf data for time
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@691 f882894a-f735-0410-b71e-b25c423dba1c
| -rw-r--r-- | plugins/check_dig.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index dc4f89ae..c70ad97c 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
| @@ -48,6 +48,8 @@ main (int argc, char **argv) | |||
| 48 | char input_buffer[MAX_INPUT_BUFFER]; | 48 | char input_buffer[MAX_INPUT_BUFFER]; |
| 49 | char *command_line; | 49 | char *command_line; |
| 50 | char *output; | 50 | char *output; |
| 51 | long microsec; | ||
| 52 | double elapsed_time; | ||
| 51 | int result = STATE_UNKNOWN; | 53 | int result = STATE_UNKNOWN; |
| 52 | 54 | ||
| 53 | output = strdup (""); | 55 | output = strdup (""); |
| @@ -68,10 +70,11 @@ main (int argc, char **argv) | |||
| 68 | PATH_TO_DIG, dns_server, server_port, query_address); | 70 | PATH_TO_DIG, dns_server, server_port, query_address); |
| 69 | 71 | ||
| 70 | alarm (timeout_interval); | 72 | alarm (timeout_interval); |
| 71 | time (&start_time); | 73 | gettimeofday (&tv, NULL); |
| 72 | 74 | ||
| 73 | if (verbose) | 75 | if (verbose) |
| 74 | printf ("%s\n", command_line); | 76 | printf ("%s\n", command_line); |
| 77 | |||
| 75 | /* run the command */ | 78 | /* run the command */ |
| 76 | child_process = spopen (command_line); | 79 | child_process = spopen (command_line); |
| 77 | if (child_process == NULL) { | 80 | if (child_process == NULL) { |
| @@ -130,20 +133,34 @@ main (int argc, char **argv) | |||
| 130 | asprintf (&output, _("dig returned error status")); | 133 | asprintf (&output, _("dig returned error status")); |
| 131 | } | 134 | } |
| 132 | 135 | ||
| 133 | (void) time (&end_time); | 136 | microsec = deltime (tv); |
| 137 | elapsed_time = (double)microsec / 1.0e6; | ||
| 134 | 138 | ||
| 135 | if (output == NULL || strlen (output) == 0) | 139 | if (output == NULL || strlen (output) == 0) |
| 136 | asprintf (&output, _(" Probably a non-existent host/domain")); | 140 | asprintf (&output, _(" Probably a non-existent host/domain")); |
| 137 | 141 | ||
| 138 | if (result == STATE_OK) | 142 | if (elapsed_time > critical_interval) |
| 139 | printf (_("DNS OK - %d seconds response time (%s)\n"), | 143 | die (STATE_CRITICAL, |
| 140 | (int) (end_time - start_time), output); | 144 | _("DNS OK - %d seconds response time (%s)|time=%ldus\n"), |
| 141 | else if (result == STATE_WARNING) | 145 | elapsed_time, output, microsec); |
| 142 | printf (_("DNS WARNING - %s\n"), output); | 146 | |
| 143 | else if (result == STATE_CRITICAL) | 147 | else if (result == STATE_CRITICAL) |
| 144 | printf (_("DNS CRITICAL - %s\n"), output); | 148 | printf (_("DNS CRITICAL - %s|time=%ldus\n"), output); |
| 149 | |||
| 150 | else if (elapsed_time > warning_interval) | ||
| 151 | die (STATE_WARNING, | ||
| 152 | _("DNS OK - %d seconds response time (%s)|time=%ldus\n"), | ||
| 153 | elapsed_time, output, microsec); | ||
| 154 | |||
| 155 | else if (result == STATE_WARNING) | ||
| 156 | printf (_("DNS WARNING - %s|time=%ldus\n"), output); | ||
| 157 | |||
| 158 | else if (result == STATE_OK) | ||
| 159 | printf (_("DNS OK - %d seconds response time (%s)|time=%ldus\n"), | ||
| 160 | elapsed_time, output, microsec); | ||
| 161 | |||
| 145 | else | 162 | else |
| 146 | printf (_("DNS problem - %s\n"), output); | 163 | printf (_("DNS problem - %s|time=%ldus\n"), output); |
| 147 | 164 | ||
| 148 | return result; | 165 | return result; |
| 149 | } | 166 | } |
