summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_disk.c43
-rw-r--r--plugins/check_ping.c30
-rw-r--r--plugins/check_procs.c45
3 files changed, 99 insertions, 19 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7429424..9ce4a32 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -62,6 +62,7 @@ main (int argc, char **argv)
62 int used_disk = -1; 62 int used_disk = -1;
63 int free_disk = -1; 63 int free_disk = -1;
64 int result = STATE_UNKNOWN; 64 int result = STATE_UNKNOWN;
65 int temp_result = STATE_UNKNOWN;
65 char *command_line = NULL; 66 char *command_line = NULL;
66 char input_buffer[MAX_INPUT_BUFFER] = ""; 67 char input_buffer[MAX_INPUT_BUFFER] = "";
67 char file_system[MAX_INPUT_BUFFER] = ""; 68 char file_system[MAX_INPUT_BUFFER] = "";
@@ -99,7 +100,36 @@ main (int argc, char **argv)
99 || sscanf (input_buffer, "%s %*s %d %d %d %d%% %s", file_system, 100 || sscanf (input_buffer, "%s %*s %d %d %d %d%% %s", file_system,
100 &total_disk, &used_disk, &free_disk, &usp, &mntp) == 6) { 101 &total_disk, &used_disk, &free_disk, &usp, &mntp) == 6) {
101 102
102 result = max (result, check_disk (usp, free_disk)); 103 /* cannot use max now that STATE_UNKNOWN is greater than STATE_CRITICAL
104 result = max (result, check_disk (usp, free_disk)); */
105 temp_result = check_disk (usp, free_disk) ;
106
107
108 if ( temp_result == STATE_CRITICAL ) {
109 result = STATE_CRITICAL;
110 }
111 else if (temp_result == STATE_WARNING) {
112 if ( !( result == STATE_CRITICAL) ) {
113 result = STATE_WARNING;
114 }
115 }
116 else if (temp_result == STATE_OK) {
117 if ( ! ( result == STATE_CRITICAL || result == STATE_WARNING) ){
118 result = STATE_OK;
119 }
120 }
121 else if (temp_result == STATE_UNKNOWN) {
122 if ( ! ( result == STATE_CRITICAL || result == STATE_WARNING || result == STATE_OK) ){
123 result = STATE_UNKNOWN;
124 }
125 }
126 else {
127 /* don't have a match with the return value from check_disk() */
128 result = STATE_UNKNOWN;
129 }
130
131
132
103 len = 133 len =
104 snprintf (outbuf, MAX_INPUT_BUFFER - 1, 134 snprintf (outbuf, MAX_INPUT_BUFFER - 1,
105 " [%d kB (%d%%) free on %s]", free_disk, 100 - usp, 135 " [%d kB (%d%%) free on %s]", free_disk, 100 - usp,
@@ -115,15 +145,20 @@ main (int argc, char **argv)
115 145
116 /* If we get anything on stderr, at least set warning */ 146 /* If we get anything on stderr, at least set warning */
117 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) 147 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
118 result = max (result, STATE_WARNING); 148 /*result = max (result, STATE_WARNING); */
149 if( !( result == STATE_CRITICAL) ) {
150 result = STATE_WARNING;
151 }
119 152
120 /* close stderr */ 153 /* close stderr */
121 (void) fclose (child_stderr); 154 (void) fclose (child_stderr);
122 155
123 /* close the pipe */ 156 /* close the pipe */
124 if (spclose (child_process)) 157 if (spclose (child_process))
125 result = max (result, STATE_WARNING); 158 /*result = max (result, STATE_WARNING); */
126 159 if( !( result == STATE_CRITICAL) ) {
160 result = STATE_WARNING;
161 }
127 if (usp < 0) 162 if (usp < 0)
128 printf ("Disk \"%s\" not mounted or nonexistant\n", path); 163 printf ("Disk \"%s\" not mounted or nonexistant\n", path);
129 else if (result == STATE_UNKNOWN) 164 else if (result == STATE_UNKNOWN)
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 5eada4f..420f148 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -121,8 +121,12 @@ main (int argc, char **argv)
121 else if (pl >= wpl || rta >= wrta) 121 else if (pl >= wpl || rta >= wrta)
122 result = STATE_WARNING; 122 result = STATE_WARNING;
123 else if (pl < wpl && rta < wrta && pl >= 0 && rta >= 0) 123 else if (pl < wpl && rta < wrta && pl >= 0 && rta >= 0)
124 result = max (result, STATE_OK); 124 /* cannot use the max function because STATE_UNKNOWN is now 3 gt STATE_OK
125 125 result = max (result, STATE_OK); */
126 if( !( (result == STATE_WARNING) || (result == STATE_CRITICAL) ) ) {
127 result = STATE_OK;
128 }
129
126 if (display_html == TRUE) 130 if (display_html == TRUE)
127 printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, server_address); 131 printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, server_address);
128 if (pl == 100) 132 if (pl == 100)
@@ -381,7 +385,12 @@ run_ping (char *command_line)
381 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 385 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
382 386
383 if (strstr (input_buffer, "(DUP!)")) { 387 if (strstr (input_buffer, "(DUP!)")) {
384 result = max (result, STATE_WARNING); 388 /* cannot use the max function since STATE_UNKNOWN is max
389 result = max (result, STATE_WARNING); */
390 if( !(result == STATE_CRITICAL) ){
391 result = STATE_WARNING;
392 }
393
385 warn_text = realloc (warn_text, strlen (WARN_DUPLICATES) + 1); 394 warn_text = realloc (warn_text, strlen (WARN_DUPLICATES) + 1);
386 if (warn_text == NULL) 395 if (warn_text == NULL)
387 terminate (STATE_UNKNOWN, "unable to realloc warn_text"); 396 terminate (STATE_UNKNOWN, "unable to realloc warn_text");
@@ -445,6 +454,9 @@ run_ping (char *command_line)
445 else if (strstr (input_buffer, "Destination Host Unreachable")) 454 else if (strstr (input_buffer, "Destination Host Unreachable"))
446 terminate (STATE_CRITICAL, "PING CRITICAL - Host Unreachable (%s)", 455 terminate (STATE_CRITICAL, "PING CRITICAL - Host Unreachable (%s)",
447 server_address); 456 server_address);
457 else if (strstr (input_buffer, "unknown host" ) )
458 terminate (STATE_CRITICAL, "PING CRITICAL - Host not found (%s)",
459 server_address);
448 460
449 warn_text = 461 warn_text =
450 realloc (warn_text, strlen (warn_text) + strlen (input_buffer) + 2); 462 realloc (warn_text, strlen (warn_text) + strlen (input_buffer) + 2);
@@ -456,9 +468,15 @@ run_ping (char *command_line)
456 sprintf (warn_text, "%s %s", warn_text, input_buffer); 468 sprintf (warn_text, "%s %s", warn_text, input_buffer);
457 469
458 if (strstr (input_buffer, "DUPLICATES FOUND")) 470 if (strstr (input_buffer, "DUPLICATES FOUND"))
459 result = max (result, STATE_WARNING); 471 /* cannot use the max function since STATE_UNKNOWN is max
472 result = max (result, STATE_WARNING); */
473 if( !(result == STATE_CRITICAL) ){
474 result = STATE_WARNING;
475 }
460 else 476 else
461 result = max (result, STATE_CRITICAL); 477 /* cannot use the max function since STATE_UNKNOWN is max
478 result = max (result, STATE_CRITICAL); */
479 result = STATE_CRITICAL ;
462 } 480 }
463 (void) fclose (child_stderr); 481 (void) fclose (child_stderr);
464 482
@@ -469,7 +487,7 @@ run_ping (char *command_line)
469 487
470 return result; 488 return result;
471} 489}
472 490
473 491
474void 492void
475print_usage (void) 493print_usage (void)
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index c66d33d..9a3dc01 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -145,18 +145,29 @@ main (int argc, char **argv)
145 /* If we get anything on STDERR, at least set warning */ 145 /* If we get anything on STDERR, at least set warning */
146 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { 146 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
147 if (verbose) 147 if (verbose)
148 printf ("%s", input_buffer); 148 printf ("STDERR: %s", input_buffer);
149 result = max (result, STATE_WARNING); 149 /*Cannot use max() any more as STATE_UNKNOWN is gt STATE_CRITICAL
150 result = max (result, STATE_WARNING); */
151 if ( !(result == STATE_CRITICAL) ) {
152 result = STATE_WARNING;
153 }
154 printf ("System call sent warnings to stderr\n");
150 } 155 }
151 if (result > STATE_OK) 156
157/* if (result == STATE_UNKNOWN || result == STATE_WARNING)
152 printf ("System call sent warnings to stderr\n"); 158 printf ("System call sent warnings to stderr\n");
153 159*/
154 (void) fclose (child_stderr); 160 (void) fclose (child_stderr);
155 161
156 /* close the pipe */ 162 /* close the pipe */
157 if (spclose (child_process)) { 163 if (spclose (child_process)) {
158 printf ("System call returned nonzero status\n"); 164 printf ("System call returned nonzero status\n");
159 return max (result, STATE_WARNING); 165 if ( !(result == STATE_CRITICAL) ) {
166 return STATE_WARNING;
167 }
168 else {
169 return result ;
170 }
160 } 171 }
161 172
162 if (options == ALL) 173 if (options == ALL)
@@ -164,7 +175,8 @@ main (int argc, char **argv)
164 175
165 if (found == 0) { /* no process lines parsed so return STATE_UNKNOWN */ 176 if (found == 0) { /* no process lines parsed so return STATE_UNKNOWN */
166 printf ("Unable to read output\n"); 177 printf ("Unable to read output\n");
167 return max (result, STATE_UNKNOWN); 178
179 return result;
168 } 180 }
169 181
170 if (verbose && (options & STAT)) 182 if (verbose && (options & STAT))
@@ -199,15 +211,30 @@ main (int argc, char **argv)
199 } 211 }
200 else if (wmax >= 0 && procs > wmax) { 212 else if (wmax >= 0 && procs > wmax) {
201 printf (format, "WARNING", procs); 213 printf (format, "WARNING", procs);
202 return max (result, STATE_WARNING); 214 if ( !(result == STATE_CRITICAL) ) {
215 return STATE_WARNING;
216 }
217 else {
218 return result ;
219 }
220 /*return max (result, STATE_WARNING); */
203 } 221 }
204 else if (wmin >= 0 && procs < wmin) { 222 else if (wmin >= 0 && procs < wmin) {
205 printf (format, "WARNING", procs); 223 printf (format, "WARNING", procs);
206 return max (result, STATE_WARNING); 224 if ( !(result == STATE_CRITICAL) ) {
225 return STATE_WARNING;
226 }
227 else {
228 return result ;
229 }
230 /*return max (result, STATE_WARNING); */
207 } 231 }
208 232
209 printf (format, "OK", procs); 233 printf (format, "OK", procs);
210 return max (result, STATE_OK); 234 if ( result == STATE_UNKNOWN ) {
235 result = STATE_OK;
236 }
237 return result;
211} 238}
212 239
213/* process command-line arguments */ 240/* process command-line arguments */