summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-11-20 11:28:50 +0000
committerKarl 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)
75 if (child_stderr == NULL) 75 if (child_stderr == NULL)
76 printf ("Could not open stderr for %s\n", command_line); 76 printf ("Could not open stderr for %s\n", command_line);
77 77
78 output = strscpy (output, "");
79
80 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 78 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
81 79
82 /* the server is responding, we just got the host name... */ 80 /* the server is responding, we just got the host name... */
@@ -111,7 +109,7 @@ main (int argc, char **argv)
111 /* If we get anything on STDERR, at least set warning */ 109 /* If we get anything on STDERR, at least set warning */
112 result = max_state (result, STATE_WARNING); 110 result = max_state (result, STATE_WARNING);
113 printf ("%s", input_buffer); 111 printf ("%s", input_buffer);
114 if (!strcmp (output, "")) 112 if (strlen (output) == 0)
115 strscpy (output, 1 + index (input_buffer, ':')); 113 strscpy (output, 1 + index (input_buffer, ':'));
116 } 114 }
117 115
@@ -120,27 +118,24 @@ main (int argc, char **argv)
120 /* close the pipe */ 118 /* close the pipe */
121 if (spclose (child_process)) { 119 if (spclose (child_process)) {
122 result = max_state (result, STATE_WARNING); 120 result = max_state (result, STATE_WARNING);
123 if (!strcmp (output, "")) 121 if (strlen (output) == 0)
124 strscpy (output, "nslookup returned error status"); 122 strscpy (output, "dig returned error status");
125 } 123 }
126 124
127 (void) time (&end_time); 125 (void) time (&end_time);
128 126
127 if (output == NULL || strcmp (output, "") == 0 || strlen (output) == 0 || strspn (output, " \t\r\n") == strlen (output))
128 strscpy (output, " Probably a non-existent host/domain");
129
129 if (result == STATE_OK) 130 if (result == STATE_OK)
130 printf ("DNS ok - %d seconds response time (%s)\n", 131 printf ("DNS ok - %d seconds response time (%s)\n",
131 (int) (end_time - start_time), output); 132 (int) (end_time - start_time), output);
132 else if (result == STATE_WARNING) 133 else if (result == STATE_WARNING)
133 printf ("DNS WARNING - %s\n", 134 printf ("DNS WARNING - %s\n", output);
134 !strcmp (output,
135 "") ? " Probably a non-existent host/domain" : output);
136 else if (result == STATE_CRITICAL) 135 else if (result == STATE_CRITICAL)
137 printf ("DNS CRITICAL - %s\n", 136 printf ("DNS CRITICAL - %s\n", output);
138 !strcmp (output,
139 "") ? " Probably a non-existent host/domain" : output);
140 else 137 else
141 printf ("DNS problem - %s\n", 138 printf ("DNS problem - %s\n", output);
142 !strcmp (output,
143 "") ? " Probably a non-existent host/domain" : output);
144 139
145 return result; 140 return result;
146} 141}