From 52eeda2326b030c1fc9049b8ffd25ef335c6ea4b Mon Sep 17 00:00:00 2001 From: Riccardo Bicelli Date: Fri, 27 Mar 2020 17:24:21 +0100 Subject: [PATCH] Fixed OpenVPN Number of Connections --- README.md | 14 +++++++++++--- README.md.backup | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ pfsense_zbx.php | 2 +- 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 README.md.backup diff --git a/README.md b/README.md index cd9e2f8..c2d5b28 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pfSense Zabbix template -This is a pfSense active template for zabbix, based on [Keenton Zabbix Template](https://github.com/keentonsas/zabbix-template-pfsense) for freeBSD part and a php script using pfSense functions library for monitoring specific data. +This is a pfSense active template for Zabbix, based on [Keenton Zabbix Template](https://github.com/keentonsas/zabbix-template-pfsense) for freeBSD part and a php script using pfSense functions library for monitoring specific data. Tested with pfSense 2.4 and Zabbix 4.0 @@ -16,6 +16,14 @@ Tested with pfSense 2.4 and Zabbix 4.0 ## Configuration First copy the file pfsense_zbx.php to your pfsense box (e.g. to /root/scripts). + +For example, from pfSense shell: + +```bash +mkdir /root/scripts +curl -o /root/scripts/pfsense_zbx.php https://raw.githubusercontent.com/rbicelli/pfsense-zabbix-template/master/pfsense_zbx.php +``` + Then install package "Zabbix Agent 4" on your pfSense Box @@ -32,7 +40,7 @@ UserParameter=pfsense.discovery[*],/usr/local/bin/php /root/scripts/pfsense_zbx. UserParameter=pfsense.value[*],/usr/local/bin/php /root/scripts/pfsense_zbx.php $1 $2 $3 ``` -__Please note that **AllowRoot=1** option is required in order to execute correctly OpenVPN checks and others._ +_Please note that **AllowRoot=1** option is required in order to execute correctly OpenVPN checks and others._ Then import xml template in Zabbix and add your pfSense hosts. @@ -44,4 +52,4 @@ Possible values are: - 1: Master - 2: Backup -This is useful when monitoring services which could stay stopped on CARP Backup Member. \ No newline at end of file +This is useful when monitoring services which could stay stopped on CARP Backup Member. diff --git a/README.md.backup b/README.md.backup new file mode 100644 index 0000000..6b36d4b --- /dev/null +++ b/README.md.backup @@ -0,0 +1,55 @@ +# pfSense Zabbix template + +This is a pfSense active template for zabbix, based on [Keenton Zabbix Template](https://github.com/keentonsas/zabbix-template-pfsense) for freeBSD part and a php script using pfSense functions library for monitoring specific data. + +Tested with pfSense 2.4 and Zabbix 4.0 + +## What it does + + - pfSense Version/Update Available + - Gateway Monitoring (Gateway Status/RTT with discovery) + - OpenVPN Server Monitoring (Server Status/Tunnel Status with discovery) + - CARP Monitoring (Global CARP State) + - Basic service monitoring (Service Status with discovery) + + +## Configuration + +First copy the file pfsense_zbx.php to your pfsense box (e.g. to /root/scripts). + +For example, from pfSense shell: + +```bash +mkdir /root/scripts +curl -o /root/scripts/pfsense_zbx.php https://raw.githubusercontent.com/rbicelli/pfsense-zabbix-template/master/pfsense_zbx.php +``` + +Then install package "Zabbix Agent 4" on your pfSense Box + + +In Advanced Features-> User Parameters + +```bash +AllowRoot=1 +UserParameter=pfsense.states.max,grep "limit states" /tmp/rules.limits | cut -f4 -d ' ' +UserParameter=pfsense.states.current,grep "current entries" /tmp/pfctl_si_out | tr -s ' ' | cut -f4 -d ' ' +UserParameter=pfsense.mbuf.current,netstat -m | grep "mbuf clusters" | cut -f1 -d ' ' | cut -d '/' -f1 +UserParameter=pfsense.mbuf.cache,netstat -m | grep "mbuf clusters" | cut -f1 -d ' ' | cut -d '/' -f2 +UserParameter=pfsense.mbuf.max,netstat -m | grep "mbuf clusters" | cut -f1 -d ' ' | cut -d '/' -f4 +UserParameter=pfsense.discovery[*],/usr/local/bin/php /root/scripts/pfsense_zbx.php discovery $1 +UserParameter=pfsense.value[*],/usr/local/bin/php /root/scripts/pfsense_zbx.php $1 $2 $3 +``` + +__Please note that **AllowRoot=1** option is required in order to execute correctly OpenVPN checks and others._ + +Then import xml template in Zabbix and add your pfSense hosts. + +If you are running a redundant CARP setup you can adjust the macro {#EXPECTED_CARP_STATUS} to a value representing what is CARP expected status on monitored box. + +Possible values are: + + - 0: Disabled + - 1: Master + - 2: Backup + +This is useful when monitoring services which could stay stopped on CARP Backup Member. \ No newline at end of file diff --git a/pfsense_zbx.php b/pfsense_zbx.php index 456608a..6ee39a3 100644 --- a/pfsense_zbx.php +++ b/pfsense_zbx.php @@ -134,7 +134,7 @@ function pfz_openvpn_servervalue($server_id,$valuekey){ //Client Connections: isan array so it is sufficient to count elements if ($valuekey=="conns"){ - $value=count($conns); + $value=count($value); if ($value=="") $value="0"; }