aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_procs.c
diff options
context:
space:
mode:
authorGravatar Subhendu Ghosh <sghosh@users.sourceforge.net> 2002-06-19 03:09:10 +0000
committerGravatar Subhendu Ghosh <sghosh@users.sourceforge.net> 2002-06-19 03:09:10 +0000
commitd36016a7adf28424d7f4adaa50612c41f1937c3b (patch)
tree88114a06b6c22f5716e6495cd5533f050cca0011 /plugins/check_procs.c
parent0db01536cb9cd5717ccbaca005fd9a6236dd7a6b (diff)
downloadmonitoring-plugins-d36016a7adf28424d7f4adaa50612c41f1937c3b.tar.gz
fixes for using POSIX return codes
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@54 f882894a-f735-0410-b71e-b25c423dba1c
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 c66d33de..9a3dc015 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -145,18 +145,29 @@ main (int argc, char **argv)
/* If we get anything on STDERR, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
if (verbose)
- printf ("%s", input_buffer);
- result = max (result, STATE_WARNING);
+ printf ("STDERR: %s", input_buffer);
+ /*Cannot use max() any more as STATE_UNKNOWN is gt STATE_CRITICAL
+ result = max (result, STATE_WARNING); */
+ if ( !(result == STATE_CRITICAL) ) {
+ result = STATE_WARNING;
+ }
+ printf ("System call sent warnings to stderr\n");
}
- if (result > STATE_OK)
+
+/* if (result == STATE_UNKNOWN || result == STATE_WARNING)
printf ("System call sent warnings to stderr\n");
-
+*/
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process)) {
printf ("System call returned nonzero status\n");
- return max (result, STATE_WARNING);
+ if ( !(result == STATE_CRITICAL) ) {
+ return STATE_WARNING;
+ }
+ else {
+ return result ;
+ }
}
if (options == ALL)
@@ -164,7 +175,8 @@ main (int argc, char **argv)
if (found == 0) { /* no process lines parsed so return STATE_UNKNOWN */
printf ("Unable to read output\n");
- return max (result, STATE_UNKNOWN);
+
+ return result;
}
if (verbose && (options & STAT))
@@ -199,15 +211,30 @@ main (int argc, char **argv)
}
else if (wmax >= 0 && procs > wmax) {
printf (format, "WARNING", procs);
- return max (result, STATE_WARNING);
+ if ( !(result == STATE_CRITICAL) ) {
+ return STATE_WARNING;
+ }
+ else {
+ return result ;
+ }
+ /*return max (result, STATE_WARNING); */
}
else if (wmin >= 0 && procs < wmin) {
printf (format, "WARNING", procs);
- return max (result, STATE_WARNING);
+ if ( !(result == STATE_CRITICAL) ) {
+ return STATE_WARNING;
+ }
+ else {
+ return result ;
+ }
+ /*return max (result, STATE_WARNING); */
}
printf (format, "OK", procs);
- return max (result, STATE_OK);
+ if ( result == STATE_UNKNOWN ) {
+ result = STATE_OK;
+ }
+ return result;
}
/* process command-line arguments */