[Nagiosplug-checkins] nagiosplug/plugins check_swap.c,1.49,1.50
M. Sean Finney
seanius at users.sourceforge.net
Tue Jun 28 18:05:25 CEST 2005
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29319
Modified Files:
check_swap.c
Log Message:
divide by 0 fix for check_swap
Index: check_swap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- check_swap.c 28 Jun 2005 00:26:53 -0000 1.49
+++ check_swap.c 29 Jun 2005 01:04:10 -0000 1.50
@@ -310,7 +310,13 @@
# 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),
More information about the Commits
mailing list