aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_disk.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_disk.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_disk.c')
-rw-r--r--plugins/check_disk.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 74294249..9ce4a324 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -62,6 +62,7 @@ main (int argc, char **argv)
int used_disk = -1;
int free_disk = -1;
int result = STATE_UNKNOWN;
+ int temp_result = STATE_UNKNOWN;
char *command_line = NULL;
char input_buffer[MAX_INPUT_BUFFER] = "";
char file_system[MAX_INPUT_BUFFER] = "";
@@ -99,7 +100,36 @@ main (int argc, char **argv)
|| sscanf (input_buffer, "%s %*s %d %d %d %d%% %s", file_system,
&total_disk, &used_disk, &free_disk, &usp, &mntp) == 6) {
- result = max (result, check_disk (usp, free_disk));
+ /* cannot use max now that STATE_UNKNOWN is greater than STATE_CRITICAL
+ result = max (result, check_disk (usp, free_disk)); */
+ temp_result = check_disk (usp, free_disk) ;
+
+
+ if ( temp_result == STATE_CRITICAL ) {
+ result = STATE_CRITICAL;
+ }
+ else if (temp_result == STATE_WARNING) {
+ if ( !( result == STATE_CRITICAL) ) {
+ result = STATE_WARNING;
+ }
+ }
+ else if (temp_result == STATE_OK) {
+ if ( ! ( result == STATE_CRITICAL || result == STATE_WARNING) ){
+ result = STATE_OK;
+ }
+ }
+ else if (temp_result == STATE_UNKNOWN) {
+ if ( ! ( result == STATE_CRITICAL || result == STATE_WARNING || result == STATE_OK) ){
+ result = STATE_UNKNOWN;
+ }
+ }
+ else {
+ /* don't have a match with the return value from check_disk() */
+ result = STATE_UNKNOWN;
+ }
+
+
+
len =
snprintf (outbuf, MAX_INPUT_BUFFER - 1,
" [%d kB (%d%%) free on %s]", free_disk, 100 - usp,
@@ -115,15 +145,20 @@ 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))
- result = max (result, STATE_WARNING);
+ /*result = max (result, STATE_WARNING); */
+ if( !( result == STATE_CRITICAL) ) {
+ result = STATE_WARNING;
+ }
/* close stderr */
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- result = max (result, STATE_WARNING);
-
+ /*result = max (result, STATE_WARNING); */
+ if( !( result == STATE_CRITICAL) ) {
+ result = STATE_WARNING;
+ }
if (usp < 0)
printf ("Disk \"%s\" not mounted or nonexistant\n", path);
else if (result == STATE_UNKNOWN)