df: fix "config" vs "fetch" mismatches (#9)

Two fixes:
1) Use same regexp to skip df partitions in "config" and "fetch".
2) Use same function (was two different sed) to cleanup partition name.

This fixes bug #5.
This commit is contained in:
Kim B. Heino 2020-10-07 20:11:11 +03:00 committed by GitHub
parent ebd0cca326
commit 5206847aa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -1,2 +1,3 @@
# the following variables are added to the top of the assembled muninlite script # the following variables are added to the top of the assembled muninlite script
NTP_PEER="pool.ntp.org" NTP_PEER="pool.ntp.org"
DF_IGNORE_FILESYSTEM_REGEX="(none|unknown|rootfs|iso9660|squashfs|udf|romfs|ramfs|debugfs|cgroup_root|devtmpfs)"

View file

@ -1,14 +1,13 @@
config_df() { config_df() {
IGNORE_FILESYSTEM_REGEX="(none|unknown|rootfs|iso9660|squashfs|udf|romfs|ramfs|debugfs|cgroup_root|devtmpfs)"
echo "graph_title Filesystem usage (in %) echo "graph_title Filesystem usage (in %)
graph_args --upper-limit 100 -l 0 graph_args --upper-limit 100 -l 0
graph_vlabel % graph_vlabel %
graph_category disk graph_category disk
graph_info This graph shows disk usage on the machine." graph_info This graph shows disk usage on the machine."
for PART in $(df -PT | grep '^/' | grep -vwE "$IGNORE_FILESYSTEM_REGEX" | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g') for PART in $(df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g')
do do
PINFO=$(df -P "$PART" | tail -1); PINFO=$(df -P "$PART" | tail -1);
PNAME=$(echo "$PINFO" | cut -d " " -f 1 | sed 's/\//_/g') PNAME=$(clean_fieldname "$(echo "$PINFO" | cut -d " " -f 1)")
echo "$PNAME.label $PART" echo "$PNAME.label $PART"
echo "$PNAME.info $PNAME -> $PART" echo "$PNAME.info $PNAME -> $PART"
echo "$PNAME.warning 92" echo "$PNAME.warning 92"
@ -16,10 +15,10 @@ graph_info This graph shows disk usage on the machine."
done done
} }
fetch_df() { fetch_df() {
for PART in $(df -P | grep '^/' | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g') for PART in $(df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g')
do do
PINFO=$(df -P "$PART" | tail -1); PINFO=$(df -P "$PART" | tail -1);
PNAME=$(echo "$PINFO" | cut -d " " -f 1 | sed 's/[\/.-]/_/g') PNAME=$(clean_fieldname "$(echo "$PINFO" | cut -d " " -f 1)")
echo "$PNAME.value" "$(echo "$PINFO" | sed -e 's/\%//g' -e 's/ */ /g' | cut -d " " -f 5)" echo "$PNAME.value" "$(echo "$PINFO" | sed -e 's/\%//g' -e 's/ */ /g' | cut -d " " -f 5)"
done done
} }