From 5935aed0db2ce8c31bf026600a3eabe3e69e9f75 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Mon, 21 Dec 2020 09:50:15 +0100 Subject: [PATCH] bundles/{netdata,pppd,radvd,vmhost,vnstat,wide-dhcp6c}: add monitoring --- bundles/netdata/metadata.py | 9 ++++++++ bundles/pppd/files/check_dyndns_update | 28 ++++++++++++++++++++++++ bundles/pppd/items.py | 3 +++ bundles/pppd/metadata.py | 30 ++++++++++++++++++++++++++ bundles/radvd/metadata.py | 9 ++++++++ bundles/vmhost/metadata.py | 3 +++ bundles/vnstat/metadata.py | 9 ++++++++ bundles/wide-dhcp6c/metadata.py | 9 ++++++++ 8 files changed, 100 insertions(+) create mode 100644 bundles/pppd/files/check_dyndns_update diff --git a/bundles/netdata/metadata.py b/bundles/netdata/metadata.py index 04ae1ee..01549e8 100644 --- a/bundles/netdata/metadata.py +++ b/bundles/netdata/metadata.py @@ -4,6 +4,15 @@ defaults = { 'netdata': {}, }, }, + 'icinga2_api': { + 'netdata': { + 'services': { + 'NETDATA PROCESS': { + 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C netdata -c 1:', + }, + }, + }, + }, } diff --git a/bundles/pppd/files/check_dyndns_update b/bundles/pppd/files/check_dyndns_update new file mode 100644 index 0000000..c9e6f4f --- /dev/null +++ b/bundles/pppd/files/check_dyndns_update @@ -0,0 +1,28 @@ +#!/bin/bash + +statusfile="/var/tmp/dyndns.monitoring" +if ! [[ -f "$statusfile" ]] +then + echo "Status file not found" + exit 3 +fi + +mtime=$(stat -c %Y $statusfile) +now=$(date +%s) +if (( $now - $mtime > 60*60*24*8 )) +then + echo "Status file is older than 8 days!" + exit 3 +fi + +statuscode=$(cat $statusfile) +case "$statuscode" in + 200) + echo "OK" + exit 0 + ;; + *) + echo "Last statuscode was $statuscode" + exit 2 + ;; +esac diff --git a/bundles/pppd/items.py b/bundles/pppd/items.py index 3f4395a..586c909 100644 --- a/bundles/pppd/items.py +++ b/bundles/pppd/items.py @@ -84,6 +84,9 @@ files = { '/usr/local/bin/restart-pppoe-if-no-public-ip': { 'mode': '0755', }, + '/usr/local/share/icinga/plugins/check_dyndns_update': { + 'mode': '0755', + }, } if 'dyndns' in node.metadata['pppd']: diff --git a/bundles/pppd/metadata.py b/bundles/pppd/metadata.py index ca29ca4..42ea384 100644 --- a/bundles/pppd/metadata.py +++ b/bundles/pppd/metadata.py @@ -11,4 +11,34 @@ defaults = { 'cron': { 'restart-pppoe-if-no-public-ip': '*/5 * * * * root /usr/local/bin/restart-pppoe-if-no-public-ip', }, + 'icinga2_api': { + 'pppd': { + 'services': { + 'PPPD PROCESS': { + 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C pppd -c 1:', + }, + 'PPPOE PROCESS': { + 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C pppoe -c 1:', + }, + }, + }, + }, } + + +@metadata_reactor +def icinga_dyndns(metadata): + if 'dyndns' not in metadata.get('pppd'): + return {} + + return { + 'icinga2_api': { + 'pppd': { + 'services': { + 'DYNDNS UPDATE': { + 'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_dyndns_update', + }, + }, + }, + }, + } diff --git a/bundles/radvd/metadata.py b/bundles/radvd/metadata.py index 1f7071c..9e72b7d 100644 --- a/bundles/radvd/metadata.py +++ b/bundles/radvd/metadata.py @@ -4,6 +4,15 @@ defaults = { 'radvd': {}, }, }, + 'icinga2_api': { + 'radvd': { + 'services': { + 'RADVD PROCESS': { + 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C radvd -c 1:', + }, + }, + }, + }, } if node.has_bundle('pppd'): diff --git a/bundles/vmhost/metadata.py b/bundles/vmhost/metadata.py index 2bd660e..8ac632d 100644 --- a/bundles/vmhost/metadata.py +++ b/bundles/vmhost/metadata.py @@ -10,6 +10,9 @@ defaults = { 'icinga2_api': { 'vmhost': { 'services': { + 'LIBVIRT PROCESS': { + 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C libvirtd -c 1:', + }, 'QEMU VM STATUS': { 'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_vm_status', 'vars.notification.mail': True, diff --git a/bundles/vnstat/metadata.py b/bundles/vnstat/metadata.py index ca26874..fba4e13 100644 --- a/bundles/vnstat/metadata.py +++ b/bundles/vnstat/metadata.py @@ -5,6 +5,15 @@ defaults = { 'vnstati': {}, }, }, + 'icinga2_api': { + 'vnstat': { + 'services': { + 'VNSTATD PROCESS': { + 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C vnstatd -c 1:', + }, + }, + }, + }, 'vnstat': { 'bandwidth': '1000', }, diff --git a/bundles/wide-dhcp6c/metadata.py b/bundles/wide-dhcp6c/metadata.py index 6811c0f..04495db 100644 --- a/bundles/wide-dhcp6c/metadata.py +++ b/bundles/wide-dhcp6c/metadata.py @@ -12,6 +12,15 @@ defaults = { ], }, }, + 'icinga2_api': { + 'wide-dhcp6c': { + 'services': { + 'WIDE-DHCP6CD PROCESS': { + 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C dhcp6c -c 1:', + }, + }, + }, + }, 'wide-dhcp6c': { 'subnet_len': '8', },