diff options
| author | Gunnar Beutner <gunnar@beutner.name> | 2014-04-21 22:49:51 +0200 |
|---|---|---|
| committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-04-27 19:59:06 +0200 |
| commit | 1b3890572ed5c19ce51634c1a071c0a24eb61ddf (patch) | |
| tree | 7ddf8d1a205be752f148acd6d92a25096c41a04d | |
| parent | 5e03bd8e8cf4ea41aef6cf5d7f115afa7565c861 (diff) | |
| download | monitoring-plugins-1b3890572ed5c19ce51634c1a071c0a24eb61ddf.tar.gz | |
Make check_disk work on Windows.
| -rw-r--r-- | plugins/check_disk.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index c12b5d98..925dfa82 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -52,6 +52,11 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 52 | #endif | 52 | #endif |
| 53 | #include "regex.h" | 53 | #include "regex.h" |
| 54 | 54 | ||
| 55 | #ifdef __CYGWIN__ | ||
| 56 | # include <windows.h> | ||
| 57 | # undef ERROR | ||
| 58 | # define ERROR -1 | ||
| 59 | #endif | ||
| 55 | 60 | ||
| 56 | /* If nonzero, show inode information. */ | 61 | /* If nonzero, show inode information. */ |
| 57 | static int inode_format = 1; | 62 | static int inode_format = 1; |
| @@ -175,6 +180,10 @@ main (int argc, char **argv) | |||
| 175 | struct fs_usage fsp, tmpfsp; | 180 | struct fs_usage fsp, tmpfsp; |
| 176 | struct parameter_list *temp_list, *path; | 181 | struct parameter_list *temp_list, *path; |
| 177 | 182 | ||
| 183 | #ifdef __CYGWIN__ | ||
| 184 | char mountdir[32]; | ||
| 185 | #endif | ||
| 186 | |||
| 178 | preamble = strdup (" - free space:"); | 187 | preamble = strdup (" - free space:"); |
| 179 | output = strdup (""); | 188 | output = strdup (""); |
| 180 | details = strdup (""); | 189 | details = strdup (""); |
| @@ -221,7 +230,6 @@ main (int argc, char **argv) | |||
| 221 | 230 | ||
| 222 | /* Process for every path in list */ | 231 | /* Process for every path in list */ |
| 223 | for (path = path_select_list; path; path=path->name_next) { | 232 | for (path = path_select_list; path; path=path->name_next) { |
| 224 | |||
| 225 | if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL) | 233 | if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL) |
| 226 | printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end, | 234 | printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end, |
| 227 | path->freespace_percent->critical->end); | 235 | path->freespace_percent->critical->end); |
| @@ -234,6 +242,13 @@ main (int argc, char **argv) | |||
| 234 | 242 | ||
| 235 | me = path->best_match; | 243 | me = path->best_match; |
| 236 | 244 | ||
| 245 | #ifdef __CYGWIN__ | ||
| 246 | if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11) | ||
| 247 | continue; | ||
| 248 | snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10); | ||
| 249 | if (GetDriveType(mountdir) != DRIVE_FIXED) | ||
| 250 | me->me_remote = 1; | ||
| 251 | #endif | ||
| 237 | /* Filters */ | 252 | /* Filters */ |
| 238 | 253 | ||
| 239 | /* Remove filesystems already seen */ | 254 | /* Remove filesystems already seen */ |
| @@ -970,6 +985,10 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) { | |||
| 970 | } else { | 985 | } else { |
| 971 | /* find all group members */ | 986 | /* find all group members */ |
| 972 | for (p_list = path_select_list; p_list; p_list=p_list->name_next) { | 987 | for (p_list = path_select_list; p_list; p_list=p_list->name_next) { |
| 988 | #ifdef __CYGWIN__ | ||
| 989 | if (strncmp(p_list->name, "/cygdrive/", 10) != 0) | ||
| 990 | continue; | ||
| 991 | #endif | ||
| 973 | if (p_list->group && ! (strcmp(p_list->group, p->group))) { | 992 | if (p_list->group && ! (strcmp(p_list->group, p->group))) { |
| 974 | stat_path(p_list); | 993 | stat_path(p_list); |
| 975 | get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); | 994 | get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); |
