PluginPortrait/homedirs: homedirs

File homedirs, 907 bytes (added by ckujau, at 2008-10-27T12:00:59+01:00)

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#
9CACHEFILE=/tmp/munin-homedirs.cache
10
11if [ "$1" = "autoconf" ]; then
12        echo yes
13        exit 0
14fi
15
16if [ "$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
29fi     
30
31awk '!/lost\+found/ {gsub(/\//,"_"); print $2".value "$1 * 1024 }' $CACHEFILE