Projet

Général

Profil

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

root / plugins / other / df_with_nfs @ af935077

Historique | Voir | Annoter | Télécharger (2,4 ko)

1
#!/bin/sh
2
#
3
# Script to monitor disk usage.
4
#
5
# Parameters understood:
6
#
7
# 	config   (required)
8
# 	autoconf (optional - used by munin-config)
9
#
10
# $Log$
11
# Revision 1.5.2.4  2005/03/12 21:35:07  jimmyo
12
# Correct history loss in linux/{df,df_inode}.
13
#
14
# Revision 1.5.2.3  2005/03/10 10:04:48  jimmyo
15
# Fixed minor bug introduced with yesterdays change.
16
#
17
# Revision 1.5.2.2  2005/03/09 19:10:32  jimmyo
18
# Made linux/df work properly with tmpfs and devmapper (Deb#298442).
19
#
20
# Revision 1.5.2.1  2005/02/16 22:50:14  jimmyo
21
# linux/df* now ignores bind mounts.
22
#
23
# Revision 1.5  2004/12/09 20:27:45  jimmyo
24
# Sort fields in df*-plugins alphabetically.
25
#
26
# Revision 1.4  2004/09/25 22:29:16  jimmyo
27
# Added info fields to a bunch of plugins.
28
#
29
# Revision 1.3  2004/05/20 13:57:12  jimmyo
30
# Set categories to some of the plugins.
31
#
32
# Revision 1.2  2004/05/18 22:04:30  jimmyo
33
# Use "sed 1d" instead of "tail +2" in df plugins (patch by Olivier Delhomme).
34
#
35
# Revision 1.1  2004/01/02 18:50:01  jimmyo
36
# Renamed occurrances of lrrd -> munin
37
#
38
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
39
# Import of LRRD CVS tree after renaming to Munin
40
#
41
# Revision 1.2  2003/11/07 17:43:16  jimmyo
42
# Cleanups and log entries
43
#
44
#
45
#
46
# Magic markers (optional - used by munin-config and installation
47
# scripts):
48
#
49
#%# family=auto
50
#%# capabilities=autoconf
51

    
52
MAXLABEL=20
53

    
54
if [ "$1" = "autoconf" ]; then
55
	echo yes
56
	exit 0
57
fi
58

    
59
clean_name() {
60
    echo $1 $7 $2 | sed 's/[\/.-]/_/g'| awk "{ 
61
	if (\$3 == \"tmpfs\")
62
		n=\$1\$2
63
	else
64
		n=\$1
65
	print n
66
	}"
67
}
68

    
69

    
70
if [ "$1" = "config" ]; then
71

    
72
	echo 'graph_title Filesystem usage (in %)'
73
	echo 'graph_args --upper-limit 100 -l 0'
74
	echo 'graph_vlabel %'
75
	echo 'graph_category disk'
76
	echo 'graph_info This graph shows disk usage on the machine.'
77
	df -T -P -x none -x unknown -x udf -x iso9660 -x romfs -x ramfs | sed 1d | grep -v "//" | sort  | cut -d: -f2 | while read i; do
78
		name=`clean_name $i`
79
		echo -n "$name.label "
80
		echo $i | awk "{ 
81
			dir=\$7
82
			if (length(dir) <= $MAXLABEL)
83
				print dir
84
			else
85
				printf (\"...%s\n\", substr (dir, length(dir)-$MAXLABEL+4, $MAXLABEL-3)) 
86
			print \"$name.info \" \$7 \" (\" \$2 \") -> \" \$1;
87
		}"
88
		echo "$name.warning 92"
89
		echo "$name.critical 98"
90
	done
91
	exit 0
92
fi
93

    
94
df -T -P -x none -x unknown -x udf -x iso9660 -x romfs -x ramfs -x tmpfs | sed 1d | cut -d: -f2 | grep -v "//" | while read i; do
95
	name=`clean_name $i`
96
	echo -n "$name.value "
97
	echo $i | awk '{ print $6 }' | cut -f1 -d%
98
done