diff options
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r-- | plugins/check_disk.c | 43 |
1 files changed, 5 insertions, 38 deletions
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) | |||
69 | char file_system[MAX_INPUT_BUFFER] = ""; | 69 | char file_system[MAX_INPUT_BUFFER] = ""; |
70 | char mntp[MAX_INPUT_BUFFER] = ""; | 70 | char mntp[MAX_INPUT_BUFFER] = ""; |
71 | char outbuf[MAX_INPUT_BUFFER] = ""; | 71 | char outbuf[MAX_INPUT_BUFFER] = ""; |
72 | char *output = NULL; | 72 | char *output = ""; |
73 | 73 | ||
74 | if (process_arguments (argc, argv) != OK) | 74 | if (process_arguments (argc, argv) != OK) |
75 | usage ("Could not parse arguments\n"); | 75 | usage ("Could not parse arguments\n"); |
@@ -100,48 +100,15 @@ main (int argc, char **argv) | |||
100 | &used_disk, &free_disk, &usp, &mntp) == 6 | 100 | &used_disk, &free_disk, &usp, &mntp) == 6 |
101 | || sscanf (input_buffer, "%s %*s %d %d %d %d%% %s", file_system, | 101 | || sscanf (input_buffer, "%s %*s %d %d %d %d%% %s", file_system, |
102 | &total_disk, &used_disk, &free_disk, &usp, &mntp) == 6) { | 102 | &total_disk, &used_disk, &free_disk, &usp, &mntp) == 6) { |
103 | 103 | asprintf (&output, "%s [%d kB (%d%%) free on %s]", output, free_disk, | |
104 | /* cannot use max now that STATE_UNKNOWN is greater than STATE_CRITICAL | 104 | 100 - usp, display_mntp ? mntp : file_system); |
105 | result = max (result, check_disk (usp, free_disk)); */ | 105 | result = max_state (result, check_disk (usp, free_disk)); |
106 | temp_result = check_disk (usp, free_disk) ; | ||
107 | |||
108 | |||
109 | if ( temp_result == STATE_CRITICAL ) { | ||
110 | result = STATE_CRITICAL; | ||
111 | } | ||
112 | else if (temp_result == STATE_WARNING) { | ||
113 | if ( !( result == STATE_CRITICAL) ) { | ||
114 | result = STATE_WARNING; | ||
115 | } | ||
116 | } | ||
117 | else if (temp_result == STATE_OK) { | ||
118 | if ( ! ( result == STATE_CRITICAL || result == STATE_WARNING) ){ | ||
119 | result = STATE_OK; | ||
120 | } | ||
121 | } | ||
122 | else if (temp_result == STATE_UNKNOWN) { | ||
123 | if ( ! ( result == STATE_CRITICAL || result == STATE_WARNING || result == STATE_OK) ){ | ||
124 | result = STATE_UNKNOWN; | ||
125 | } | ||
126 | } | ||
127 | else { | ||
128 | /* don't have a match with the return value from check_disk() */ | ||
129 | result = STATE_UNKNOWN; | ||
130 | } | ||
131 | |||
132 | |||
133 | |||
134 | len = | ||
135 | snprintf (outbuf, MAX_INPUT_BUFFER - 1, | ||
136 | " [%d kB (%d%%) free on %s]", free_disk, 100 - usp, | ||
137 | display_mntp ? mntp : file_system); | ||
138 | outbuf[len] = 0; | ||
139 | output = strscat (output, outbuf); | ||
140 | } | 106 | } |
141 | else { | 107 | else { |
142 | printf ("Unable to read output:\n%s\n%s\n", command_line, input_buffer); | 108 | printf ("Unable to read output:\n%s\n%s\n", command_line, input_buffer); |
143 | return result; | 109 | return result; |
144 | } | 110 | } |
111 | |||
145 | } | 112 | } |
146 | 113 | ||
147 | /* If we get anything on stderr, at least set warning */ | 114 | /* If we get anything on stderr, at least set warning */ |