From e193edb501ad395833f6a7d883636b536cefe61e Mon Sep 17 00:00:00 2001 From: Albert Stefanov Date: Sun, 15 Oct 2023 09:32:29 +0300 Subject: [PATCH] Add CheckMK plugins Document the currently used monitoring plugins (ref. #12) Add the patched QEMU plugin --- tools/cmk-plugins/README.md | 18 ++++++++++++++++++ tools/cmk-plugins/qemu | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tools/cmk-plugins/README.md create mode 100755 tools/cmk-plugins/qemu diff --git a/tools/cmk-plugins/README.md b/tools/cmk-plugins/README.md new file mode 100644 index 0000000..97f1307 --- /dev/null +++ b/tools/cmk-plugins/README.md @@ -0,0 +1,18 @@ +# CheckMK Plugins + +Monitoring plugins for Openfest 2023 + +## Installation + +Built-in plugins are downloaded directly from the monitoring site ([Internal URL](http://monitoring.openfest.org/)). +Custom plugins are downloaded from this repo. + +The files are installed to `/usr/lib/check_mk_agent/plugins` with execute permissions (ex. `755`). + +## Plugin List + +| Name | Type | Installed on | Notes | +| ------------ | ----------------------------------------------- | ------------ | ---------------------------- | +| qemu | [Custom](https://exchange.checkmk.com/p/qemu-1) | sonata | Patched to work on debian 12 | +| smart | Built-in | sonata | Disk SMART monitoring | +| isc_dhcpd.py | Built-in | dns | DHCP pool usage | diff --git a/tools/cmk-plugins/qemu b/tools/cmk-plugins/qemu new file mode 100755 index 0000000..9499481 --- /dev/null +++ b/tools/cmk-plugins/qemu @@ -0,0 +1,37 @@ +#!/bin/bash + +# based upon 'qemu' from +# 12/2010 Matthias Henze +# Lizenz: GPL v2 +# +# updated for libvirtd (virsh) by +# Jonathan Mills 09/2011 +# +# updated by +# Christian Burmeister 05/2015 +# +# updated formating: +# Bastian Kuhn 08/2018 +# +# Update PID regexp: +# Albert Stefanov 10/2023 + +if which virsh >/dev/null; then + echo '<<>>' + virsh list | grep -v 'State' | grep -v '^--' | grep -v '^$' | while read L + do + ID=$(echo $L | awk '{print $1}') + NAME=$(echo $L | awk '{print $2}') + STATE=$(echo $L | awk '{print $3}') + MEM=$(virsh dominfo $NAME | grep 'Used memory' | awk '{print $3}') + let MEM=MEM/1024 + PID=$(pgrep -f -- "/qemu-system-x86_64 .*-name guest=$NAME") + if [ -n "$PID" ]; then + DATA=$(top -p $PID -n 1 -b | sed '${/^$/d}' | tail -1 | awk -- '{print $9" "$10}') + else + DATA="" + fi + echo $ID" "$NAME" "$STATE" "$MEM" "$DATA + done +fi +