summaryrefslogtreecommitdiffstats
path: root/plugins/check_procs.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_procs.c')
-rw-r--r--plugins/check_procs.c45
1 files changed, 36 insertions, 9 deletions
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 */