summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3a942eb)
raw | patch | inline | side by side (parent: 3a942eb)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Tue, 30 Sep 2003 13:54:26 +0000 (13:54 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Tue, 30 Sep 2003 13:54:26 +0000 (13:54 +0000) |
unnecessary ifdefs for help page. Better indentation for ifdefs
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@742 f882894a-f735-0410-b71e-b25c423dba1c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@742 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_swap.c | patch | blob | history |
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 2b71fd2106ec11f5e1bf0390019c372c18760b83..367c720d2d2a8313d7c51b07920e0c2174ab79f7 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
fclose(fp);
#else
# ifdef HAVE_SWAP
+ asprintf(&swap_command, "%s", SWAP_COMMAND);
+ asprintf(&swap_format, "%s", SWAP_FORMAT);
+ conv_factor = SWAP_CONVERSION;
+
+/* These override the command used if a summary (and thus ! allswaps) is required */
+/* The summary flag returns more accurate information about swap usage on these OSes */
+# ifdef _AIX
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
+ }
+# else
+# ifdef sun
+ if (!allswaps) {
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);
- conv_factor = SWAP_CONVERSION;
}
+# endif
+# endif
if (verbose >= 2)
printf (_("Command: %s\n"), swap_command);
}
}
+/* If different swap command is used for summary switch, need to read format differently */
+# ifdef _AIX
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
+ } else {
+# else
+# ifdef sun
+ if (!allswaps) {
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 {
+# endif
+# endif
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
+# ifdef _AIX
dskfree = dsktotal * (100 - dskfree) / 100;
-#else
+# else
dskfree = dskfree / conv_factor;
-#endif
+# endif
if (verbose >= 3)
printf (_("total=%d, free=%d\n"), dsktotal, dskfree);
asprintf (&status, "%s [%lu (%d%%)]", status, dskfree, 100 - percent);
}
}
+# ifdef _AIX
+ }
+# else
+# ifdef sun
}
+# endif
+# endif
+
/* If we get anything on STDERR, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
result = max_state (result, STATE_WARNING);
/* close the pipe */
if (spclose (child_process))
result = max_state (result, STATE_WARNING);
-# endif
-#endif
+# endif /* HAVE_SWAP */
+#endif /* HAVE_PROC_MEMINFO */
percent_used = 100 * ((double) used_swap) / ((double) total_swap);
result = max_state (result, check_swap (percent_used, free_swap));
-a, --allswaps\n\
Conduct comparisons for all swap partitions, one by one\n"));
-#ifdef sun
printf (_("\n\
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));
}