From 93bbc46cb232777d112645a01802e80fe8e7e364 Mon Sep 17 00:00:00 2001 From: Michael Howe Date: Sat, 16 Dec 2017 22:27:12 +0000 Subject: [PATCH] Add lvmcache_ plugin --- Makefile | 4 +++ conf/lvmcache | 2 ++ debian/changelog | 6 ++++ plugins/lvmcache_ | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 conf/lvmcache create mode 100755 plugins/lvmcache_ diff --git a/Makefile b/Makefile index 6af094a..96fc5c0 100644 --- 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 index 0000000..c4ae185 --- /dev/null +++ b/conf/lvmcache @@ -0,0 +1,2 @@ +[lvmcache_*] +user root diff --git a/debian/changelog b/debian/changelog index 4de0801..dae773d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +munin-plugins-local (0.10~test.0) UNRELEASED; urgency=medium + + * Add lvmcache_ plugin, for graphing lvm cache state + + -- Michael Howe 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 index 0000000..c3430b1 --- /dev/null +++ b/plugins/lvmcache_ @@ -0,0 +1,70 @@ +#!/bin/bash +# +# Plugin to get LVM cache states. See lvmcache(7) for further details. +# +# Heavily based on + +# 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 <