From 4f2e1d7b8d21f1752b7d0c49f8e9ecf4fb3dd1d7 Mon Sep 17 00:00:00 2001 From: Niklas Yann Wettengel Date: Sat, 11 Sep 2021 14:56:47 +0200 Subject: [PATCH] munin wg peers --- .../files/munin/munin_wg_conf | 3 ++ .../files/munin/munin_wg_peers | 54 +++++++++++++++++++ .../tasks/install_munin.yml | 25 +++++++++ 3 files changed, 82 insertions(+) create mode 100644 roles/install_monitoring/files/munin/munin_wg_conf create mode 100755 roles/install_monitoring/files/munin/munin_wg_peers diff --git a/roles/install_monitoring/files/munin/munin_wg_conf b/roles/install_monitoring/files/munin/munin_wg_conf new file mode 100644 index 0000000..6bf6e8d --- /dev/null +++ b/roles/install_monitoring/files/munin/munin_wg_conf @@ -0,0 +1,3 @@ +[wg_peers_*] +user root +group root diff --git a/roles/install_monitoring/files/munin/munin_wg_peers b/roles/install_monitoring/files/munin/munin_wg_peers new file mode 100755 index 0000000..8aa9b87 --- /dev/null +++ b/roles/install_monitoring/files/munin/munin_wg_peers @@ -0,0 +1,54 @@ +#!/bin/sh +# -*- sh -*- + +: << =cut + +=head1 NAME + +wg_peers_ - Plugin to monitor wg peers + +=head1 CONFIGURATION + +Set user and group to have access + + [wg_peers_*] + user root + group root + +=head1 USAGE + +Link this plugin to /etc/munin/plugins/ + +After creating the links, restart munin-node. Don't forget to configure the plugin! + +=head1 AUTHORS + +Niklas Yann Wettengel + +=head1 LICENSE + +GPLv2 + +=head1 MAGIC MARKERS + + #%# family=manual + +=cut + +. "$MUNIN_LIBDIR/plugins/plugin.sh" + +myname=$(basename "$0" | sed 's/^wg_peers_//g') + +if [ "$1" = "config" ]; then + echo "graph_title wg${myname} peers" + echo "graph_info This graph shows the wg peers on this supernode" + echo "graph_args -l 0" + echo "graph_scale no" + echo "graph_vlabel peers count" + echo "graph_category wireguard" + echo "peers.label peers" + echo "peers.draw AREA" + exit 0 +fi + +echo "peers.value $(wg show wg${myname} peers | wc -l)" diff --git a/roles/install_monitoring/tasks/install_munin.yml b/roles/install_monitoring/tasks/install_munin.yml index 1a35928..0a95622 100644 --- a/roles/install_monitoring/tasks/install_munin.yml +++ b/roles/install_monitoring/tasks/install_munin.yml @@ -57,6 +57,31 @@ notify: restart munin-node when: "'fastd' in group_names" +- name: copy wg peers plugin + copy: + src: munin/munin_wg_peers + dest: /usr/lib/munin/plugins/wg_peers_ + mode: 0755 + notify: restart munin-node + when: "'fastd' in group_names" + +- name: copy wg peers plugin config + copy: + src: munin/munin_wg_conf + dest: /etc/munin/plugin-conf.d/wg + mode: 0644 + notify: restart munin-node + when: "'fastd' in group_names" + +- name: enable munin plugins for wg peers + file: + path: /etc/munin/plugins/wg_peers_{{ item.name }} + src: /usr/lib/munin/plugins/wg_peers_ + state: link + with_items: "{{ sites }}" + notify: restart munin-node + when: "'fastd' in group_names" + - name: copy dhcp-pool plugin copy: src: munin/munin_dhcp_pool_plugin