diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2003-09-17 09:31:56 (GMT) |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2003-09-17 09:31:56 (GMT) |
commit | 4fe50f4297fa4b34d28c2d39ab83e5d2db4e1193 (patch) | |
tree | 145b6f954fb99c75bc75df83c7477bd30b4b6aa6 | |
parent | a0e099de2bb62c6b48587d75b2601f605ff14aad (diff) | |
download | monitoring-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.in | 59 | ||||
-rw-r--r-- | plugins/check_swap.c | 36 |
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 | |||
1263 | dnl The plugin works through all the swap devices and adds up the total swap | 1263 | dnl The plugin works through all the swap devices and adds up the total swap |
1264 | dnl available. | 1264 | dnl available. |
1265 | AC_PATH_PROG(PATH_TO_SWAP,swap) | 1265 | AC_PATH_PROG(PATH_TO_SWAP,swap) |
1266 | AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo) | 1266 | if (test -n "$PATH_TO_SWAP") |
1267 | |||
1268 | dnl dunno why this does not work below - use hack (kbd) | ||
1269 | dnl fine on linux, broken on solaris | ||
1270 | dnl if /bin/test -e "/proc/meminfo" | ||
1271 | AC_MSG_CHECKING(for how to check memory) | ||
1272 | if [cat /proc/meminfo > /dev/null 2>&1] | ||
1273 | then | ||
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" | ||
1278 | fi | ||
1279 | |||
1280 | if ( test -n "$PATH_TO_SWAP" || test -n "$PATH_TO_SWAPINFO" ) | ||
1281 | then | 1267 | then |
1282 | 1268 | AC_MSG_CHECKING([for $PATH_TO_SWAP format]) | |
1283 | if [$PATH_TO_SWAP -l 2>&1 >/dev/null] | 1269 | if [$PATH_TO_SWAP -l 2>&1 >/dev/null] |
1284 | then | 1270 | then |
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" |
1295 | fi | ||
1296 | dnl end if for PATH_TO_SWAP | ||
1297 | fi | ||
1309 | 1298 | ||
1310 | elif [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null] | 1299 | AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo) |
1300 | if (test -n "$PATH_TO_SWAPINFO") | ||
1301 | then | ||
1302 | AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format]) | ||
1303 | if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null] | ||
1311 | then | 1304 | then |
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]) |
1330 | fi | 1323 | fi |
1324 | dnl end if for PATH_TO_SWAPINFO | ||
1325 | fi | ||
1326 | |||
1327 | AC_PATH_PROG(PATH_TO_LSPS,lsps) | ||
1328 | if (test -n "$PATH_TO_LSPS") | ||
1329 | then | ||
1330 | AC_MSG_CHECKING([for $PATH_TO_LSPS format]) | ||
1331 | if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null] | ||
1332 | then | ||
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]) | ||
1338 | fi | ||
1339 | dnl end if for PATH_TO_SWAPINFO | ||
1340 | fi | ||
1331 | 1341 | ||
1332 | if test "x$ac_cv_have_swap" != "x" | 1342 | if test "x$ac_cv_have_swap" != "x" |
1333 | then | 1343 | then |
@@ -1343,8 +1353,19 @@ then | |||
1343 | [Conversion factor to MB]) | 1353 | [Conversion factor to MB]) |
1344 | fi | 1354 | fi |
1345 | 1355 | ||
1346 | dnl End of if SWAP | 1356 | dnl dunno why this does not work below - use hack (kbd) |
1347 | fi | 1357 | dnl fine on linux, broken on solaris |
1358 | dnl if /bin/test -e "/proc/meminfo" | ||
1359 | AC_MSG_CHECKING([for /proc/meminfo]) | ||
1360 | if [cat /proc/meminfo > /dev/null 2>&1] | ||
1361 | then | ||
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" | ||
1366 | else | ||
1367 | AC_MSG_RESULT([no]) | ||
1368 | fi | ||
1348 | 1369 | ||
1349 | AC_PATH_PROG(PATH_TO_DIG,dig) | 1370 | AC_PATH_PROG(PATH_TO_DIG,dig) |
1350 | AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present]) | 1371 | 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 3a799c3..2b71fd2 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
@@ -47,10 +47,6 @@ long unsigned int crit_size = 0; | |||
47 | int verbose; | 47 | int verbose; |
48 | int allswaps; | 48 | int allswaps; |
49 | 49 | ||
50 | #if !defined(sun) | ||
51 | int sun = 0; /* defined by compiler if it is a sun solaris system */ | ||
52 | #endif | ||
53 | |||
54 | int | 50 | int |
55 | main (int argc, char **argv) | 51 | main (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\ | |||
373 | Will be discrepencies because swap -s counts allocated swap and includes\n\ | 393 | Will be discrepencies because swap -s counts allocated swap and includes\n\ |
374 | real memory\n")); | 394 | real memory\n")); |
375 | #endif | 395 | #endif |
396 | #ifdef _AIX | ||
397 | printf (_("\n\ | ||
398 | On 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 | } |