소스 검색

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 년 전
부모
커밋
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_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);
 	} else {
 		percent_used = 0;