root / plugins / disk / xfs_frag @ 64089240
Historique | Voir | Annoter | Télécharger (1,28 ko)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
|
| 3 |
: <<=cut |
| 4 |
=head1 NAME |
| 5 |
|
| 6 |
xfs_frag - Munin plugin to monitor the fragmentation level on your XFS filesystems |
| 7 |
|
| 8 |
=head1 APPLICABLE SYSTEMS |
| 9 |
|
| 10 |
Any machine with an XFS file system. |
| 11 |
|
| 12 |
=head1 CONFIGURATION |
| 13 |
|
| 14 |
None, generally, but you may want to run as root and set a timeout. |
| 15 |
|
| 16 |
[xfs_frag] |
| 17 |
user root |
| 18 |
timeout 90 |
| 19 |
|
| 20 |
=head1 MAGIC MARKERS |
| 21 |
|
| 22 |
#%# family=auto contrib |
| 23 |
#%# capabilities= |
| 24 |
|
| 25 |
=head1 VERSION |
| 26 |
|
| 27 |
1 |
| 28 |
|
| 29 |
=head1 AUTHOR |
| 30 |
|
| 31 |
Paul Saunders L<darac+munin@darac.org.uk> |
| 32 |
|
| 33 |
=cut |
| 34 |
|
| 35 |
declare -a TOKENS |
| 36 |
shopt -s nocasematch |
| 37 |
|
| 38 |
case $1 in |
| 39 |
config) |
| 40 |
cat <<'EOF' |
| 41 |
graph_title XFS fragmentation |
| 42 |
graph_vlabel Percent |
| 43 |
graph_category disk |
| 44 |
EOF |
| 45 |
awk '{print $2 " " $3}' </etc/mtab | while read -r LINE; do
|
| 46 |
# shellcheck disable=SC2206 |
| 47 |
TOKENS=($LINE) |
| 48 |
if [[ ${TOKENS[1]} =~ xfs ]]; then
|
| 49 |
FIELDNAME=$(echo "${TOKENS[0]}" | sed 's/^[^A-Za-z_]/_/; s/[^A-Za-z0-9_]/_/g')
|
| 50 |
echo "$FIELDNAME.label ${TOKENS[0]}"
|
| 51 |
echo "$FIELDNAME.type GAUGE" |
| 52 |
fi |
| 53 |
done |
| 54 |
exit 0 |
| 55 |
;; |
| 56 |
esac |
| 57 |
|
| 58 |
awk '{print $2 " " $3 " " $1}' </etc/mtab | while read -r LINE; do
|
| 59 |
# shellcheck disable=SC2206 |
| 60 |
TOKENS=($LINE) |
| 61 |
if [[ ${TOKENS[1]} =~ xfs ]]; then
|
| 62 |
FIELDNAME=$(echo "${TOKENS[0]}" | sed 's/^[^A-Za-z_]/_/; s/[^A-Za-z0-9_]/_/g')
|
| 63 |
FRAG=$(xfs_db -c frag -r "${TOKENS[2]}" | sed 's/.*fragmentation factor \(.*\)%.*/\1/')
|
| 64 |
echo "$FIELDNAME.value $FRAG" |
| 65 |
fi |
| 66 |
done |
