File: df_abs.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 (72 lines) | stat: -rwxr-xr-x 1,590 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
#!/bin/sh
#
# Script to monitor absolute disk usage.
#
# Parameters understood:
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#
# $Log$
# Revision 1.2.2.1  2005/02/16 22:50:14  jimmyo
# linux/df* now ignores bind mounts.
#
# Revision 1.2  2004/08/24 13:37:29  ilmari
# Add total line
#
# Revision 1.1  2004/08/24 12:26:48  ilmari
# Added plugin linux/df_abs
#
# Magic markers (optional - used by munin-config and installation
# scripts):
#
#%# family=manual
#%# capabilities=autoconf

MAXLABEL=20
MAXNAME=15

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

clean_name() {
    echo $1 | sed 's/[\/.-]/_/g; s/^_dev\(_mapper\)\?_//'| awk "{ 
	if (length(\$1) > $MAXNAME)
		print substr(\$1, length(\$1)-$MAXNAME+1)
	else
		print \$1
	}"
}

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

	echo 'graph_title Filesystem usage (in bytes)'
	echo 'graph_args --base 1024 --lower-limit 0'
	echo 'graph_vlabel bytes'
	echo 'graph_category disk'
	echo 'graph_total Total'
	df -P -l -x none -x unknown | sed 1d | grep -v "//" | while read i; do
		name=`clean_name $i`
		echo -n "$name.label "
		echo $i | awk "{ 
			dir=\$6
			if (length(dir) <= $MAXLABEL)
				print dir
			else
				printf (\"...%s\n\", substr (dir, length(dir)-$MAXLABEL+4, $MAXLABEL-3)) 
		}"
		echo "$name.cdef $name,1024,*"
		size=`echo $i | awk '{print $2}'`
		echo "$name.warning $((size / 100 * 92))"
		echo "$name.critical $((size / 100 * 98))"
	done
	exit 0
fi

df -P -l -x unknown  -x none| sed 1d | grep -v "//" | while read i; do
	name=`clean_name $i`
	echo -n "$name.value "
	echo $i | awk '{ print $3 }'
done