-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/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/ARCH | ||
env.PATTERN www.example.com www.sample.com | ||
In PATTERN, all items will be expanded like this : www.example.com* | ||
=head1 AUTHOR AND COPYRIGHT | ||
Copyright 2013 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 |