From 9b8ef00ac6875b94f818599bfde9a93f202dae3c Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 7 May 2024 18:57:22 +0200 Subject: [PATCH] Fix method to retrieve and compute real used pages (used - free pages) --- check_mdb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/check_mdb b/check_mdb index 69ec22e..3c04aae 100755 --- a/check_mdb +++ b/check_mdb @@ -90,7 +90,7 @@ do esac done -CMD="$MDB_STAT -e $DB_PATH" +CMD="$MDB_STAT -ef $DB_PATH" debug "mdb_stat command = '$CMD'" if [ -n "$SUDO_USER" ] @@ -111,6 +111,11 @@ then exit 3 fi +raw_used_pages=$( echo -e "$OUTPUT"|grep -E '^ +Number of pages used: '|sed 's/^ \+Number of pages used: \([0-9]\+\)$/\1/' ) +free_pages=$( echo -e "$OUTPUT"|grep -E '^ +Free pages: '|sed 's/^ \+Free pages: \([0-9]\+\)$/\1/' ) +let used_pages=raw_used_pages-free_pages +debug "Used/free pages: $raw_used_pages / $free_pages. Real used pages: $used_pages" + max_pages=$( echo -e "$OUTPUT"|grep -E '^ +Max pages: '|sed 's/^ \+Max pages: \([0-9]\+\)$/\1/' ) used_pages=$( echo -e "$OUTPUT"|grep -E '^ +Number of pages used: '|sed 's/^ \+Number of pages used: \([0-9]\+\)$/\1/' ) let perc_used=$used_pages*100/$max_pages