summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_disk.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 36f30a5..44b3286 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -142,14 +142,17 @@ main (int argc, char **argv)
142 char file_system[MAX_INPUT_BUFFER]; 142 char file_system[MAX_INPUT_BUFFER];
143 char *output; 143 char *output;
144 char *details; 144 char *details;
145 char *perf;
146 uintmax_t psize;
145 float free_space, free_space_pct, total_space; 147 float free_space, free_space_pct, total_space;
146 148
147 struct mount_entry *me; 149 struct mount_entry *me;
148 struct fs_usage fsp; 150 struct fs_usage fsp;
149 struct name_list *temp_list; 151 struct name_list *temp_list;
150 152
151 output = strdup (""); 153 output = strdup (" - free space:");
152 details = strdup (""); 154 details = strdup ("");
155 perf = strdup ("");
153 156
154 setlocale (LC_ALL, ""); 157 setlocale (LC_ALL, "");
155 bindtextdomain (PACKAGE, LOCALEDIR); 158 bindtextdomain (PACKAGE, LOCALEDIR);
@@ -185,6 +188,14 @@ main (int argc, char **argv)
185 usp = (double)(fsp.fsu_blocks - fsp.fsu_bavail) * 100 / fsp.fsu_blocks; 188 usp = (double)(fsp.fsu_blocks - fsp.fsu_bavail) * 100 / fsp.fsu_blocks;
186 disk_result = check_disk (usp, fsp.fsu_bavail); 189 disk_result = check_disk (usp, fsp.fsu_bavail);
187 result = max_state (disk_result, result); 190 result = max_state (disk_result, result);
191 psize = fsp.fsu_blocks*fsp.fsu_blocksize/mult;
192 asprintf (&perf, "%s %s", perf,
193 perfdata ((!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
194 fsp.fsu_bavail*fsp.fsu_blocksize/mult, units,
195 TRUE, min ((uintmax_t)psize-(uintmax_t)w_df, (uintmax_t)((1.0-w_dfp/100.0)*psize)),
196 TRUE, min ((uintmax_t)psize-(uintmax_t)c_df, (uintmax_t)((1.0-c_dfp/100.0)*psize)),
197 TRUE, 0,
198 TRUE, psize));
188 if (disk_result==STATE_OK && erronly && !verbose) 199 if (disk_result==STATE_OK && erronly && !verbose)
189 continue; 200 continue;
190 201
@@ -192,12 +203,12 @@ main (int argc, char **argv)
192 free_space_pct = (float)fsp.fsu_bavail*100/fsp.fsu_blocks; 203 free_space_pct = (float)fsp.fsu_bavail*100/fsp.fsu_blocks;
193 total_space = (float)fsp.fsu_blocks*fsp.fsu_blocksize/mult; 204 total_space = (float)fsp.fsu_blocks*fsp.fsu_blocksize/mult;
194 if (disk_result!=STATE_OK || verbose>=0) 205 if (disk_result!=STATE_OK || verbose>=0)
195 asprintf (&output, ("%s [%.0f %s (%.0f%%) free on %s]"), 206 asprintf (&output, ("%s %s %.0f %s (%.0f%%);"),
196 output, 207 output,
208 (!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
197 free_space, 209 free_space,
198 units, 210 units,
199 free_space_pct, 211 free_space_pct);
200 (!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
201 asprintf (&details, _("%s\n\ 212 asprintf (&details, _("%s\n\
202%.0f of %.0f %s (%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"), 213%.0f of %.0f %s (%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
203 details, free_space, total_space, units, free_space_pct, 214 details, free_space, total_space, units, free_space_pct,
@@ -207,6 +218,8 @@ main (int argc, char **argv)
207 218
208 } 219 }
209 220
221 asprintf (&output, "%s|%s", output, perf);
222
210 if (verbose > 2) 223 if (verbose > 2)
211 asprintf (&output, "%s%s", output, details); 224 asprintf (&output, "%s%s", output, details);
212 225
@@ -220,8 +233,8 @@ main (int argc, char **argv)
220 temp_list = temp_list->name_next; 233 temp_list = temp_list->name_next;
221 } 234 }
222 235
223 die (result, "DISK %s%s%s\n", state_text (result), output, details); 236 printf ("DISK %s%s\n", state_text (result), output);
224 return STATE_UNKNOWN; 237 return result;
225} 238}
226 239
227 240
@@ -507,11 +520,11 @@ check_disk (double usp, uintmax_t free_disk)
507{ 520{
508 int result = STATE_UNKNOWN; 521 int result = STATE_UNKNOWN;
509 /* check the percent used space against thresholds */ 522 /* check the percent used space against thresholds */
510 if (usp >= 0.0 && usp >= (100.0 - c_dfp)) 523 if (usp >= 0.0 && c_dfp >=0.0 && usp >= (100.0 - c_dfp))
511 result = STATE_CRITICAL; 524 result = STATE_CRITICAL;
512 else if (c_df > 0 && free_disk <= c_df) 525 else if (c_df > 0 && free_disk <= c_df)
513 result = STATE_CRITICAL; 526 result = STATE_CRITICAL;
514 else if (usp >= 0.0 && usp >= (100.0 - w_dfp)) 527 else if (usp >= 0.0 && w_dfp >=0.0 && usp >= (100.0 - w_dfp))
515 result = STATE_WARNING; 528 result = STATE_WARNING;
516 else if (w_df > 0 && free_disk <= w_df) 529 else if (w_df > 0 && free_disk <= w_df)
517 result = STATE_WARNING; 530 result = STATE_WARNING;