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

High Availability gateway trigger fix for site to site VPN #178

Open
wants to merge 3 commits 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
11 changes: 11 additions & 0 deletions pfsense_zbx.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
require_once('functions.inc');
require_once('config.inc');
require_once('util.inc');
require_once('gwlb.inc');

//For Interfaces Discovery
require_once('interfaces.inc');
Expand Down Expand Up @@ -538,6 +539,13 @@ function pfz_gw_discovery() {
echo $json_string;
}

function pfz_gw_config($gw, $valuekey) {
$gws = return_gateways_array();
if(array_key_exists($gw,$gws)) {
$value = $gws[$gw][$valuekey];
}
echo $value;
}

function pfz_gw_value($gw, $valuekey) {
$gws = return_gateways_status(true);
Expand Down Expand Up @@ -1600,6 +1608,9 @@ function pfz_discovery($section){
case "discovery":
pfz_discovery($argv[2]);
break;
case "gw_config":
pfz_gw_config($argv[2],$argv[3]);
break;
case "gw_value":
pfz_gw_value($argv[2],$argv[3]);
break;
Expand Down
42 changes: 40 additions & 2 deletions zabbix5/template_pfsense_active.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,45 @@ last(/Template pfSense Active/pfsense.value[cert_hash_secbits, {#CERT_INDEX}])&l
</preprocessing>
</item_prototype>
<item_prototype>
<name>Gateway $2 Packet Loss</name>
<name>Gateway $2 Interface</name>
<type>ZABBIX_ACTIVE</type>
<key>pfsense.value[gw_value,{#GATEWAY},interface]</key>
<delay>0</delay>
<value_type>CHAR</value_type>
<applications>
<application>
<name>Gateways</name>
</application>
</applications>
</item_prototype>
<item_prototype>
<name>Gateway $2 OpenVPN Server</name>
<type>DEPENDENT</type>
<key>pfsense.value[gw_value,{#GATEWAY},vpnserver]</key>
<delay>0</delay>
<description>VPN server number. 0 if not an OpenVPN interface.</description>
<applications>
<application>
<name>Gateways</name>
</application>
</applications>
<preprocessing>
<step>
<type>REGEX</type>
<parameters>
<parameter>ovpns([0-9]+?)</parameter>
<parameter>\1</parameter>
</parameters>
<error_handler>CUSTOM_VALUE</error_handler>
<error_handler_params>0</error_handler_params>
</step>
</preprocessing>
<master_item>
<key>pfsense.value[gw_config,{#GATEWAY},interface]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Gateway $2 Packet Loss</name>
<type>ZABBIX_ACTIVE</type>
<key>pfsense.value[gw_value,{#GATEWAY},loss]</key>
<delay>60s</delay>
Expand Down Expand Up @@ -1094,7 +1132,7 @@ last(/Template pfSense Active/pfsense.value[cert_hash_secbits, {#CERT_INDEX}])&l
<description>Gateway is lagging</description>
</trigger_prototype>
<trigger_prototype>
<expression>{last()}=3</expression>
<expression>{last()}=3 and ( last(/Template pfSense Active/pfsense.value[gw_config,{#GATEWAY},vpnserver]) =0 or last(/Template pfSense Active/pfsense.value[carp_status])=1)</expression>
<name>High packet Loss on {#GATEWAY}</name>
<priority>HIGH</priority>
<description>High Packet Loss on Gateway</description>
Expand Down
25 changes: 23 additions & 2 deletions zabbix6/pfsense_active.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,27 @@ zabbix_export:
delay: 300s
description: 'Gateway Discovery'
item_prototypes:
- uuid: 840cd51725f34428a90e15951827a56b
name: 'Gateway {#GATEWAY} Interface'
type: ZABBIX_ACTIVE
key: 'pfsense.value[gw_config,{#GATEWAY},interface]'
trends: '0'
value_type: CHAR
- uuid: a52580ae85f1444cb4d2c713e1cbd2fe
name: 'Gateway {#GATEWAY} OpenVPN Server'
type: DEPENDENT
key: 'pfsense.value[gw_config,{#GATEWAY},vpnserver]'
delay: '0'
description: 'VPN server number. 0 if not an OpenVPN interface.'
preprocessing:
- type: REGEX
parameters:
- 'ovpns([0-9]+?)'
- \1
error_handler: CUSTOM_VALUE
error_handler_params: '0'
master_item:
key: 'pfsense.value[gw_config,{#GATEWAY},interface]'
- uuid: db89e0dd738148e19c52f08bbc7723f7
name: 'Gateway {#GATEWAY} RTT'
type: ZABBIX_ACTIVE
Expand All @@ -850,7 +871,7 @@ zabbix_export:
- tag: Application
value: Gateways
- uuid: ba759ceb73f949108fddbc4029cfc9f2
name: 'Gateway {#GATEWAY} Packet Loss'
name: 'Gateway {#GATEWAY} Packet Loss'
type: ZABBIX_ACTIVE
key: 'pfsense.value[gw_value,{#GATEWAY},loss]'
delay: 60s
Expand Down Expand Up @@ -890,7 +911,7 @@ zabbix_export:
priority: WARNING
description: 'Gateway is lagging'
- uuid: a89a7d0dbd87432fa13ee7e4d15a4bdf
expression: 'avg(/Template pfSense Active/pfsense.value[gw_value,{#GATEWAY},status],#3)=3'
expression: 'avg(/Template pfSense Active/pfsense.value[gw_value,{#GATEWAY},status],#3)=3 and ( last(/Template pfSense Active/pfsense.value[gw_config,{#GATEWAY},vpnserver]) =0 or last(/Template pfSense Active/pfsense.value[carp_status])=1)'
name: 'High packet Loss on {#GATEWAY}'
priority: HIGH
description: 'High Packet Loss on Gateway'
Expand Down