summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-11-21 12:40:58 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-11-21 12:40:58 (GMT)
commitcc6eb04be8d8c9d1707d858f8a7c85aed2156af0 (patch)
treea72eb0892767b307c14b7b30140a3695a5c18f5b /plugins
parent4b2e85d372262652cbd2cd37a701e7abddb3fa00 (diff)
downloadmonitoring-plugins-cc6eb04be8d8c9d1707d858f8a7c85aed2156af0.tar.gz
fix empty output on errors
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@220 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dig.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 975986d..e4f8632 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -88,11 +88,11 @@ main (int argc, char **argv)
88 input_buffer[strcspn (input_buffer, "\r\n")] = '\0'; 88 input_buffer[strcspn (input_buffer, "\r\n")] = '\0';
89 89
90 if (strstr (input_buffer, query_address) == input_buffer) { 90 if (strstr (input_buffer, query_address) == input_buffer) {
91 output = strscpy (output, input_buffer); 91 asprintf (&output, input_buffer);
92 result = STATE_OK; 92 result = STATE_OK;
93 } 93 }
94 else { 94 else {
95 strscpy (output, "Server not found in ANSWER SECTION"); 95 asprintf (&output, "Server not found in ANSWER SECTION");
96 result = STATE_WARNING; 96 result = STATE_WARNING;
97 } 97 }
98 98
@@ -102,7 +102,7 @@ main (int argc, char **argv)
102 } 102 }
103 103
104 if (result != STATE_OK) { 104 if (result != STATE_OK) {
105 strscpy (output, "No ANSWER SECTION found"); 105 asprintf (&output, "No ANSWER SECTION found");
106 } 106 }
107 107
108 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { 108 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
@@ -110,7 +110,7 @@ main (int argc, char **argv)
110 result = max_state (result, STATE_WARNING); 110 result = max_state (result, STATE_WARNING);
111 printf ("%s", input_buffer); 111 printf ("%s", input_buffer);
112 if (strlen (output) == 0) 112 if (strlen (output) == 0)
113 strscpy (output, 1 + index (input_buffer, ':')); 113 asprintf (&output, 1 + index (input_buffer, ':'));
114 } 114 }
115 115
116 (void) fclose (child_stderr); 116 (void) fclose (child_stderr);
@@ -119,13 +119,13 @@ main (int argc, char **argv)
119 if (spclose (child_process)) { 119 if (spclose (child_process)) {
120 result = max_state (result, STATE_WARNING); 120 result = max_state (result, STATE_WARNING);
121 if (strlen (output) == 0) 121 if (strlen (output) == 0)
122 strscpy (output, "dig returned error status"); 122 asprintf (&output, "dig returned error status");
123 } 123 }
124 124
125 (void) time (&end_time); 125 (void) time (&end_time);
126 126
127 if (output == NULL || strcmp (output, "") == 0 || strlen (output) == 0 || strspn (output, " \t\r\n") == strlen (output)) 127 if (output == NULL || strlen (output) == 0)
128 strscpy (output, " Probably a non-existent host/domain"); 128 asprintf (&output, " Probably a non-existent host/domain");
129 129
130 if (result == STATE_OK) 130 if (result == STATE_OK)
131 printf ("DNS ok - %d seconds response time (%s)\n", 131 printf ("DNS ok - %d seconds response time (%s)\n",
@@ -216,7 +216,7 @@ process_arguments (int argc, char **argv)
216 } 216 }
217 } 217 }
218 else { 218 else {
219 dns_server = strscpy (NULL, "127.0.0.1"); 219 asprintf (&dns_server, "127.0.0.1");
220 } 220 }
221 } 221 }
222 222