Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / disk / xfs_frag @ 17f78427

Historique | Voir | Annoter | Télécharger (1,2 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 ARRY
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
		cat /etc/mtab | awk '{print $2 " " $3}' | while read LINE
46
		do
47
			ARRY=($LINE)
48
			if [[ ${ARRY[1]} =~ xfs ]]; then
49
				FIELDNAME=$(echo ${ARRY[0]} | sed 's/^[^A-Za-z_]/_/; s/[^A-Za-z0-9_]/_/g')
50
				echo "$FIELDNAME.label ${ARRY[0]}"
51
				echo "$FIELDNAME.type GAUGE"
52
			fi
53
		done
54
		exit 0
55
		;;
56
esac
57

    
58
cat /etc/mtab | awk '{print $2 " " $3 " " $1}' | while read LINE
59
do
60
	ARRY=($LINE)
61
	if [[ ${ARRY[1]} =~ xfs ]]; then
62
		FIELDNAME=$(echo ${ARRY[0]} | sed 's/^[^A-Za-z_]/_/; s/[^A-Za-z0-9_]/_/g')
63
		FRAG=$(xfs_db -c frag -r ${ARRY[2]} | sed 's/.*fragmentation factor \(.*\)%.*/\1/')
64
		echo $FIELDNAME.value $FRAG
65
	fi
66
done
67