plugin-homedirs: homedirs

File homedirs, 0.9 kB (added by ckujau, 1 year ago)

Munin plugin to display the size of home directories (sh(1) version)

Line 
1 #!/bin/sh
2 #
3 # (c)2008, Christian Kujau <lists@nerdbynature.de>
4 # Inspired by the perl version from 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-homedirs.cache ] && du -sk /home/* > /tmp/munin-homedirs.cache
8 #
9 CACHEFILE=/tmp/munin-homedirs.cache
10
11 if [ "$1" = "autoconf" ]; then
12         echo yes
13         exit 0
14 fi
15
16 if [ "$1" = "config" ]; then
17         echo 'graph_title Homedir usage (in MB)'
18         echo 'graph_args --base 1024 -l 1'
19         echo 'graph_vlabel MBytes'
20         echo 'graph_category disk'
21         echo 'graph_info This graph shows the size of the users homedirs'
22
23         awk '!/lost\+found/ {gsub(/\//,"_"); print $2}' $CACHEFILE | sort | while read i; do
24                 echo "$i".label `echo "$i" | sed 's/_/\//g'`
25                 echo "$i".warning 1024000
26                 echo "$i".critical 2048000
27         done
28         exit 0
29 fi      
30
31 awk '!/lost\+found/ {gsub(/\//,"_"); print $2".value "$1 * 1024 }' $CACHEFILE