summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8a321be)
raw | patch | inline | side by side (parent: 8a321be)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Tue, 11 Mar 2003 06:44:22 +0000 (06:44 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Tue, 11 Mar 2003 06:44:22 +0000 (06:44 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@392 f882894a-f735-0410-b71e-b25c423dba1c
configure.in | patch | blob | history | |
plugins/check_disk.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index fcd5c56b935709f2acbbcf70d96c677900bb95bb..8f7f4f9a0ace410d472cbec31b17285073f70753 100644 (file)
--- a/configure.in
+++ b/configure.in
AC_SUBST(INSTALL)
AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_GCC_TRADITIONAL
+AC_PROG_RANLIB
+AC_AIX
+AC_MINIX
+
AC_PROG_MAKE_SET
AC_PROG_AWK
+# Check for SunOS statfs brokenness wrt partitions 2GB and larger.
+# If <sys/vfs.h> exists and struct statfs has a member named f_spare,
+# enable the work-around code in fsusage.c.
+AC_MSG_CHECKING([for statfs that truncates block counts])
+AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
+[AC_TRY_COMPILE([
+#if !defined(sun) && !defined(__sun)
+choke -- this is a workaround for a Sun-specific problem
+#endif
+#include <sys/types.h>
+#include <sys/vfs.h>],
+[struct statfs t; long c = *(t.f_spare);],
+fu_cv_sys_truncating_statfs=yes,
+fu_cv_sys_truncating_statfs=no,
+)])
+if test $fu_cv_sys_truncating_statfs = yes; then
+ AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
+[ Define if the block counts reported by statfs may be truncated to 2GB
+ and the correct values may be stored in the f_spare array.
+ (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
+ SunOS 4.1.1 seems not to be affected.)])
+fi
+
saved_srcdir=$srcdir
srcdir=$srcdir/lib
test -f $srcdir/getloadavg.c \
AC_HEADER_SYS_WAIT
AC_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)
AC_CHECK_HEADERS(stdarg.h sys/unistd.h unistd.h ctype.h stdlib.h)
+AC_CHECK_HEADERS(sys/vfs.h,
+ [AC_TRY_COMPILE([#include <sys/vfs.h>],
+ [struct statfs *buf],
+ [AC_DEFINE(HAVE_STRUCT_STATFS,1,[Define if statfs struct can be found])])])
+AC_CHECK_HEADERS(sys/param.h sys/mount.h,
+ [AC_TRY_COMPILE([#include <sys/param.h>
+#include <sys/mount.h>],
+ [struct statfs *buf],
+ [AC_DEFINE(HAVE_STRUCT_STATFS,1,[Define if statfs struct can be found])])])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 9421d06036c947c66a376bc9cc15bd8653549528..1afc76208763601786ee6c9d20f6e8543cd04348 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
#include "utils.h"
#include <stdarg.h>
+#ifdef _AIX
+ #pragma alloca
+#endif
+
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+
#define REVISION "$Revision$"
#define COPYRIGHT "2000-2002"
char mntp[MAX_INPUT_BUFFER];
char *output = "";
+#ifdef HAVE_STRUCT_STATFS
+#ifdef HAVE_SYS_VFS_H
+#include <sys/vfs.h>
+#else
+#include <sys/param.h>
+#include <sys/mount.h>
+#endif
+ struct statfs buf;
+#endif
+
if (process_arguments (argc, argv) != OK)
usage ("Could not parse arguments\n");
+#ifdef HAVE_STRUCT_STATFS
+
+ if (statfs (path, &buf) == -1) {
+ switch (errno)
+ {
+ case ENOTDIR:
+ terminate (STATE_UNKNOWN, "A component of the path prefix is not a directory.\n");
+ case ENAMETOOLONG:
+ terminate (STATE_UNKNOWN, "path is too long.\n");
+ case ENOENT:
+ terminate (STATE_UNKNOWN, "The file referred to by path does not exist.\n");
+ case EACCES:
+ terminate (STATE_UNKNOWN, "Search permission is denied for a component of the path prefix of path.\n");
+ case ELOOP:
+ terminate (STATE_UNKNOWN, "Too many symbolic links were encountered in translating path.\n");
+ case EFAULT:
+ terminate (STATE_UNKNOWN, "Buf or path points to an invalid address.\n");
+ case EIO:
+ terminate (STATE_UNKNOWN, "An I/O error occurred while reading from or writing to the file system.\n");
+ case ENOMEM:
+ terminate (STATE_UNKNOWN, "Insufficient kernel memory was available.\n");
+ case ENOSYS:
+ terminate (STATE_UNKNOWN, "The filesystem path is on does not support statfs.\n");
+ }
+ }
+ usp = (buf.f_blocks - buf.f_bavail) / buf.f_blocks;
+ disk_result = check_disk (usp, buf.f_bavail);
+ result = disk_result;
+ asprintf (&output, "%ld of %ld kB free (%ld-byte blocks)",
+ buf.f_bavail*buf.f_bsize/1024, buf.f_blocks*buf.f_bsize/1024, buf.f_bsize);
+
+#else
+
asprintf (&command_line, "%s %s", DF_COMMAND, path);
if (verbose>0)
result = STATE_WARNING;
if (usp < 0)
- printf ("Disk \"%s\" not mounted or nonexistant\n", path);
+ terminate (result, "Disk \"%s\" not mounted or nonexistant\n", path);
else if (result == STATE_UNKNOWN)
- printf ("Unable to read output\n%s\n%s\n", command_line, input_buffer);
- else
- printf ("DISK %s%s\n", state_text (result), output);
+ terminate (result, "Unable to read output\n%s\n%s\n", command_line, input_buffer);
- return result;
+#endif
+
+ terminate (result, "DISK %s %s\n", state_text (result), output);
}
/* process command-line arguments */