From 07b4387e39de62326b384f59089dc877cc396341 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 7 Oct 2015 10:03:51 +0200 Subject: disk usage plugin for VMs --- munin/vm_du_ | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 munin/vm_du_ diff --git a/munin/vm_du_ b/munin/vm_du_ new file mode 100755 index 0000000..5564c44 --- /dev/null +++ b/munin/vm_du_ @@ -0,0 +1,51 @@ +#!/bin/bash +# -*- sh -*- + +MUNIN_LIBDIR=${MUNIN_LIBDIR:-/usr/share/munin} +. $MUNIN_LIBDIR/plugins/plugin.sh + +BASE=/srv/vmstore + +VM=${0##*vm_du_} +#VM=${VM//_/.} + +case $1 in + autoconf) + if [[ -d "$BASE" ]]; then + echo yes + exit 0 + else + echo "no ($BASE not found)" + exit 0 + fi + ;; + suggest) + if [[ -d "$BASE" ]]; then + find "$BASE" -mindepth 1 -maxdepth 1 -type d -a ! -name lost+found -printf '%f\n' # | tr . _ + fi + exit 0 + ;; + config) + echo "graph_title disk usage VM $VM" + echo 'graph_args --base 1024 --lower-limit 0' + echo 'graph_vlabel bytes' + echo 'graph_category disk' + echo 'graph_total Total' + + find "$BASE/$VM" -mindepth 1 -maxdepth 1 -type f | + while read fn; do + label="${fn##*/}" + label=${label//./_} + name=${label//-/_} + echo "$name.label $label" + echo "$name.cdef $name,1024,*" + done + exit 0 + ;; +esac + +find "$BASE/$VM" -mindepth 1 -maxdepth 1 -type f -printf '%f %k\n' | +while read fn du; do + fn=${fn//[.-]/_} + echo "$fn.value $du" +done -- cgit v1.2.3