]> git.michaelhowe.org Git - packages/m/munin-plugins-local.git/commitdiff
Add lvmcache_ plugin
authorMichael Howe <michael@michaelhowe.org>
Sat, 16 Dec 2017 22:27:12 +0000 (22:27 +0000)
committerMichael Howe <michael@michaelhowe.org>
Sat, 16 Dec 2017 22:27:12 +0000 (22:27 +0000)
Makefile
conf/lvmcache [new file with mode: 0644]
debian/changelog
plugins/lvmcache_ [new file with mode: 0755]

index 6af094aa1b0fb8e5f7ced6c2e1da8e0f80b346d4..96fc5c03d4f13a98f3ef6bec1b6c213d91f4268c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@
 PLUGINDIR=plugins
 INSTALL=/usr/bin/install
 DSTPLUGINDIR=$(DESTDIR)/usr/share/munin/plugins
+CONFDIR=conf
+DSTCONFDIR=$(DESTDIR)/etc/munin/plugin-conf.d
 
 build:
        # no-op
@@ -9,5 +11,7 @@ build:
 install:
        $(INSTALL) -d $(DSTPLUGINDIR)
        $(INSTALL) -m 0755 $(PLUGINDIR)/* $(DSTPLUGINDIR)
+       $(INSTALL) -d $(DSTCONFDIR)
+       $(INSTALL) -m 0755 $(CONFDIR)/* $(DSTCONFDIR)
 
 .PHONY: install
diff --git a/conf/lvmcache b/conf/lvmcache
new file mode 100644 (file)
index 0000000..c4ae185
--- /dev/null
@@ -0,0 +1,2 @@
+[lvmcache_*]
+user root
index 4de0801bb4133813a0f9876999347713a62cae57..dae773da0f6790f534861a161feefb3aa789d8b3 100644 (file)
@@ -1,3 +1,9 @@
+munin-plugins-local (0.10~test.0) UNRELEASED; urgency=medium
+
+  * Add lvmcache_ plugin, for graphing lvm cache state 
+
+ -- Michael Howe <michael@michaelhowe.org>  Sat, 16 Dec 2017 22:12:26 +0000
+
 munin-plugins-local (0.9) unstable; urgency=low
 
   * Fix snmp__sky_router_ not showing the total number of devices 
diff --git a/plugins/lvmcache_ b/plugins/lvmcache_
new file mode 100755 (executable)
index 0000000..c3430b1
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/bash
+#
+# Plugin to get LVM cache states.  See lvmcache(7) for further details.
+#
+# Heavily based on <https://github.com/SweBarre/munin-lvm/blob/master/vg_>
+
+# Magic markers
+
+#%# family=auto
+#%# capabilities=autoconf suggest
+
+set -e
+
+VOLUMEGROUP=${0##*lvmcache_}
+VOLUMEGROUP=${VOLUMEGROUP%%_*}
+LOGICALVOLUME=${0##*${VOLUMEGROUP}_}
+
+[ -z "$LVS" ] && LVS="$(which lvs)"
+if [ ! -x "$LVS" ]; then
+    echo "Error - cannot find an executable lvs" >&2
+    exit 1
+fi
+
+export LVS
+
+do_ () {
+    LV_OUTPUT=( $($LVS --noheading --unit b --nosuffix --options lv_name,cache_total_blocks,cache_used_blocks,cache_read_hits,cache_read_misses,cache_write_hits,cache_write_misses,cache_dirty_blocks "$VOLUMEGROUP/$LOGICALVOLUME") )
+    echo "blks_total.value ${LV_OUTPUT[1]}"
+    echo "blks_used.value ${LV_OUTPUT[2]}"
+    echo "blks_read_hit.value ${LV_OUTPUT[3]}"
+    echo "blks_read_miss.value ${LV_OUTPUT[4]}"
+    echo "blks_write_hit.value ${LV_OUTPUT[5]}"
+    echo "blks_write_miss.value ${LV_OUTPUT[6]}"
+    echo "blks_dirty.value ${LV_OUTPUT[7]}"
+}
+
+do_autoconf() {
+    [ $LVS ] || { echo "no (lvs not found)"; exit 0; }
+    echo "yes"
+    exit 0
+}
+
+do_suggest () {
+    $LVS --noheadings --options vg_name,lv_name,cache_total_blocks | awk '$3 ~ /.+/ {print $1 "_" $2 }'
+}
+
+do_config () {
+    cat <<EOF
+graph_title LVM cache state $VOLUMEGROUP/$LOGICALVOLUME
+graph_info Cache information about $VOLUMEGROUP/$LOGICALVOLUME
+graph_vlabel bytes
+graph_category disk
+graph_args --base 1024 -l 0
+graph_scale yes
+blks_total.label Total blocks
+blks_total.draw LINE1
+blks_used.label Used blocks
+blks_used.draw LINE1
+blks_read_hit.label Cache read hits
+blks_read_hit.draw LINE1
+blks_read_miss.label Cache read misses
+blks_read_miss.draw LINE1
+blks_write_hit.label Cache write hits
+blks_write_hit.draw LINE1
+blks_dirty.label Dirty blocks
+blks_dirty.draw LINE1
+EOF
+}
+
+do_$1