Merge pull request #17 from daald/improve-df

Improve df
This commit is contained in:
Steve Schnepp 2023-12-14 14:33:37 +01:00 committed by GitHub
commit 3b6ef20dc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,21 +4,19 @@ 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 "$DF_IGNORE_FILESYSTEM_REGEX" | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g') df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | while read dev type blocks used avail pct mp
do do
PINFO=$(df -P "$PART" | tail -1); PNAME=$(clean_fieldname "$mp")
PNAME=$(clean_fieldname "$(echo "$PINFO" | cut -d " " -f 1)") echo "$PNAME.label $mp"
echo "$PNAME.label $PART" echo "$PNAME.info $dev -> $mp"
echo "$PNAME.info $PNAME -> $PART"
echo "$PNAME.warning 92" echo "$PNAME.warning 92"
echo "$PNAME.critical 98" echo "$PNAME.critical 98"
done done
} }
fetch_df() { fetch_df() {
for PART in $(df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g') df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | while read dev type blocks used avail pct mp
do do
PINFO=$(df -P "$PART" | tail -1); PNAME=$(clean_fieldname "$mp")
PNAME=$(clean_fieldname "$(echo "$PINFO" | cut -d " " -f 1)") echo "$PNAME.value" "${pct%\%}"
echo "$PNAME.value" "$(echo "$PINFO" | sed -e 's/\%//g' -e 's/ */ /g' | cut -d " " -f 5)"
done done
} }