Rather simple script. Using log file instead of management interface.
Part has to run as Root (due to Munin most likely not having access to read the log files. Working with the management interface could solve this.
#!/bin/bash echo "VPN.value `cat /var/log/openvpn-status.log | sed -e '1,/Common Name/d' | sed -e '/ROUTING TABLE/,$d' | wc -l`" > /tmp/.vpn_munin.txt
You can change the name of VPN.value to the VPN name and/or add multiple lines (each with a different NAME.value if you’re running more than one VPN user. Be sure to cat the right log file).
chmod +x /usr/local/bin/getVpnUsers.sh
Add this to root cron:
*/5 * * * * /usr/local/bin/getVpnUsers.sh >/dev/null 2>&1
Now create /etc/munin/plugins/vpnusers:
#!/bin/sh case $1 in config) cat <<'EOM' graph_category network graph_title oVPN users graph_vlabel users VPN.label My oVPN # add more labels like this: #isazi.label Isazi VPN EOM exit 0;; esac cat /tmp/.vpn_munin.txt
chmod +x /etc/munin/plugins/vpnusers
You’ll need the correct NAME.label in the plugin depending on the name you choose in part one.
And restart munin-node:
Check your Munin under “network”. It might take ~15+ minutes before the graph is generated.