summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a0e099d)
raw | patch | inline | side by side (parent: a0e099d)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Wed, 17 Sep 2003 09:31:56 +0000 (09:31 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Wed, 17 Sep 2003 09:31:56 +0000 (09:31 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@734 f882894a-f735-0410-b71e-b25c423dba1c
configure.in | patch | blob | history | |
plugins/check_swap.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 09e8e3504227911c911f4832ef98633e04db630e..0999d7ebd485525424be55de03a42e0ee24e7e0f 100644 (file)
--- a/configure.in
+++ b/configure.in
dnl The plugin works through all the swap devices and adds up the total swap
dnl available.
AC_PATH_PROG(PATH_TO_SWAP,swap)
-AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
-
-dnl dunno why this does not work below - use hack (kbd)
-dnl fine on linux, broken on solaris
-dnl if /bin/test -e "/proc/meminfo"
-AC_MSG_CHECKING(for how to check memory)
-if [cat /proc/meminfo > /dev/null 2>&1]
-then
- AC_MSG_RESULT([found /proc/meminfo])
- AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
- AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
- EXTRAS="$EXTRAS check_swap"
-fi
-
-if ( test -n "$PATH_TO_SWAP" || test -n "$PATH_TO_SWAPINFO" )
+if (test -n "$PATH_TO_SWAP")
then
-
+AC_MSG_CHECKING([for $PATH_TO_SWAP format])
if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
then
ac_cv_have_swap=yes
fi
EXTRAS="$EXTRAS check_swap"
+fi
+dnl end if for PATH_TO_SWAP
+fi
-elif [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
+AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
+if (test -n "$PATH_TO_SWAPINFO")
+then
+AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
+if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
then
ac_cv_have_swap=yes
ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
ac_cv_swap_conv=1024
AC_MSG_RESULT([using HP-UX format swapinfo])
fi
+dnl end if for PATH_TO_SWAPINFO
+fi
+
+AC_PATH_PROG(PATH_TO_LSPS,lsps)
+if (test -n "$PATH_TO_LSPS")
+then
+AC_MSG_CHECKING([for $PATH_TO_LSPS format])
+if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
+then
+ ac_cv_have_swap=yes
+ ac_cv_swap_command="$PATH_TO_LSPS -a"
+ ac_cv_swap_format=["%*s %*s %*s %d%*s %d %*s"]
+ ac_cv_swap_conv=1
+ AC_MSG_RESULT([using AIX lsps])
+fi
+dnl end if for PATH_TO_SWAPINFO
+fi
if test "x$ac_cv_have_swap" != "x"
then
[Conversion factor to MB])
fi
-dnl End of if SWAP
-fi
+dnl dunno why this does not work below - use hack (kbd)
+dnl fine on linux, broken on solaris
+dnl if /bin/test -e "/proc/meminfo"
+AC_MSG_CHECKING([for /proc/meminfo])
+if [cat /proc/meminfo > /dev/null 2>&1]
+then
+ AC_MSG_RESULT([found /proc/meminfo])
+ AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
+ AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
+ EXTRAS="$EXTRAS check_swap"
+else
+ AC_MSG_RESULT([no])
+fi
AC_PATH_PROG(PATH_TO_DIG,dig)
AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 3a799c32ea47857e702acb72800b0edcfc06f355..2b71fd2106ec11f5e1bf0390019c372c18760b83 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
int verbose;
int allswaps;
-#if !defined(sun)
-int sun = 0; /* defined by compiler if it is a sun solaris system */
-#endif
-
int
main (int argc, char **argv)
{
fclose(fp);
#else
# ifdef HAVE_SWAP
- if (!allswaps && sun) {
+ if (!allswaps) {
+#ifdef _AIX
+ asprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
+ asprintf(&swap_format, "%s", "%d%*s %d");
+ conv_factor = 1;
+#else
+# ifdef sun
asprintf(&swap_command, "%s", "/usr/sbin/swap -s");
asprintf(&swap_format, "%s", "%*s %*dk %*s %*s + %*dk %*s = %dk %*s %dk %*s");
conv_factor = 2048;
+# endif
+#endif
} else {
asprintf(&swap_command, "%s", SWAP_COMMAND);
asprintf(&swap_format, "%s", SWAP_FORMAT);
}
}
- if (!allswaps && sun) {
+ if (!allswaps) {
+#ifdef _AIX
+ fgets(input_buffer, MAX_INPUT_BUFFER - 1, child_process); /* Ignore first line */
+ sscanf (input_buffer, swap_format, &total_swap, &used_swap);
+ free_swap = total_swap * (100 - used_swap) /100;
+ used_swap = total_swap - free_swap;
+ if (verbose >= 3)
+ printf (_("total=%d, used=%d, free=%d\n"), total_swap, used_swap, free_swap);
+#else
+# ifdef sun
sscanf (input_buffer, swap_format, &used_swap, &free_swap);
used_swap = used_swap / 1024;
free_swap = free_swap / 1024;
total_swap = used_swap + free_swap;
+# endif
+#endif
} else {
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
sscanf (input_buffer, swap_format, &dsktotal, &dskfree);
dsktotal = dsktotal / conv_factor;
+ /* AIX lists percent used, so this converts to dskfree in MBs */
+#ifdef _AIX
+ dskfree = dsktotal * (100 - dskfree) / 100;
+#else
dskfree = dskfree / conv_factor;
+#endif
if (verbose >= 3)
printf (_("total=%d, free=%d\n"), dsktotal, dskfree);
On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\
Will be discrepencies because swap -s counts allocated swap and includes\n\
real memory\n"));
+#endif
+#ifdef _AIX
+ printf (_("\n\
+On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n"));
#endif
printf (_(UT_SUPPORT));