summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c25c672)
raw | patch | inline | side by side (parent: c25c672)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 19 Aug 2004 19:05:49 +0000 (19:05 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 19 Aug 2004 19:05:49 +0000 (19:05 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@890 f882894a-f735-0410-b71e-b25c423dba1c
configure.in | patch | blob | history | |
plugins/check_swap.c | patch | blob | history | |
plugins/common.h | patch | blob | history |
diff --git a/configure.in b/configure.in
index e207d95bcde5d3f5cc8e00d2c82855f60af04b32..3154af058ca1fb53683f3921e048ebd94a06ef22 100644 (file)
--- a/configure.in
+++ b/configure.in
AC_INIT(nagios-plugins,1.4.0alpha2)
AC_CONFIG_SRCDIR(Helper.pm)
AM_INIT_AUTOMAKE
-AC_CONFIG_HEADER(config.h)
+AM_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST
RELEASE=1
dnl end if for PATH_TO_SWAPCTL
fi
+dnl
+dnl test for swapctl system call, as found in tru64 and solaris
+dnl note: the way the ifdef logic in check_swap is right now,
+dnl this will only affect systems that don't pass one of the
+dnl earlier tests.
+dnl
+AC_CHECK_HEADERS([sys/swap.h sys/stat.h sys/param.h])
+AC_CHECK_DECLS([swapctl],,,[
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/swap.h>
+ ])
+dnl
+dnl end test for swapctl system call
+dnl
+
+
if test "x$ac_cv_have_swap" != "x"
then
AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 1155ed0ea44e9e76a61e9e3e64cdccea3daf2da2..f6bbd33508bea409e4d61923adb27d88859b621a 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
{
int percent_used, percent;
unsigned long long total_swap = 0, used_swap = 0, free_swap = 0;
- unsigned long long dsktotal, dskused, dskfree, tmp;
+ unsigned long long dsktotal = 0, dskused = 0, dskfree = 0, tmp = 0;
int result = STATE_OK;
char input_buffer[MAX_INPUT_BUFFER];
char *perf;
char *temp_buffer;
char *swap_command;
char *swap_format;
+# else
+# ifdef HAVE_DECL_SWAPCTL
+ int i=0, nswaps=0;
+ swaptbl_t tbl;
+# endif /* HAVE_DECL_SWAPCTL */
# endif
#endif
char str[32];
/* close the pipe */
if (spclose (child_process))
result = max_state (result, STATE_WARNING);
+# else
+# ifdef HAVE_DECL_SWAPCTL
+
+ /* initialize swap table entries */
+ memset(&tbl, 0, sizeof(swaptbl_t));
+ tbl.swt_ent[0].ste_path=(char*)malloc(sizeof(char)*(MAXPATHLEN+1));
+ memset(tbl.swt_ent[0].ste_path, 0, sizeof(char)*(MAXPATHLEN+1));
+ tbl.swt_n=1;
+
+ /* get the number of active swap devices */
+ nswaps=swapctl(SC_GETNSWP, NULL);
+
+ /* and now, tally 'em up */
+ for(i=0;i<nswaps;i++){
+ swapctl(SC_LIST, &tbl);
+ /* on tru64, swap is stored in 8k pages. i'd
+ use conv_factor or SWAP_CONVERSION, but they're
+ both buried under a bunch of ifdef's. ideally
+ all functions could call getpagesize(2)... */
+ dsktotal = tbl.swt_ent[0].ste_pages / 128;
+ dskfree = tbl.swt_ent[0].ste_free / 128;
+ dskused = ( total_swap - free_swap );
+
+ if(allswaps && dsktotal > 0){
+ percent = 100 * (((double) dskused) / ((double) dsktotal));
+ result = max_state (result, check_swap (percent, dskfree));
+ }
+
+ total_swap += dsktotal;
+ free_swap += dskfree;
+ used_swap += dskused;
+ }
+
+ /* and clean up after ourselves */
+ free(tbl.swt_ent[0].ste_path);
+
+# endif /* HAVE_DECL_SWAPCTL */
# endif /* HAVE_SWAP */
#endif /* HAVE_PROC_MEMINFO */
diff --git a/plugins/common.h b/plugins/common.h
index 3e892522f177c6d00b1a6f5bed3b561b1672520e..d878271e01c760059e9a552db813c653e745b4df 100644 (file)
--- a/plugins/common.h
+++ b/plugins/common.h
#include <locale.h>
#endif
+#ifdef HAVE_DECL_SWAPCTL
+# ifdef HAVE_SYS_SWAP_H
+# include <sys/swap.h>
+# endif
+# ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+# endif
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# endif
+#endif
+
/*
*
* Missing Functions