Fix method to retrieve and compute real used pages (used - free pages)

This commit is contained in:
Benjamin Renard 2024-05-07 18:57:22 +02:00
parent 4cf080a81d
commit 1cb03a2fad
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -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,8 +111,12 @@ 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
debug "Used/max pages: $used_pages / $max_pages ($perc_used%)"