summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.in38
-rw-r--r--plugins/check_disk.c61
2 files changed, 94 insertions, 5 deletions
diff --git a/configure.in b/configure.in
index fcd5c56b..8f7f4f9a 100644
--- a/configure.in
+++ b/configure.in
@@ -21,9 +21,38 @@ AC_PROG_INSTALL
21AC_SUBST(INSTALL) 21AC_SUBST(INSTALL)
22 22
23AC_PROG_CC 23AC_PROG_CC
24AC_PROG_CPP
25AC_PROG_GCC_TRADITIONAL
26AC_PROG_RANLIB
27AC_AIX
28AC_MINIX
29
24AC_PROG_MAKE_SET 30AC_PROG_MAKE_SET
25AC_PROG_AWK 31AC_PROG_AWK
26 32
33# Check for SunOS statfs brokenness wrt partitions 2GB and larger.
34# If <sys/vfs.h> exists and struct statfs has a member named f_spare,
35# enable the work-around code in fsusage.c.
36AC_MSG_CHECKING([for statfs that truncates block counts])
37AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
38[AC_TRY_COMPILE([
39#if !defined(sun) && !defined(__sun)
40choke -- this is a workaround for a Sun-specific problem
41#endif
42#include <sys/types.h>
43#include <sys/vfs.h>],
44[struct statfs t; long c = *(t.f_spare);],
45fu_cv_sys_truncating_statfs=yes,
46fu_cv_sys_truncating_statfs=no,
47)])
48if test $fu_cv_sys_truncating_statfs = yes; then
49 AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
50[ Define if the block counts reported by statfs may be truncated to 2GB
51 and the correct values may be stored in the f_spare array.
52 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
53 SunOS 4.1.1 seems not to be affected.)])
54fi
55
27saved_srcdir=$srcdir 56saved_srcdir=$srcdir
28srcdir=$srcdir/lib 57srcdir=$srcdir/lib
29test -f $srcdir/getloadavg.c \ 58test -f $srcdir/getloadavg.c \
@@ -447,6 +476,15 @@ AC_HEADER_TIME
447AC_HEADER_SYS_WAIT 476AC_HEADER_SYS_WAIT
448AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h unistd.h uio.h errno.h regex.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h) 477AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h unistd.h uio.h errno.h regex.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h)
449AC_CHECK_HEADERS(stdarg.h sys/unistd.h unistd.h ctype.h stdlib.h) 478AC_CHECK_HEADERS(stdarg.h sys/unistd.h unistd.h ctype.h stdlib.h)
479AC_CHECK_HEADERS(sys/vfs.h,
480 [AC_TRY_COMPILE([#include <sys/vfs.h>],
481 [struct statfs *buf],
482 [AC_DEFINE(HAVE_STRUCT_STATFS,1,[Define if statfs struct can be found])])])
483AC_CHECK_HEADERS(sys/param.h sys/mount.h,
484 [AC_TRY_COMPILE([#include <sys/param.h>
485#include <sys/mount.h>],
486 [struct statfs *buf],
487 [AC_DEFINE(HAVE_STRUCT_STATFS,1,[Define if statfs struct can be found])])])
450 488
451dnl Checks for typedefs, structures, and compiler characteristics. 489dnl Checks for typedefs, structures, and compiler characteristics.
452AC_C_CONST 490AC_C_CONST
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 9421d060..1afc7620 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -36,6 +36,14 @@
36#include "utils.h" 36#include "utils.h"
37#include <stdarg.h> 37#include <stdarg.h>
38 38
39#ifdef _AIX
40 #pragma alloca
41#endif
42
43#if HAVE_INTTYPES_H
44# include <inttypes.h>
45#endif
46
39#define REVISION "$Revision$" 47#define REVISION "$Revision$"
40#define COPYRIGHT "2000-2002" 48#define COPYRIGHT "2000-2002"
41 49
@@ -73,9 +81,52 @@ main (int argc, char **argv)
73 char mntp[MAX_INPUT_BUFFER]; 81 char mntp[MAX_INPUT_BUFFER];
74 char *output = ""; 82 char *output = "";
75 83
84#ifdef HAVE_STRUCT_STATFS
85#ifdef HAVE_SYS_VFS_H
86#include <sys/vfs.h>
87#else
88#include <sys/param.h>
89#include <sys/mount.h>
90#endif
91 struct statfs buf;
92#endif
93
76 if (process_arguments (argc, argv) != OK) 94 if (process_arguments (argc, argv) != OK)
77 usage ("Could not parse arguments\n"); 95 usage ("Could not parse arguments\n");
78 96
97#ifdef HAVE_STRUCT_STATFS
98
99 if (statfs (path, &buf) == -1) {
100 switch (errno)
101 {
102 case ENOTDIR:
103 terminate (STATE_UNKNOWN, "A component of the path prefix is not a directory.\n");
104 case ENAMETOOLONG:
105 terminate (STATE_UNKNOWN, "path is too long.\n");
106 case ENOENT:
107 terminate (STATE_UNKNOWN, "The file referred to by path does not exist.\n");
108 case EACCES:
109 terminate (STATE_UNKNOWN, "Search permission is denied for a component of the path prefix of path.\n");
110 case ELOOP:
111 terminate (STATE_UNKNOWN, "Too many symbolic links were encountered in translating path.\n");
112 case EFAULT:
113 terminate (STATE_UNKNOWN, "Buf or path points to an invalid address.\n");
114 case EIO:
115 terminate (STATE_UNKNOWN, "An I/O error occurred while reading from or writing to the file system.\n");
116 case ENOMEM:
117 terminate (STATE_UNKNOWN, "Insufficient kernel memory was available.\n");
118 case ENOSYS:
119 terminate (STATE_UNKNOWN, "The filesystem path is on does not support statfs.\n");
120 }
121 }
122 usp = (buf.f_blocks - buf.f_bavail) / buf.f_blocks;
123 disk_result = check_disk (usp, buf.f_bavail);
124 result = disk_result;
125 asprintf (&output, "%ld of %ld kB free (%ld-byte blocks)",
126 buf.f_bavail*buf.f_bsize/1024, buf.f_blocks*buf.f_bsize/1024, buf.f_bsize);
127
128#else
129
79 asprintf (&command_line, "%s %s", DF_COMMAND, path); 130 asprintf (&command_line, "%s %s", DF_COMMAND, path);
80 131
81 if (verbose>0) 132 if (verbose>0)
@@ -151,13 +202,13 @@ main (int argc, char **argv)
151 result = STATE_WARNING; 202 result = STATE_WARNING;
152 203
153 if (usp < 0) 204 if (usp < 0)
154 printf ("Disk \"%s\" not mounted or nonexistant\n", path); 205 terminate (result, "Disk \"%s\" not mounted or nonexistant\n", path);
155 else if (result == STATE_UNKNOWN) 206 else if (result == STATE_UNKNOWN)
156 printf ("Unable to read output\n%s\n%s\n", command_line, input_buffer); 207 terminate (result, "Unable to read output\n%s\n%s\n", command_line, input_buffer);
157 else
158 printf ("DISK %s%s\n", state_text (result), output);
159 208
160 return result; 209#endif
210
211 terminate (result, "DISK %s %s\n", state_text (result), output);
161} 212}
162 213
163/* process command-line arguments */ 214/* process command-line arguments */