1
0
Fork 0

nagios/btrfs: quick patch

This commit is contained in:
Chl 2023-10-01 01:32:25 +02:00
parent eabe6084fb
commit d2ee68217e
2 changed files with 6 additions and 4 deletions

View file

@ -109,6 +109,7 @@ check_freespace_is_above_threshold() {
# 4: EXCL
# 5: MAXRFER
# 6: MAXEXCL
# 7: SUBVOLUMEPATH
format_output_item() {
local LOCAL_OUTPUT=""
if [ "$5" != "none" ]; then
@ -125,7 +126,7 @@ format_output_item() {
)"
fi
if [ -n "$LOCAL_OUTPUT" ]; then
printf "%s:%s (%s)" "$1" "$2" "$LOCAL_OUTPUT"
printf "%s:%s (%s)" "$1" "$2$( test -n "$7" && echo ":$7" )" "$LOCAL_OUTPUT"
fi
}
@ -175,7 +176,7 @@ while getopts hw:c:V: f; do
# Loop on each qgroup
# (the kinda weird <<EOF at the end is to avoid entering a sub-shell, so we can keep
# our precious vars even with prosix-strict dash)
while read QGROUPID RFER EXCL MAXRFER MAXEXCL; do
while read QGROUPID RFER EXCL MAXRFER MAXEXCL SUBVOLUMEPATH; do
LOOP_OUTPUT_STATUS=$STATE_OK
if [ "$MAXRFER" != "none" ]; then
FREERFER="$(( $MAXRFER - $RFER ))"
@ -201,7 +202,7 @@ while getopts hw:c:V: f; do
# Depending on the alerts raised during this loop, we store
# the output in ok/warning/critical. This way, in case of critical
# alert, we don't list all the ok data.
TMP="$( format_output_item "$VOLUME" "$QGROUPID" "$RFER" "$EXCL" "$MAXRFER" "$MAXEXCL" )"
TMP="$( format_output_item "$VOLUME" "$QGROUPID" "$RFER" "$EXCL" "$MAXRFER" "$MAXEXCL" "$SUBVOLUMEPATH" )"
case "$LOOP_OUTPUT_STATUS" in
"$STATE_OK")
OUTPUT_DETAIL_OK="$OUTPUT_DETAIL_OK $TMP" ;;
@ -211,7 +212,7 @@ while getopts hw:c:V: f; do
OUTPUT_DETAIL_CRITICAL="$OUTPUT_DETAIL_CRITICAL $TMP" ;;
esac
OUTPUT_PERFDATA="$( printf "%s\n%s\n%s" "$OUTPUT_PERFDATA" "$VOLUME:$QGROUPID:rfer=$RFER" "$VOLUME:$QGROUPID:excl=$EXCL" )"
OUTPUT_PERFDATA="$( printf "%s\n%s\n%s" "$OUTPUT_PERFDATA" "$VOLUME:$QGROUPID:$SUBVOLUMEPATH:rfer=$RFER" "$VOLUME:$QGROUPID:$SUBVOLUMEPATH:excl=$EXCL" )"
done <<EOF
$( btrfs qgroup show -re --raw "$VOLUME" | tail -n +3 )
EOF

View file

@ -0,0 +1 @@
command[check_btrfs_quota]=sudo /usr/local/share/scripts-admin/nagios/check_btrfs_quota.sh -w 30% -c 10% -V /srv