From 52c1c4d859b8dc711b9353c5f6373426f3b05efc Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Mon, 18 Nov 2002 07:23:15 +0000 Subject: failed to handle multple disks git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@208 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/plugins/check_disk.c b/plugins/check_disk.c index bde9563..26d9ac9 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -69,7 +69,7 @@ main (int argc, char **argv) char file_system[MAX_INPUT_BUFFER] = ""; char mntp[MAX_INPUT_BUFFER] = ""; char outbuf[MAX_INPUT_BUFFER] = ""; - char *output = NULL; + char *output = ""; if (process_arguments (argc, argv) != OK) usage ("Could not parse arguments\n"); @@ -100,48 +100,15 @@ main (int argc, char **argv) &used_disk, &free_disk, &usp, &mntp) == 6 || sscanf (input_buffer, "%s %*s %d %d %d %d%% %s", file_system, &total_disk, &used_disk, &free_disk, &usp, &mntp) == 6) { - - /* 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, - display_mntp ? mntp : file_system); - outbuf[len] = 0; - output = strscat (output, outbuf); + asprintf (&output, "%s [%d kB (%d%%) free on %s]", output, free_disk, + 100 - usp, display_mntp ? mntp : file_system); + result = max_state (result, check_disk (usp, free_disk)); } else { printf ("Unable to read output:\n%s\n%s\n", command_line, input_buffer); return result; } + } /* If we get anything on stderr, at least set warning */ -- cgit v0.10-9-g596f