Stars: 201
Forks: 96
Pull Requests: 28
Issues: 122
Watchers: 33
Last Updated: 2023-07-18 09:14:28
Zabbix Template for pfSense
License: Apache License 2.0
Languages: PHP
This is a pfSense active template for Zabbix, based on Standard Agent and a php script using pfSense functions library for monitoring specific data.
Tested with pfSense 2.5.x, Zabbix 4.0, Zabbix 5.0, Zabbix 6.0
Template pfSense Active
Template pfSense Active: OpenVPN Server User Auth
Template pfSense Active: IPsec
Template pfSense Active: Speedtest
First copy the file pfsense_zbx.php to your pfsense box (e.g. to /root/scripts).
From Diagnostics/Command Prompt input this one-liner:
curl --create-dirs -o /root/scripts/pfsense_zbx.php https://raw.githubusercontent.com/rbicelli/pfsense-zabbix-template/master/pfsense_zbx.php
Then install package "Zabbix Agent 5" (or "Zabbix Agent 6") on your pfSense Box
In Advanced Features-> User Parameters
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 correctly execute OpenVPN checks and others.
Also increase the Timeout value at least to 5, otherwise some checks will fail.
Then import xml templates in Zabbix and add your pfSense hosts.
If you are running a redundant CARP setup you should adjust the macro {$EXPECTED_CARP_STATUS} to a value representing what is CARP expected status on monitored box.
Possible values are:
This is useful when monitoring services which could stay stopped on CARP Backup Member.
For running speedtests on WAN interfaces you have to install the speedtest package.
From Diagnostics/Command Prompt input this commands:
pkg update && pkg install -y py38-speedtest-cli
Speedtest python package could be broken at the moment, so you could need an extra step, only if manually executing speedtest results in an error: download the latest version from package author's github repo.
curl -Lo /usr/local/lib/python3.8/site-packages/speedtest.py https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
For testing if speedtest is installed properly you can try it:
/usr/local/bin/speedtest
Remember that you will need to install the package on every pfSense upgrade.
Speedtest template creates a cron job and check for entry everytime Zabbix requests its items. If you want to uninstall the cron jobs simply run, from Diagnostics/Command Prompt:
/url/local/bin/php /root/scripts/pfsense_zbx.php cron_cleanup
NOTE: When used in multiple gateways scenario, speedtest results are OK only with default gateway. This is a known behavior that must be fixed upstream.
Keenton Zabbix Template for Zabbix Agent freeBSD part.