diff options
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r-- | plugins/check_disk.c | 43 |
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) | |||
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) |