summaryrefslogtreecommitdiff
path: root/munin/vm_du_
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2015-10-07 10:03:51 +0200
committerPeter Palfrader <peter@palfrader.org>2015-10-07 10:03:51 +0200
commit07b4387e39de62326b384f59089dc877cc396341 (patch)
tree59629776c533632dc465f38d53db524a87289409 /munin/vm_du_
parentf12b5801b74a3a208512a1626e4ecbd347208234 (diff)
disk usage plugin for VMs
Diffstat (limited to 'munin/vm_du_')
-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