diff --git a/pfsense_zbx.php b/pfsense_zbx.php index 23da440..d14dde5 100644 --- a/pfsense_zbx.php +++ b/pfsense_zbx.php @@ -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'); @@ -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); @@ -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; diff --git a/zabbix5/template_pfsense_active.xml b/zabbix5/template_pfsense_active.xml index d596f78..0a318e9 100644 --- a/zabbix5/template_pfsense_active.xml +++ b/zabbix5/template_pfsense_active.xml @@ -1043,7 +1043,45 @@ last(/Template pfSense Active/pfsense.value[cert_hash_secbits, {#CERT_INDEX}])&l - Gateway $2 Packet Loss + Gateway $2 Interface + ZABBIX_ACTIVE + pfsense.value[gw_value,{#GATEWAY},interface] + 0 + CHAR + + + Gateways + + + + + Gateway $2 OpenVPN Server + DEPENDENT + pfsense.value[gw_value,{#GATEWAY},vpnserver] + 0 + VPN server number. 0 if not an OpenVPN interface. + + + Gateways + + + + + REGEX + + ovpns([0-9]+?) + \1 + + CUSTOM_VALUE + 0 + + + + pfsense.value[gw_config,{#GATEWAY},interface] + + + + Gateway $2 Packet Loss ZABBIX_ACTIVE pfsense.value[gw_value,{#GATEWAY},loss] 60s @@ -1094,7 +1132,7 @@ last(/Template pfSense Active/pfsense.value[cert_hash_secbits, {#CERT_INDEX}])&l Gateway is lagging - {last()}=3 + {last()}=3 and ( last(/Template pfSense Active/pfsense.value[gw_config,{#GATEWAY},vpnserver]) =0 or last(/Template pfSense Active/pfsense.value[carp_status])=1) High packet Loss on {#GATEWAY} HIGH High Packet Loss on Gateway diff --git a/zabbix6/pfsense_active.yaml b/zabbix6/pfsense_active.yaml index 0079f19..9cf94f7 100644 --- a/zabbix6/pfsense_active.yaml +++ b/zabbix6/pfsense_active.yaml @@ -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 @@ -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 @@ -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'