Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update somes lines, but nothing all #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ Zabbix 3.0

Script for OpenVPN users monitoring.
It shows an OpenVPN user’s status, and its uplink and downlink traffic.
The “hosts” by the files certificates names are made using LLD.

Setup:

1) Copy the file discover_vpn.sh to any directory on the server were OpenVPN is(for example /etc/zabbix/scripts/discover_vpn.sh ). In this file specify the path to directory where OpenVPN certificates are (line №3).

2) Copy all lines from “zabbix_agentd.txt” file and paste to the end of zabbix agent config (/etc/zabbix/zabbix_agentd.conf). Probably, will be necessary to change the path to discover_vpn.sh.
2) Copy the file “openvpn.conf” to /etc/zabbix/zabbix_agentd.d/openvpn.conf. Probably, will be necessary to change the path to discover_vpn.sh, and make /etc/openvpn/ipp.txt readable to zabbix user.

3) Import openvpn.xml to zabbix template.

Expand Down
7 changes: 5 additions & 2 deletions zabbix_agentd.txt → openvpn.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
UserParameter=discovery.openvpn,/etc/zabbix/scripts/discover_vpn.sh
#Old
#UserParameter=discovery.openvpn,/etc/zabbix/scripts/discover_vpn.sh
#UserParameter=discovery.openvpn.ipp,/etc/zabbix/scripts/discover_vpn_ipp.sh # for discovery with ifconfig-pool-persist

UserParameter=discovery.openvpn,/etc/zabbix/scripts/discover_vpn_ipp.sh # for discovery with ifconfig-pool-persist
UserParameter=user_status.openvpn[*], cat /var/log/openvpn-status.log | grep $1 >/dev/null && echo 1 || echo 0
UserParameter=num_user.openvpn, cat /var/log/openvpn-status.log | sed -n '/Connected Since/,/ROUTING/p' | sed -e '1d' -e '$d' | wc -l
UserParameter=user_byte_received.openvpn[*], if [ "`grep -c $1 /var/log/openvpn-status.log`" != "0" ]; then cat /var/log/openvpn-status.log | grep $1 | tr "," "\n" | sed -n '3p' ; else echo "0" ; fi
UserParameter=user_byte_sent.openvpn[*], if [ "`grep -c $1 /var/log/openvpn-status.log`" != "0" ]; then cat /var/log/openvpn-status.log | grep $1 | tr "," "\n" | sed -n '4p' ; else echo "0" ; fi

UserParameter=discovery.openvpn.ipp,/etc/zabbix/scripts/discover_vpn_ipp.sh # for discovery with ifconfig-pool-persist
50 changes: 27 additions & 23 deletions openvpn.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.0</version>
<date>2016-04-12T15:13:40Z</date>
<date>2016-08-17T11:07:00Z</date>
<groups>
<group>
<name>_SET_Templates</name>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>OpenVPN</template>
<name>OpenVPN</name>
<template>Template App OpenVPN</template>
<name>Template App OpenVPN</name>
<description/>
<groups>
<group>
<name>_SET_Templates</name>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name>status</name>
<name>OpenVPN</name>
</application>
</applications>
<items>
<item>
<name>num_user</name>
<name>openvpn num_user</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
Expand Down Expand Up @@ -58,14 +58,18 @@
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications/>
<applications>
<application>
<name>OpenVPN</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
</items>
<discovery_rules>
<discovery_rule>
<name>vpn_user</name>
<name>openvpn vpn_user</name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
Expand Down Expand Up @@ -98,7 +102,7 @@
<description/>
<item_prototypes>
<item_prototype>
<name>byte_received {#VPNUSER}</name>
<name>openvpn byte_received {#VPNUSER}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
Expand Down Expand Up @@ -134,15 +138,15 @@
<inventory_link>0</inventory_link>
<applications>
<application>
<name>status</name>
<name>OpenVPN</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>byte_sent {#VPNUSER}</name>
<name>openvpn byte_sent {#VPNUSER}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
Expand Down Expand Up @@ -178,15 +182,15 @@
<inventory_link>0</inventory_link>
<applications>
<application>
<name>status</name>
<name>OpenVPN</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>user_status openvpn {#VPNUSER}</name>
<name>openvpn user_status openvpn {#VPNUSER}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
Expand Down Expand Up @@ -222,7 +226,7 @@
<inventory_link>0</inventory_link>
<applications>
<application>
<name>status</name>
<name>OpenVPN</name>
</application>
</applications>
<valuemap/>
Expand All @@ -233,7 +237,7 @@
<trigger_prototypes/>
<graph_prototypes>
<graph_prototype>
<name>byte_sent/received {#VPNUSER}</name>
<name>openvpn byte_sent/received {#VPNUSER}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
Expand All @@ -258,7 +262,7 @@
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>OpenVPN</host>
<host>Template App OpenVPN</host>
<key>user_byte_received.openvpn[{#VPNUSER}]</key>
</item>
</graph_item>
Expand All @@ -270,14 +274,14 @@
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>OpenVPN</host>
<host>Template App OpenVPN</host>
<key>user_byte_sent.openvpn[{#VPNUSER}]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
<graph_prototype>
<name>status openvpn {#VPNUSER}</name>
<name>OpenVPN Status {#VPNUSER}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
Expand All @@ -302,7 +306,7 @@
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>OpenVPN</host>
<host>Template App OpenVPN</host>
<key>user_status.openvpn[{#VPNUSER}]</key>
</item>
</graph_item>
Expand Down Expand Up @@ -337,7 +341,7 @@
<sort_triggers>0</sort_triggers>
<resource>
<key>num_user.openvpn</key>
<host>OpenVPN</host>
<host>Template App OpenVPN</host>
</resource>
<max_columns>3</max_columns>
<application/>
Expand All @@ -358,8 +362,8 @@
<dynamic>0</dynamic>
<sort_triggers>0</sort_triggers>
<resource>
<name>status openvpn {#VPNUSER}</name>
<host>OpenVPN</host>
<name>OpenVPN Status {#VPNUSER}</name>
<host>Template App OpenVPN</host>
</resource>
<max_columns>3</max_columns>
<application/>
Expand Down