summaryrefslogtreecommitdiff
path: root/munin
diff options
context:
space:
mode:
Diffstat (limited to 'munin')
-rwxr-xr-xmunin/vm_du_51
1 files changed, 51 insertions, 0 deletions
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