summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.c
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2003-09-17 09:31:56 +0000
committerTon Voon <tonvoon@users.sourceforge.net>2003-09-17 09:31:56 +0000
commit4fe50f4297fa4b34d28c2d39ab83e5d2db4e1193 (patch)
tree145b6f954fb99c75bc75df83c7477bd30b4b6aa6 /plugins/check_swap.c
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
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r--plugins/check_swap.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 3a799c32..2b71fd21 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}