Graph amount of OpenVPN users to Munin

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.

Create /usr/local/bin/

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/

Add this to root cron:

*/5 * * * * /usr/local/bin/ >/dev/null 2>&1

Now create /etc/munin/plugins/vpnusers:


case $1 in
 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
 exit 0;;

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:

/etc/init.d/munin-node restart

That’s it.

Check your Munin under “network”. It might take ~15+ minutes before the graph is generated.


Leave a Reply...