aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-11-20 11:28:50 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-11-20 11:28:50 +0000
commit6692168ec07fb87907aaccc66b644e105e6d5754 (patch)
treed976450287cd35040bfca7981ceb378025e42ac0 /plugins
parent5c3629009461cc14b5fe4fda58691330fddf3c02 (diff)
downloadmonitoring-plugins-6692168ec07fb87907aaccc66b644e105e6d5754.tar.gz
fix solaris SEGV, still need to print meaningful error text
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@218 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dig.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index ba9ff0df..975986da 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -75,8 +75,6 @@ main (int argc, char **argv)
if (child_stderr == NULL)
printf ("Could not open stderr for %s\n", command_line);
- output = strscpy (output, "");
-
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
/* the server is responding, we just got the host name... */
@@ -111,7 +109,7 @@ main (int argc, char **argv)
/* If we get anything on STDERR, at least set warning */
result = max_state (result, STATE_WARNING);
printf ("%s", input_buffer);
- if (!strcmp (output, ""))
+ if (strlen (output) == 0)
strscpy (output, 1 + index (input_buffer, ':'));
}
@@ -120,27 +118,24 @@ main (int argc, char **argv)
/* close the pipe */
if (spclose (child_process)) {
result = max_state (result, STATE_WARNING);
- if (!strcmp (output, ""))
- strscpy (output, "nslookup returned error status");
+ if (strlen (output) == 0)
+ strscpy (output, "dig returned error status");
}
(void) time (&end_time);
+ if (output == NULL || strcmp (output, "") == 0 || strlen (output) == 0 || strspn (output, " \t\r\n") == strlen (output))
+ strscpy (output, " Probably a non-existent host/domain");
+
if (result == STATE_OK)
printf ("DNS ok - %d seconds response time (%s)\n",
(int) (end_time - start_time), output);
else if (result == STATE_WARNING)
- printf ("DNS WARNING - %s\n",
- !strcmp (output,
- "") ? " Probably a non-existent host/domain" : output);
+ printf ("DNS WARNING - %s\n", output);
else if (result == STATE_CRITICAL)
- printf ("DNS CRITICAL - %s\n",
- !strcmp (output,
- "") ? " Probably a non-existent host/domain" : output);
+ printf ("DNS CRITICAL - %s\n", output);
else
- printf ("DNS problem - %s\n",
- !strcmp (output,
- "") ? " Probably a non-existent host/domain" : output);
+ printf ("DNS problem - %s\n", output);
return result;
}