Removed preprocessing on Gateways, added default for numeric values in openvpn_server_uservalue

master
Riccardo Bicelli 4 years ago
parent e1a7179b45
commit 99b054e243
  1. 31
      pfsense_zbx.php
  2. 29
      template_pfsense_active.xml
  3. 78
      template_pfsense_active_ovpn_user.xml

@ -191,7 +191,7 @@ function pfz_openvpn_server_userdiscovery(){
} }
// Get OpenVPN User Connected Value // Get OpenVPN User Connected Value
function pfz_openvpn_server_uservalue($unique_id, $valuekey){ function pfz_openvpn_server_uservalue($unique_id, $valuekey, $default=""){
$atpos=strpos($unique_id,'+'); $atpos=strpos($unique_id,'+');
$server_id = substr($unique_id,0,$atpos); $server_id = substr($unique_id,0,$atpos);
@ -202,12 +202,12 @@ function pfz_openvpn_server_uservalue($unique_id, $valuekey){
if($server['vpnid']==$server_id) { if($server['vpnid']==$server_id) {
foreach($server['conns'] as $conn) { foreach($server['conns'] as $conn) {
if ($conn['common_name']==$user_id){ if ($conn['common_name']==$user_id){
$value = $conn[$valuekey]; $value = $conn[$valuekey];
} }
} }
} }
} }
if ($value=="") $value = $default;
echo $value; echo $value;
} }
// OpenVPN Client Discovery // OpenVPN Client Discovery
@ -230,7 +230,7 @@ function pfz_openvpn_clientdiscovery() {
} }
function pfz_openvpn_clientvalue($client_id, $valuekey){ function pfz_openvpn_clientvalue($client_id, $valuekey, $default="none"){
$clients = openvpn_get_active_clients(); $clients = openvpn_get_active_clients();
foreach($clients as $client) { foreach($clients as $client) {
if($client['vpnid']==$client_id) if($client['vpnid']==$client_id)
@ -245,7 +245,7 @@ function pfz_openvpn_clientvalue($client_id, $valuekey){
} }
if ($value=="") $value="none"; if ($value=="") $value=$default;
echo $value; echo $value;
} }
@ -370,8 +370,12 @@ function pfz_gw_discovery() {
function pfz_gw_value($gw, $valuekey) { function pfz_gw_value($gw, $valuekey) {
$gws = return_gateways_status(true); $gws = return_gateways_status(true);
if(array_key_exists($gw,$gws)) if(array_key_exists($gw,$gws)) {
echo $gws[$gw][$valuekey]; $value = $gws[$gw][$valuekey];
if ($valuekey=="status")
$value = pfz_valuemap("gateway.status", $value);
echo $value;
}
} }
@ -469,6 +473,16 @@ function pfz_valuemap($valuename, $value){
"server_tls" => "3", "server_tls" => "3",
"server_user" => "4", "server_user" => "4",
"server_tls_user" => "5"); "server_tls_user" => "5");
break;
case "gateway.status":
$valuemap = array(
"none" => "0",
"loss" => "1",
"highdelay" => "2",
"highloss" => "3",
"force_down" => "4",
"down" => "5");
break; break;
} }
@ -519,6 +533,9 @@ switch (strtolower($argv[1])){
case "openvpn_server_uservalue": case "openvpn_server_uservalue":
pfz_openvpn_server_uservalue($argv[2],$argv[3]); pfz_openvpn_server_uservalue($argv[2],$argv[3]);
break; break;
case "openvpn_server_uservalue_numeric":
pfz_openvpn_server_uservalue($argv[2],$argv[3],"0");
break;
case "openvpn_clientvalue": case "openvpn_clientvalue":
pfz_openvpn_clientvalue($argv[2],$argv[3]); pfz_openvpn_clientvalue($argv[2],$argv[3]);
break; break;

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<zabbix_export> <zabbix_export>
<version>4.0</version> <version>4.0</version>
<date>2020-04-28T07:21:17Z</date> <date>2020-07-11T12:27:03Z</date>
<groups> <groups>
<group> <group>
<name>Templates</name> <name>Templates/Network Devices</name>
</group> </group>
</groups> </groups>
<templates> <templates>
@ -17,7 +17,7 @@ Version 1.0.1&#13;
https://github.com/rbicelli/pfsense-zabbix-template</description> https://github.com/rbicelli/pfsense-zabbix-template</description>
<groups> <groups>
<group> <group>
<name>Templates</name> <name>Templates/Network Devices</name>
</group> </group>
</groups> </groups>
<applications> <applications>
@ -3240,18 +3240,7 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<name>pfSense Gateway Status</name> <name>pfSense Gateway Status</name>
</valuemap> </valuemap>
<logtimefmt/> <logtimefmt/>
<preprocessing> <preprocessing/>
<step>
<type>5</type>
<params>(.*)
\1:none=0:loss=1:highdelay=2:highloss=3:force_down=4:down=5</params>
</step>
<step>
<type>5</type>
<params>(none|loss|highdelay|highloss|force_down|down)(?=.*:\1=(\d))
\2</params>
</step>
</preprocessing>
<jmx_endpoint/> <jmx_endpoint/>
<timeout>3s</timeout> <timeout>3s</timeout>
<url/> <url/>
@ -3425,8 +3414,8 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<graph_prototypes> <graph_prototypes>
<graph_prototype> <graph_prototype>
<name>Gateway {#GATEWAY} Availability</name> <name>Gateway {#GATEWAY} Availability</name>
<width>640</width> <width>900</width>
<height>480</height> <height>200</height>
<yaxismin>0.0000</yaxismin> <yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax> <yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period> <show_work_period>1</show_work_period>
@ -3469,8 +3458,8 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
</graph_prototype> </graph_prototype>
<graph_prototype> <graph_prototype>
<name>Gateway {#GATEWAY} Status</name> <name>Gateway {#GATEWAY} Status</name>
<width>640</width> <width>900</width>
<height>480</height> <height>200</height>
<yaxismin>0.0000</yaxismin> <yaxismin>0.0000</yaxismin>
<yaxismax>5.0000</yaxismax> <yaxismax>5.0000</yaxismax>
<show_work_period>1</show_work_period> <show_work_period>1</show_work_period>
@ -5180,7 +5169,7 @@ or&#13;
<expression>{Template pfSense Active:pfsense.value[system,new_version_available].last()}=1</expression> <expression>{Template pfSense Active:pfsense.value[system,new_version_available].last()}=1</expression>
<recovery_mode>0</recovery_mode> <recovery_mode>0</recovery_mode>
<recovery_expression/> <recovery_expression/>
<name>New verson of pfSense Available on {HOST.NAME}</name> <name>New Version of pfSense Available on {HOST.NAME}</name>
<correlation_mode>0</correlation_mode> <correlation_mode>0</correlation_mode>
<correlation_tag/> <correlation_tag/>
<url/> <url/>

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<zabbix_export> <zabbix_export>
<version>4.0</version> <version>4.0</version>
<date>2020-04-28T07:22:36Z</date> <date>2020-07-11T12:27:51Z</date>
<groups> <groups>
<group> <group>
<name>Templates</name> <name>Templates/Network devices</name>
</group> </group>
</groups> </groups>
<templates> <templates>
@ -20,7 +20,7 @@ Version 1.0.1&#13;
https://github.com/rbicelli/pfsense-zabbix-template</description> https://github.com/rbicelli/pfsense-zabbix-template</description>
<groups> <groups>
<group> <group>
<name>Templates</name> <name>Templates/Network devices</name>
</group> </group>
</groups> </groups>
<applications> <applications>
@ -183,18 +183,18 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<master_item/> <master_item/>
</item_prototype> </item_prototype>
<item_prototype> <item_prototype>
<name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Client ID</name> <name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Connection Time</name>
<type>7</type> <type>7</type>
<snmp_community/> <snmp_community/>
<snmp_oid/> <snmp_oid/>
<key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},client_id]</key> <key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},connect_time_unix]</key>
<delay>120s</delay> <delay>60s</delay>
<history>0</history> <history>180d</history>
<trends>0</trends> <trends>0</trends>
<status>0</status> <status>0</status>
<value_type>3</value_type> <value_type>3</value_type>
<allowed_hosts/> <allowed_hosts/>
<units/> <units>unixtime</units>
<snmpv3_contextname/> <snmpv3_contextname/>
<snmpv3_securityname/> <snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_securitylevel>0</snmpv3_securitylevel>
@ -210,7 +210,7 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<publickey/> <publickey/>
<privatekey/> <privatekey/>
<port/> <port/>
<description>Client ID</description> <description>Client Connect Time</description>
<inventory_link>0</inventory_link> <inventory_link>0</inventory_link>
<applications> <applications>
<application> <application>
@ -243,18 +243,18 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<master_item/> <master_item/>
</item_prototype> </item_prototype>
<item_prototype> <item_prototype>
<name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Connection Time</name> <name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Remote Host</name>
<type>7</type> <type>7</type>
<snmp_community/> <snmp_community/>
<snmp_oid/> <snmp_oid/>
<key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},connect_time_unix]</key> <key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},remote_host]</key>
<delay>60s</delay> <delay>60s</delay>
<history>180d</history> <history>0</history>
<trends>0</trends> <trends>0</trends>
<status>0</status> <status>0</status>
<value_type>3</value_type> <value_type>4</value_type>
<allowed_hosts/> <allowed_hosts/>
<units>unixtime</units> <units/>
<snmpv3_contextname/> <snmpv3_contextname/>
<snmpv3_securityname/> <snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_securitylevel>0</snmpv3_securitylevel>
@ -270,7 +270,7 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<publickey/> <publickey/>
<privatekey/> <privatekey/>
<port/> <port/>
<description>Client Connect Time</description> <description>Remote Host</description>
<inventory_link>0</inventory_link> <inventory_link>0</inventory_link>
<applications> <applications>
<application> <application>
@ -303,16 +303,16 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<master_item/> <master_item/>
</item_prototype> </item_prototype>
<item_prototype> <item_prototype>
<name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Peer ID</name> <name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: User Name</name>
<type>7</type> <type>7</type>
<snmp_community/> <snmp_community/>
<snmp_oid/> <snmp_oid/>
<key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},peer_id]</key> <key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},user_name]</key>
<delay>60s</delay> <delay>60s</delay>
<history>0</history> <history>0</history>
<trends>0</trends> <trends>0</trends>
<status>0</status> <status>0</status>
<value_type>3</value_type> <value_type>4</value_type>
<allowed_hosts/> <allowed_hosts/>
<units/> <units/>
<snmpv3_contextname/> <snmpv3_contextname/>
@ -330,7 +330,7 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<publickey/> <publickey/>
<privatekey/> <privatekey/>
<port/> <port/>
<description>Peer ID</description> <description>Client User Name</description>
<inventory_link>0</inventory_link> <inventory_link>0</inventory_link>
<applications> <applications>
<application> <application>
@ -363,13 +363,13 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<master_item/> <master_item/>
</item_prototype> </item_prototype>
<item_prototype> <item_prototype>
<name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Remote Host</name> <name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Virtual IP Address (IPv6)</name>
<type>7</type> <type>7</type>
<snmp_community/> <snmp_community/>
<snmp_oid/> <snmp_oid/>
<key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},remote_host]</key> <key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},virtual_addr6]</key>
<delay>60s</delay> <delay>60s</delay>
<history>0</history> <history>90d</history>
<trends>0</trends> <trends>0</trends>
<status>0</status> <status>0</status>
<value_type>4</value_type> <value_type>4</value_type>
@ -390,7 +390,7 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<publickey/> <publickey/>
<privatekey/> <privatekey/>
<port/> <port/>
<description>Remote Host</description> <description>IPv6 Address assigned from OpenVPN Server</description>
<inventory_link>0</inventory_link> <inventory_link>0</inventory_link>
<applications> <applications>
<application> <application>
@ -423,13 +423,13 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<master_item/> <master_item/>
</item_prototype> </item_prototype>
<item_prototype> <item_prototype>
<name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: User Name</name> <name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Virtual IP Address</name>
<type>7</type> <type>7</type>
<snmp_community/> <snmp_community/>
<snmp_oid/> <snmp_oid/>
<key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},user_name]</key> <key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},virtual_addr]</key>
<delay>60s</delay> <delay>60s</delay>
<history>0</history> <history>180d</history>
<trends>0</trends> <trends>0</trends>
<status>0</status> <status>0</status>
<value_type>4</value_type> <value_type>4</value_type>
@ -450,7 +450,7 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<publickey/> <publickey/>
<privatekey/> <privatekey/>
<port/> <port/>
<description>Client User Name</description> <description>IP Address assigned from OpenVPN Server</description>
<inventory_link>0</inventory_link> <inventory_link>0</inventory_link>
<applications> <applications>
<application> <application>
@ -483,16 +483,16 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<master_item/> <master_item/>
</item_prototype> </item_prototype>
<item_prototype> <item_prototype>
<name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Virtual IP Address (IPv6)</name> <name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Client ID</name>
<type>7</type> <type>7</type>
<snmp_community/> <snmp_community/>
<snmp_oid/> <snmp_oid/>
<key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},virtual_addr6]</key> <key>pfsense.value[openvpn_server_uservalue_numeric,{#UNIQUEID},client_id]</key>
<delay>180s</delay> <delay>120s</delay>
<history>90d</history> <history>0</history>
<trends>0</trends> <trends>0</trends>
<status>0</status> <status>0</status>
<value_type>4</value_type> <value_type>3</value_type>
<allowed_hosts/> <allowed_hosts/>
<units/> <units/>
<snmpv3_contextname/> <snmpv3_contextname/>
@ -510,7 +510,7 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<publickey/> <publickey/>
<privatekey/> <privatekey/>
<port/> <port/>
<description>IPv6 Address assigned from OpenVPN Server</description> <description>Client ID</description>
<inventory_link>0</inventory_link> <inventory_link>0</inventory_link>
<applications> <applications>
<application> <application>
@ -543,16 +543,16 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<master_item/> <master_item/>
</item_prototype> </item_prototype>
<item_prototype> <item_prototype>
<name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Virtual IP Address</name> <name>OpenVPN Server {#SERVERNAME}, Client {#USERID}: Peer ID</name>
<type>7</type> <type>7</type>
<snmp_community/> <snmp_community/>
<snmp_oid/> <snmp_oid/>
<key>pfsense.value[openvpn_server_uservalue,{#UNIQUEID},virtual_addr]</key> <key>pfsense.value[openvpn_server_uservalue_numeric,{#UNIQUEID},peer_id]</key>
<delay>30s</delay> <delay>60s</delay>
<history>180d</history> <history>0</history>
<trends>0</trends> <trends>0</trends>
<status>0</status> <status>0</status>
<value_type>4</value_type> <value_type>3</value_type>
<allowed_hosts/> <allowed_hosts/>
<units/> <units/>
<snmpv3_contextname/> <snmpv3_contextname/>
@ -570,7 +570,7 @@ https://github.com/rbicelli/pfsense-zabbix-template</description>
<publickey/> <publickey/>
<privatekey/> <privatekey/>
<port/> <port/>
<description>IP Address assigned from OpenVPN Server</description> <description>Peer ID</description>
<inventory_link>0</inventory_link> <inventory_link>0</inventory_link>
<applications> <applications>
<application> <application>

Loading…
Cancel
Save