Просмотр исходного кода

Added check for total_swap_mb == 0, and if present, sets used to 100% and changes status output in this case for readability

abrist 12 лет назад
Родитель
Сommit
bf5bb6b59f
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      plugins/check_swap.c

+ 5 - 2
plugins/check_swap.c

@@ -346,8 +346,11 @@ main (int argc, char **argv)
 # endif /* HAVE_SWAP */
 # endif /* HAVE_SWAP */
 #endif /* HAVE_PROC_MEMINFO */
 #endif /* HAVE_PROC_MEMINFO */
 
 
-	/* if total_swap_mb == 0, let's not divide by 0 */
-	if(total_swap_mb) {
+	/* if total_swap_mb == 0, swap is most likely missing or disabled and should go critical */
+	if(total_swap_mb == 0) {
+		percent_used = 100;
+		status = "- Swap is either disabled, not present, or of zero size. ";
+	} else if(total_swap_mb > 0) {
 		percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb);
 		percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb);
 	} else {
 	} else {
 		percent_used = 0;
 		percent_used = 0;