summaryrefslogtreecommitdiffstats
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 04d588f..925dfa8 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_disk plugin 3* Monitoring check_disk plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2008 Nagios Plugins Development Team 6* Copyright (c) 1999-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -29,7 +29,7 @@
29const char *progname = "check_disk"; 29const char *progname = "check_disk";
30const char *program_name = "check_disk"; /* Required for coreutils libs */ 30const char *program_name = "check_disk"; /* Required for coreutils libs */
31const char *copyright = "1999-2008"; 31const char *copyright = "1999-2008";
32const char *email = "nagiosplug-devel@lists.sourceforge.net"; 32const char *email = "devel@monitoring-plugins.org";
33 33
34 34
35#include "common.h" 35#include "common.h"
@@ -52,6 +52,11 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
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. */
57static int inode_format = 1; 62static 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 */
@@ -877,7 +892,7 @@ print_help (void)
877 printf (" %s\n", "-K, --icritical=PERCENT%"); 892 printf (" %s\n", "-K, --icritical=PERCENT%");
878 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of inode space is free")); 893 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of inode space is free"));
879 printf (" %s\n", "-p, --path=PATH, --partition=PARTITION"); 894 printf (" %s\n", "-p, --path=PATH, --partition=PARTITION");
880 printf (" %s\n", _("Path or partition (may be repeated)")); 895 printf (" %s\n", _("Mount point or block device as emitted by the mount(8) command (may be repeated)"));
881 printf (" %s\n", "-x, --exclude_device=PATH <STRING>"); 896 printf (" %s\n", "-x, --exclude_device=PATH <STRING>");
882 printf (" %s\n", _("Ignore device (only works if -p unspecified)")); 897 printf (" %s\n", _("Ignore device (only works if -p unspecified)"));
883 printf (" %s\n", "-C, --clear"); 898 printf (" %s\n", "-C, --clear");
@@ -911,7 +926,7 @@ print_help (void)
911 printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)")); 926 printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)"));
912 printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION"); 927 printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION");
913 printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)")); 928 printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)"));
914 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 929 printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
915 printf (" %s\n", "-u, --units=STRING"); 930 printf (" %s\n", "-u, --units=STRING");
916 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); 931 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
917 printf (UT_VERBOSE); 932 printf (UT_VERBOSE);
@@ -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);