PluginPortrait/homedirs: du_multidirs

File du_multidirs, 966 bytes (added by ckujau, at 2009-07-25T06:12:09+02:00)

Munin plugin to monitor the size of one or more directories, sh(1) version

Line 
1#!/bin/sh
2#
3# (c)2009, Christian Kujau <lists@nerdbynature.de>
4# Based on the 'homedirs' plugin, initially written in Perl by Philipp Gruber <pg@flupps.net>
5#
6# We still need a cronjob to update CACHEFILE once in a while, e.g.:
7# 0 * * * * root [ -O /tmp/munin-du_multidirs.cache ] && du -sk /dir /dir2 dir3/* > /tmp/munin-du_multidirs.cache
8#
9CACHEFILE=/tmp/munin-du_multidirs.cache
10
11if [ "$1" = "autoconf" ]; then
12        echo yes
13        exit 0
14fi
15
16if [ "$1" = "config" ]; then
17        echo 'graph_title Directory usage (in MB)'
18        echo 'graph_args --base 1024 -l 1'
19        echo 'graph_vlabel Bytes'
20        echo 'graph_category disk'
21        echo 'graph_info This graph shows the size of several directories'
22
23        awk '!/lost\+found/ {gsub(/\//,"_"); print $2 }' $CACHEFILE | sort | while read u; do
24                echo "$u".label `echo "$u" | sed 's/_/\//g'`
25#               echo "$u".warning 0
26#               echo "$u".critical 0
27        done
28        exit 0
29fi     
30
31awk '!/lost\+found/ {gsub(/\//,"_"); print $2".value "$1 * 1024 }' $CACHEFILE | sort -r -n -k2