diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 8f5ebf8ee15790c7c2f3e65777e745da8b2c95f0..aeeb9ba0a8872044e55dc1064a91f00c38cbac0e 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
float dsktotal = 0, dskused = 0, dskfree = 0, tmp = 0;
int result = STATE_UNKNOWN;
char input_buffer[MAX_INPUT_BUFFER];
- char *perf;
#ifdef HAVE_PROC_MEMINFO
FILE *fp;
#else
textdomain (PACKAGE);
status = strdup ("");
- perf = strdup ("");
if (process_arguments (argc, argv) == ERROR)
usage4 (_("Could not parse arguments"));
# endif /* HAVE_SWAP */
#endif /* HAVE_PROC_MEMINFO */
- percent_used = 100 * ((double) used_swap) / ((double) total_swap);
+ /* if total_swap == 0, let's not divide by 0 */
+ if(total_swap) {
+ percent_used = 100 * ((double) used_swap) / ((double) total_swap);
+ } else {
+ percent_used = 0;
+ }
+
result = max_state (result, check_swap (percent_used, free_swap));
printf (_("SWAP %s - %d%% free (%.0f MB out of %.0f MB) %s|"),
state_text (result),
-v, --verbose\n\
Verbose output. Up to 3 levels\n"));
- 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"));
printf (_("\n\
On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n"));