2012-01-12 14:27:01 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
: <<=cut
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
xfs_frag - Munin plugin to monitor the fragmentation level on your XFS filesystems
|
|
|
|
|
|
|
|
=head1 APPLICABLE SYSTEMS
|
|
|
|
|
|
|
|
Any machine with an XFS file system.
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
None, generally, but you may want to run as root and set a timeout.
|
|
|
|
|
|
|
|
[xfs_frag]
|
|
|
|
user root
|
|
|
|
timeout 90
|
|
|
|
|
|
|
|
=head1 MAGIC MARKERS
|
|
|
|
|
|
|
|
#%# family=auto contrib
|
|
|
|
#%# capabilities=
|
|
|
|
|
|
|
|
=head1 VERSION
|
|
|
|
|
|
|
|
1
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Paul Saunders L<darac+munin@darac.org.uk>
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
declare -a ARRY
|
|
|
|
shopt -s nocasematch
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
config)
|
2018-08-02 02:03:42 +02:00
|
|
|
cat <<'EOF'
|
2012-01-12 14:27:01 +01:00
|
|
|
graph_title XFS fragmentation
|
|
|
|
graph_vlabel Percent
|
2017-02-20 23:35:10 +01:00
|
|
|
graph_category disk
|
2012-01-12 14:27:01 +01:00
|
|
|
EOF
|
|
|
|
cat /etc/mtab | awk '{print $2 " " $3}' | while read LINE
|
|
|
|
do
|
|
|
|
ARRY=($LINE)
|
|
|
|
if [[ ${ARRY[1]} =~ xfs ]]; then
|
|
|
|
FIELDNAME=$(echo ${ARRY[0]} | sed 's/^[^A-Za-z_]/_/; s/[^A-Za-z0-9_]/_/g')
|
|
|
|
echo "$FIELDNAME.label ${ARRY[0]}"
|
|
|
|
echo "$FIELDNAME.type GAUGE"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
cat /etc/mtab | awk '{print $2 " " $3 " " $1}' | while read LINE
|
|
|
|
do
|
|
|
|
ARRY=($LINE)
|
|
|
|
if [[ ${ARRY[1]} =~ xfs ]]; then
|
|
|
|
FIELDNAME=$(echo ${ARRY[0]} | sed 's/^[^A-Za-z_]/_/; s/[^A-Za-z0-9_]/_/g')
|
|
|
|
FRAG=$(xfs_db -c frag -r ${ARRY[2]} | sed 's/.*fragmentation factor \(.*\)%.*/\1/')
|
|
|
|
echo $FIELDNAME.value $FRAG
|
|
|
|
fi
|
|
|
|
done
|
2018-08-02 02:03:42 +02:00
|
|
|
|