Value MApping Corrections

master
Riccardo Bicelli 4 years ago
parent 5f8f138e66
commit d45c3276c8
  1. 71
      README.md.backup
  2. 20
      pfsense_zbx.php
  3. 8
      template_pfsense_active.xml
  4. 9
      template_pfsense_active_ovpn_user.xml

@ -1,71 +0,0 @@
[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/rbicelli)
# pfSense Zabbix Template
This is a pfSense active template for Zabbix, based on Standard Agent and a php script using pfSense functions library for monitoring specific data.
From 28
Tested with pfSense 2.4.x and Zabbix 4.0
## What it does
**Template pfSense Active**
- Network interface Discovery and Monitoring with User Assigned Names
- Gateway Discovery and Monitoring (Gateway Status/RTT)
- OpenVPN Server Discovery and Monitoring (Server Status/Tunnel Status)
- OpenVPN Clients Discovery and Monitoring (Client Status/Tunnel Status)
- CARP Monitoring (Global CARP State)
- Basic Service Discovery and Monitoring (Service Status)
- pfSense Version/Update Available
**Template pfSense Active: OpenVPN Server User Auth**
- Discovery of OpenVPN Clients connected to OpenVPN Servers in user auth mode
- Monitoring of Client Parameters (Bytes sent/received, Connection Time...)
## 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 should 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.
## Credits
[Keenton Zabbix Template](https://github.com/keentonsas/zabbix-template-pfsense) for Zabbix Agent freeBSD part.

@ -128,8 +128,14 @@ function pfz_openvpn_servervalue($server_id,$valuekey){
$servers = pfz_openvpn_get_all_servers();
foreach($servers as $server) {
if($server['vpnid']==$server_id)
if($server['vpnid']==$server_id){
$value = $server[$valuekey];
if ($valuekey=="status") {
if ( ($server['mode']=="server_user") || ($server['mode']=="server_tls_user") ){
if ($value=="") $value="server_user_listening";
}
}
}
}
switch ($valuekey){
@ -143,6 +149,7 @@ function pfz_openvpn_servervalue($server_id,$valuekey){
break;
case "status":
$value = pfz_valuemap("openvpn.server.status", $value);
break;
@ -437,13 +444,14 @@ function pfz_valuemap($valuename, $value){
switch ($valuename){
case "openvpn.server.status":
if ($value=="") $value="none";
case "openvpn.server.status":
$valuemap = array(
"down" => "0",
"up" => "1",
"down" => "2",
"none" => "3",
"reconnecting; ping-restart" => "4");
"none" => "2",
"reconnecting; ping-restart" => "3",
"waiting" => "4",
"server_user_listening" => "5");
break;
case "openvpn.client.status":

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>4.0</version>
<date>2020-04-26T16:28:17Z</date>
<date>2020-04-28T07:21:17Z</date>
<groups>
<group>
<name>Templates</name>
@ -10,7 +10,7 @@
<templates>
<template>
<template>Template pfSense Active</template>
<name>Pfsense Active</name>
<name>pfsense Active</name>
<description>Active template for pfsense, requires pfsense_zbx.php installed to pfSense Box.&#13;
Version 1.0.1&#13;
&#13;
@ -5999,6 +5999,10 @@ or&#13;
<value>4</value>
<newvalue>Waiting</newvalue>
</mapping>
<mapping>
<value>5</value>
<newvalue>Up/Listening</newvalue>
</mapping>
</mappings>
</value_map>
<value_map>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>4.0</version>
<date>2020-04-27T22:05:29Z</date>
<date>2020-04-28T07:22:36Z</date>
<groups>
<group>
<name>Templates</name>
@ -12,7 +12,12 @@
<template>Template pfSense Active OpenVPN Server User Auth</template>
<name>pfSense Active: OpenVPN Server User Auth</name>
<description>Extension for pfSense Active Template.&#13;
Monitor client Connections of OpenVPN Server.</description>
Monitor client Connections of OpenVPN Server.&#13;
&#13;
Requires pfsense_zbx.php installed to pfSense Box.&#13;
Version 1.0.1&#13;
&#13;
https://github.com/rbicelli/pfsense-zabbix-template</description>
<groups>
<group>
<name>Templates</name>

Loading…
Cancel
Save