-
Notifications
You must be signed in to change notification settings - Fork 2
/
du_pattern
executable file
·78 lines (61 loc) · 2.02 KB
/
du_pattern
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
#!/bin/sh
# -*- sh -*-
# vim: ft=sh
: << =cut
=head1 NAME
du_pattern - plugin to monitor files size selected and grouped by a pattern
=head1 CONFIGURATION
[du_pattern]
env.DIR /var/log/apache/
env.PATTERN www.example.com www.sample.com
In PATTERN, all items will be expanded like this : www.example.com*
In this example, you will monitor the size of :
/var/log/apache/www.example.com*
/var/log/apache/www.sample.com*
It's useful if you want to graph the size of your sites' log archives for example,
one graph per site.
=head1 AUTHOR AND COPYRIGHT
Copyright 2013-2014 Luc Didry <luc AT didry.org>
=head1 LICENSE
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=cut
NAME=${0##*/du_pattern_}
if [ "$1" = "config" ]; then
echo "multigraph du_pattern_${NAME}"
echo "graph_title Files size in ${DIR}"
echo "graph_vlabel size of files"
echo "graph_category disk"
echo "graph_total Total"
echo "graph_info This graph shows the size of files grouped by a pattern."
FIRST=1
for i in ${PATTERN}
do
CLEAN=${i//\./_}
echo "$CLEAN.label $CLEAN"
if [[ $FIRST -eq 1 ]]
then
echo "$CLEAN.draw AREA"
FIRST=0
else
echo "$CLEAN.draw STACK"
fi
done
exit 0
fi
for i in ${PATTERN}
do
CLEAN=${i//\./_}
FILES="${DIR}/${i}*"
echo -n "$CLEAN.value "
echo $(du -cbs ${FILES} | grep total | cut -f 1)
done
exit 0