summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_disk.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 2558f6d..f9a9a84 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -63,6 +63,7 @@ const char *options = "\
63#include "utils.h" 63#include "utils.h"
64#include <stdarg.h> 64#include <stdarg.h>
65#include "../lib/fsusage.h" 65#include "../lib/fsusage.h"
66#include "../lib/mountlist.h"
66 67
67/* If nonzero, show inode information. */ 68/* If nonzero, show inode information. */
68static int inode_format; 69static int inode_format;
@@ -146,6 +147,8 @@ int verbose = 0;
146int erronly = FALSE; 147int erronly = FALSE;
147int display_mntp = FALSE; 148int display_mntp = FALSE;
148 149
150/* Linked list of mounted filesystems. */
151static struct mount_entry *mount_list;
149 152
150int 153int
151main (int argc, char **argv) 154main (int argc, char **argv)
@@ -162,22 +165,32 @@ main (int argc, char **argv)
162 char mntp[MAX_INPUT_BUFFER]; 165 char mntp[MAX_INPUT_BUFFER];
163 char *output = ""; 166 char *output = "";
164 167
168 struct mount_entry *me;
165 struct fs_usage fsp; 169 struct fs_usage fsp;
166 char *disk; 170 char *disk;
167 171
168 if (process_arguments (argc, argv) != OK) 172 if (process_arguments (argc, argv) != OK)
169 usage ("Could not parse arguments\n"); 173 usage ("Could not parse arguments\n");
170 174
171 get_fs_usage (path, disk, &fsp); 175 mount_list = read_filesystem_list (0);
176
177 for (me = mount_list; me; me = me->me_next) {
178 get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
179 if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) {
180 usp = (fsp.fsu_blocks - fsp.fsu_bavail) * 100 / fsp.fsu_blocks;
181 disk_result = check_disk (usp, fsp.fsu_bavail);
182 result = max_state (disk_result, result);
183 asprintf (&output, "%s %llu of %llu kB (%2.0f%%) free (%d-byte blocks) on %s (%s) %d\n",
184 output,
185 fsp.fsu_bavail*fsp.fsu_blocksize/1024,
186 fsp.fsu_blocks*fsp.fsu_blocksize/1024,
187 (double)fsp.fsu_bavail*100/fsp.fsu_blocks,
188 fsp.fsu_blocksize,
189 me->me_mountdir,
190 me->me_type, usp);
191 }
192 }
172 193
173 usp = (fsp.fsu_blocks - fsp.fsu_bavail) / fsp.fsu_blocks;
174 disk_result = check_disk (usp, fsp.fsu_bavail);
175 result = disk_result;
176 asprintf (&output, "%llu of %llu kB (%2.0f%%) free (%d-byte blocks)",
177 fsp.fsu_bavail*fsp.fsu_blocksize/1024,
178 fsp.fsu_blocks*fsp.fsu_blocksize/1024,
179 (double)fsp.fsu_bavail*100/fsp.fsu_blocks,
180 fsp.fsu_blocksize);
181 194
182 terminate (result, "DISK %s %s\n", state_text (result), output); 195 terminate (result, "DISK %s %s\n", state_text (result), output);
183} 196}