root / plugins / disk / du_pattern @ 6c7ad652
Historique | Voir | Annoter | Télécharger (2,02 ko)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
# -*- sh -*- |
| 3 |
# vim: ft=sh |
| 4 |
|
| 5 |
: << =cut |
| 6 |
|
| 7 |
=head1 NAME |
| 8 |
|
| 9 |
du_pattern - plugin to monitor files size selected and grouped by a pattern |
| 10 |
|
| 11 |
=head1 CONFIGURATION |
| 12 |
|
| 13 |
[du_pattern] |
| 14 |
env.DIR /var/log/apache/ |
| 15 |
env.PATTERN www.example.com www.sample.com |
| 16 |
|
| 17 |
In PATTERN, all items will be expanded like this : www.example.com* |
| 18 |
In this example, you will monitor the size of : |
| 19 |
/var/log/apache/www.example.com* |
| 20 |
/var/log/apache/www.sample.com* |
| 21 |
|
| 22 |
It's useful if you want to graph the size of your sites' log archives for example, |
| 23 |
one graph per site. |
| 24 |
|
| 25 |
=head1 AUTHOR AND COPYRIGHT |
| 26 |
|
| 27 |
Copyright 2013-2014 Luc Didry <luc AT didry.org> |
| 28 |
|
| 29 |
=head1 LICENSE |
| 30 |
|
| 31 |
This program is free software: you can redistribute it and/or modify |
| 32 |
it under the terms of the GNU General Public License as published by |
| 33 |
the Free Software Foundation, either version 3 of the License, or |
| 34 |
any later version. |
| 35 |
|
| 36 |
This program is distributed in the hope that it will be useful, |
| 37 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 38 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 39 |
GNU General Public License for more details. |
| 40 |
|
| 41 |
You should have received a copy of the GNU General Public License |
| 42 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 43 |
|
| 44 |
=cut |
| 45 |
|
| 46 |
NAME=${0##*/du_pattern_}
|
| 47 |
|
| 48 |
if [ "$1" = "config" ]; then |
| 49 |
echo "multigraph du_pattern_${NAME}"
|
| 50 |
echo "graph_title Files size in ${DIR}"
|
| 51 |
echo "graph_vlabel size of files" |
| 52 |
echo "graph_category disk" |
| 53 |
echo "graph_total Total" |
| 54 |
echo "graph_info This graph shows the size of files grouped by a pattern." |
| 55 |
FIRST=1 |
| 56 |
for i in ${PATTERN}
|
| 57 |
do |
| 58 |
CLEAN=${i//\./_}
|
| 59 |
echo "$CLEAN.label $CLEAN" |
| 60 |
if [[ $FIRST -eq 1 ]] |
| 61 |
then |
| 62 |
echo "$CLEAN.draw AREA" |
| 63 |
FIRST=0 |
| 64 |
else |
| 65 |
echo "$CLEAN.draw STACK" |
| 66 |
fi |
| 67 |
done |
| 68 |
exit 0 |
| 69 |
fi |
| 70 |
|
| 71 |
for i in ${PATTERN}
|
| 72 |
do |
| 73 |
CLEAN=${i//\./_}
|
| 74 |
FILES="${DIR}/${i}*"
|
| 75 |
echo -n "$CLEAN.value " |
| 76 |
echo $(du -cbs ${FILES} | grep total | cut -f 1)
|
| 77 |
done |
| 78 |
exit 0 |
