summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2003-09-17 09:31:56 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2003-09-17 09:31:56 (GMT)
commit4fe50f4297fa4b34d28c2d39ab83e5d2db4e1193 (patch)
tree145b6f954fb99c75bc75df83c7477bd30b4b6aa6
parenta0e099de2bb62c6b48587d75b2601f605ff14aad (diff)
downloadmonitoring-plugins-4fe50f4297fa4b34d28c2d39ab83e5d2db4e1193.tar.gz
Support for check_swap in AIX (tested on 5.1)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@734 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--configure.in59
-rw-r--r--plugins/check_swap.c36
2 files changed, 70 insertions, 25 deletions
diff --git a/configure.in b/configure.in
index 09e8e35..0999d7e 100644
--- a/configure.in
+++ b/configure.in
@@ -1263,23 +1263,9 @@ dnl SWAP info required is amount allocated/available and amount free
1263dnl The plugin works through all the swap devices and adds up the total swap 1263dnl The plugin works through all the swap devices and adds up the total swap
1264dnl available. 1264dnl available.
1265AC_PATH_PROG(PATH_TO_SWAP,swap) 1265AC_PATH_PROG(PATH_TO_SWAP,swap)
1266AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo) 1266if (test -n "$PATH_TO_SWAP")
1267
1268dnl dunno why this does not work below - use hack (kbd)
1269dnl fine on linux, broken on solaris
1270dnl if /bin/test -e "/proc/meminfo"
1271AC_MSG_CHECKING(for how to check memory)
1272if [cat /proc/meminfo > /dev/null 2>&1]
1273then
1274 AC_MSG_RESULT([found /proc/meminfo])
1275 AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1276 AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1277 EXTRAS="$EXTRAS check_swap"
1278fi
1279
1280if ( test -n "$PATH_TO_SWAP" || test -n "$PATH_TO_SWAPINFO" )
1281then 1267then
1282 1268AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1283if [$PATH_TO_SWAP -l 2>&1 >/dev/null] 1269if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1284then 1270then
1285 ac_cv_have_swap=yes 1271 ac_cv_have_swap=yes
@@ -1306,8 +1292,15 @@ then
1306 1292
1307 fi 1293 fi
1308 EXTRAS="$EXTRAS check_swap" 1294 EXTRAS="$EXTRAS check_swap"
1295fi
1296dnl end if for PATH_TO_SWAP
1297fi
1309 1298
1310elif [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null] 1299AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1300if (test -n "$PATH_TO_SWAPINFO")
1301then
1302AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1303if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1311then 1304then
1312 ac_cv_have_swap=yes 1305 ac_cv_have_swap=yes
1313 ac_cv_swap_command="$PATH_TO_SWAPINFO -k" 1306 ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
@@ -1328,6 +1321,23 @@ then
1328 ac_cv_swap_conv=1024 1321 ac_cv_swap_conv=1024
1329 AC_MSG_RESULT([using HP-UX format swapinfo]) 1322 AC_MSG_RESULT([using HP-UX format swapinfo])
1330fi 1323fi
1324dnl end if for PATH_TO_SWAPINFO
1325fi
1326
1327AC_PATH_PROG(PATH_TO_LSPS,lsps)
1328if (test -n "$PATH_TO_LSPS")
1329then
1330AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1331if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1332then
1333 ac_cv_have_swap=yes
1334 ac_cv_swap_command="$PATH_TO_LSPS -a"
1335 ac_cv_swap_format=["%*s %*s %*s %d%*s %d %*s"]
1336 ac_cv_swap_conv=1
1337 AC_MSG_RESULT([using AIX lsps])
1338fi
1339dnl end if for PATH_TO_SWAPINFO
1340fi
1331 1341
1332if test "x$ac_cv_have_swap" != "x" 1342if test "x$ac_cv_have_swap" != "x"
1333then 1343then
@@ -1343,8 +1353,19 @@ then
1343 [Conversion factor to MB]) 1353 [Conversion factor to MB])
1344fi 1354fi
1345 1355
1346dnl End of if SWAP 1356dnl dunno why this does not work below - use hack (kbd)
1347fi 1357dnl fine on linux, broken on solaris
1358dnl if /bin/test -e "/proc/meminfo"
1359AC_MSG_CHECKING([for /proc/meminfo])
1360if [cat /proc/meminfo > /dev/null 2>&1]
1361then
1362 AC_MSG_RESULT([found /proc/meminfo])
1363 AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1364 AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1365 EXTRAS="$EXTRAS check_swap"
1366else
1367 AC_MSG_RESULT([no])
1368fi
1348 1369
1349AC_PATH_PROG(PATH_TO_DIG,dig) 1370AC_PATH_PROG(PATH_TO_DIG,dig)
1350AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present]) 1371AC_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 3a799c3..2b71fd2 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -47,10 +47,6 @@ long unsigned int crit_size = 0;
47int verbose; 47int verbose;
48int allswaps; 48int allswaps;
49 49
50#if !defined(sun)
51int sun = 0; /* defined by compiler if it is a sun solaris system */
52#endif
53
54int 50int
55main (int argc, char **argv) 51main (int argc, char **argv)
56{ 52{
@@ -103,10 +99,18 @@ main (int argc, char **argv)
103 fclose(fp); 99 fclose(fp);
104#else 100#else
105# ifdef HAVE_SWAP 101# ifdef HAVE_SWAP
106 if (!allswaps && sun) { 102 if (!allswaps) {
103#ifdef _AIX
104 asprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
105 asprintf(&swap_format, "%s", "%d%*s %d");
106 conv_factor = 1;
107#else
108# ifdef sun
107 asprintf(&swap_command, "%s", "/usr/sbin/swap -s"); 109 asprintf(&swap_command, "%s", "/usr/sbin/swap -s");
108 asprintf(&swap_format, "%s", "%*s %*dk %*s %*s + %*dk %*s = %dk %*s %dk %*s"); 110 asprintf(&swap_format, "%s", "%*s %*dk %*s %*s + %*dk %*s = %dk %*s %dk %*s");
109 conv_factor = 2048; 111 conv_factor = 2048;
112# endif
113#endif
110 } else { 114 } else {
111 asprintf(&swap_command, "%s", SWAP_COMMAND); 115 asprintf(&swap_command, "%s", SWAP_COMMAND);
112 asprintf(&swap_format, "%s", SWAP_FORMAT); 116 asprintf(&swap_format, "%s", SWAP_FORMAT);
@@ -144,17 +148,33 @@ main (int argc, char **argv)
144 } 148 }
145 } 149 }
146 150
147 if (!allswaps && sun) { 151 if (!allswaps) {
152#ifdef _AIX
153 fgets(input_buffer, MAX_INPUT_BUFFER - 1, child_process); /* Ignore first line */
154 sscanf (input_buffer, swap_format, &total_swap, &used_swap);
155 free_swap = total_swap * (100 - used_swap) /100;
156 used_swap = total_swap - free_swap;
157 if (verbose >= 3)
158 printf (_("total=%d, used=%d, free=%d\n"), total_swap, used_swap, free_swap);
159#else
160# ifdef sun
148 sscanf (input_buffer, swap_format, &used_swap, &free_swap); 161 sscanf (input_buffer, swap_format, &used_swap, &free_swap);
149 used_swap = used_swap / 1024; 162 used_swap = used_swap / 1024;
150 free_swap = free_swap / 1024; 163 free_swap = free_swap / 1024;
151 total_swap = used_swap + free_swap; 164 total_swap = used_swap + free_swap;
165# endif
166#endif
152 } else { 167 } else {
153 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 168 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
154 sscanf (input_buffer, swap_format, &dsktotal, &dskfree); 169 sscanf (input_buffer, swap_format, &dsktotal, &dskfree);
155 170
156 dsktotal = dsktotal / conv_factor; 171 dsktotal = dsktotal / conv_factor;
172 /* AIX lists percent used, so this converts to dskfree in MBs */
173#ifdef _AIX
174 dskfree = dsktotal * (100 - dskfree) / 100;
175#else
157 dskfree = dskfree / conv_factor; 176 dskfree = dskfree / conv_factor;
177#endif
158 if (verbose >= 3) 178 if (verbose >= 3)
159 printf (_("total=%d, free=%d\n"), dsktotal, dskfree); 179 printf (_("total=%d, free=%d\n"), dsktotal, dskfree);
160 180
@@ -373,6 +393,10 @@ On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\
373Will be discrepencies because swap -s counts allocated swap and includes\n\ 393Will be discrepencies because swap -s counts allocated swap and includes\n\
374real memory\n")); 394real memory\n"));
375#endif 395#endif
396#ifdef _AIX
397 printf (_("\n\
398On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n"));
399#endif
376 400
377 printf (_(UT_SUPPORT)); 401 printf (_(UT_SUPPORT));
378} 402}