Lukas Macura 2016-04-14 21:26:59 +02:00
parent 1ae74f8da9
commit 312b52dec4
2 changed files with 438 additions and 0 deletions

65
openvpn/control.zaf Normal file
View File

@ -0,0 +1,65 @@
Plugin: openvpn
Description::
Plugin for OpenVPN users monitoring. It shows an OpenVPN users status, and its uplink and downlink traffic. The “hosts” by the files certificates names are made using LLD.
::
Version: 0.1
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/psx
Web: https://github.com/Grifagor/zabbix-openvpn
Maintainer: Lukas Macura <lukas@macura.cz>
# Dependencies
Depends-dpkg: dash curl
Depens-opkg: busybox curl
Depends-rpm: curl
Depends-bin: curl ps
Item discovery_users:
Parameters: ccd_dir
Description::
Discovery of openvpn users
::
Script::
#!/bin/sh
. $ZAF_LIB_DIR/zaf.lib.sh
path="$1"
[ -z "$path" ] && zaf_error "Missing parameter path!"
ls -F $path | sed 's/\///g' | zaf_discovery '{#VPNUSER}'
::
/Item
Item user_status:
Parameters: user
Description::
User status
::
Cmd: cat /var/log/openvpn-status.log | grep "$1" >/dev/null && echo 1 || echo 0
/Item
Item num_users:
Description::
Number of users
::
Cmd: cat /var/log/openvpn-status.log | sed -n '/Connected Since/,/ROUTING/p' | sed -e '1d' -e '$d' | wc -l
/Item
Item user_received_bytes:
Description::
Number of bytes received by user
::
Parameters: user
Cmd: cat /var/log/openvpn-status.log | grep $1 | tr "," "\n" | sed -n '3p'
/Item
Item user_sent_bytes:
Description::
Number of bytes sent by user
::
Parameters: user
Cmd: cat /var/log/openvpn-status.log | grep "$1" | tr "," "\n" | sed -n '4p'
/Item

373
openvpn/template.xml Normal file
View File

@ -0,0 +1,373 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.0</version>
<date>2016-04-12T15:13:40Z</date>
<groups>
<group>
<name>_SET_Templates</name>
</group>
</groups>
<templates>
<template>
<template>OpenVPN</template>
<name>OpenVPN</name>
<description/>
<groups>
<group>
<name>_SET_Templates</name>
</group>
</groups>
<applications>
<application>
<name>status</name>
</application>
</applications>
<items>
<item>
<name>num_user</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>openvpn.num_users</key>
<delay>120</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications/>
<valuemap/>
<logtimefmt/>
</item>
</items>
<discovery_rules>
<discovery_rule>
<name>vpn_user</name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>openvpn.discovery_users</key>
<delay>60</delay>
<status>0</status>
<allowed_hosts/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<delay_flex/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>1</lifetime>
<description/>
<item_prototypes>
<item_prototype>
<name>byte_received {#VPNUSER}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>openvpn.user_received_bytes[{#VPNUSER}]</key>
<delay>120</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>b\s</units>
<delta>1</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>status</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>byte_sent {#VPNUSER}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>openvpn.user_sent_bytes[{#VPNUSER}]</key>
<delay>120</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>b\s</units>
<delta>1</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>status</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>user_status openvpn {#VPNUSER}</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>openvpn.user_status[{#VPNUSER}]</key>
<delay>120</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>status</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
</item_prototypes>
<trigger_prototypes/>
<graph_prototypes>
<graph_prototype>
<name>byte_sent/received {#VPNUSER}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>1A7C11</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>OpenVPN</host>
<key>openvpn.user_received_bytes[{#VPNUSER}]</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>0</drawtype>
<color>F63100</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>OpenVPN</host>
<key>openvpn.user_sent_bytes[{#VPNUSER}]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
<graph_prototype>
<name>status openvpn {#VPNUSER}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>1A7C11</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>OpenVPN</host>
<key>openvpn.user_status[{#VPNUSER}]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
</graph_prototypes>
<host_prototypes/>
</discovery_rule>
</discovery_rules>
<macros/>
<templates/>
<screens>
<screen>
<name>1OpenVPN</name>
<hsize>1</hsize>
<vsize>2</vsize>
<screen_items>
<screen_item>
<resourcetype>1</resourcetype>
<width>500</width>
<height>100</height>
<x>0</x>
<y>0</y>
<colspan>1</colspan>
<rowspan>1</rowspan>
<elements>0</elements>
<valign>0</valign>
<halign>0</halign>
<style>0</style>
<url/>
<dynamic>0</dynamic>
<sort_triggers>0</sort_triggers>
<resource>
<key>openvpn.num_users</key>
<host>OpenVPN</host>
</resource>
<max_columns>3</max_columns>
<application/>
</screen_item>
<screen_item>
<resourcetype>20</resourcetype>
<width>500</width>
<height>100</height>
<x>0</x>
<y>1</y>
<colspan>1</colspan>
<rowspan>1</rowspan>
<elements>0</elements>
<valign>0</valign>
<halign>0</halign>
<style>0</style>
<url/>
<dynamic>0</dynamic>
<sort_triggers>0</sort_triggers>
<resource>
<name>status openvpn {#VPNUSER}</name>
<host>OpenVPN</host>
</resource>
<max_columns>3</max_columns>
<application/>
</screen_item>
</screen_items>
</screen>
</screens>
</template>
</templates>
</zabbix_export>