File: df.in

package info (click to toggle)
munin 1.2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,940 kB
  • ctags: 98
  • sloc: sh: 4,215; makefile: 452; perl: 135
file content (98 lines) | stat: -rwxr-xr-x 2,425 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
#
# Script to monitor disk usage.
#
# Parameters understood:
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#
# $Log$
# Revision 1.5.2.4  2005/03/12 21:35:07  jimmyo
# Correct history loss in linux/{df,df_inode}.
#
# Revision 1.5.2.3  2005/03/10 10:04:48  jimmyo
# Fixed minor bug introduced with yesterdays change.
#
# Revision 1.5.2.2  2005/03/09 19:10:32  jimmyo
# Made linux/df work properly with tmpfs and devmapper (Deb#298442).
#
# Revision 1.5.2.1  2005/02/16 22:50:14  jimmyo
# linux/df* now ignores bind mounts.
#
# Revision 1.5  2004/12/09 20:27:45  jimmyo
# Sort fields in df*-plugins alphabetically.
#
# Revision 1.4  2004/09/25 22:29:16  jimmyo
# Added info fields to a bunch of plugins.
#
# Revision 1.3  2004/05/20 13:57:12  jimmyo
# Set categories to some of the plugins.
#
# Revision 1.2  2004/05/18 22:04:30  jimmyo
# Use "sed 1d" instead of "tail +2" in df plugins (patch by Olivier Delhomme).
#
# Revision 1.1  2004/01/02 18:50:01  jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.2  2003/11/07 17:43:16  jimmyo
# Cleanups and log entries
#
#
#
# Magic markers (optional - used by munin-config and installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf

MAXLABEL=20

if [ "$1" = "autoconf" ]; then
	echo yes
	exit 0
fi

clean_name() {
    echo $1 $7 $2 | sed 's/[\/.-]/_/g'| awk "{ 
	if (\$3 == \"tmpfs\")
		n=\$1\$2
	else
		n=\$1
	print n
	}"
}


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

	echo 'graph_title Filesystem usage (in %)'
	echo 'graph_args --upper-limit 100 -l 0'
	echo 'graph_vlabel %'
	echo 'graph_category disk'
	echo 'graph_info This graph shows disk usage on the machine.'
	df -T -P -l -x none -x unknown -x udf -x iso9660 -x romfs -x ramfs | sed 1d | grep -v "//" | sort | while read i; do
		name=`clean_name $i`
		echo -n "$name.label "
		echo $i | awk "{ 
			dir=\$7
			if (length(dir) <= $MAXLABEL)
				print dir
			else
				printf (\"...%s\n\", substr (dir, length(dir)-$MAXLABEL+4, $MAXLABEL-3)) 
			print \"$name.info \" \$7 \" (\" \$2 \") -> \" \$1;
		}"
		echo "$name.warning 92"
		echo "$name.critical 98"
	done
	exit 0
fi

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