rbicelli / pfsense-zabbix-template

Zabbix Template for pfSense
Apache License 2.0
240 stars 107 forks source link

pfSense 22.05 - Openvpn Client 'status' value changed #126

Closed hvdhelm closed 4 months ago

hvdhelm commented 1 year ago

After upgrading my nodes to pfSense 22.05 the 'OpenVPN Client xyz UDP4 Tunnel Status' status value's changed. In earlier versions is was a simple value 'up' mapped in the php script with pfz_valuemap / openvpn.client.status to value 1. This will not work anymore in feature versions.

Old value: up New value: Connected (Success)

Zabbix Agent: 5.0.11

Output BEFORE upgrade (pfSense Plus 21.0.5.1)

OPENVPN Clients:
Array
(
    [0] => Array
        (
            [port] =>
            [name] => ABC
            [vpnid] => 1
            [mgmt] => client1
            [status] => up
            [connect_time] => Fri Oct 7 15:58:21 2022
            [virtual_addr] => 172.18.11.2
            [remote_host] => 77.243.xxx.xxx
            [remote_port] => 8051
            [local_host] => 213.124.yyy.yyy
            [local_port] => 22969
            [virtual_addr6] =>
            [bytes_recv] => 12185840
            [bytes_sent] => 4695844

        )

)

Output AFTER upgrade (pfSense Plus 22.05)

OPENVPN Clients:
Array
(
    [0] => Array
        (
            [port] =>
            [name] =>  ABC
            [vpnid] => 1
            [mgmt] => client1
            [status] => Connected (Success)
            [connect_time] => Fri Oct 7 16:14:54 2022
            [state] => CONNECTED
            [state_detail] => SUCCESS
            [virtual_addr] => 172.18.11.2
            [remote_host] => 77.243.xxx.xxx
            [remote_port] => 8051
            [local_host] => 213.124.yyy.yyy
            [local_port] => 51409
            [virtual_addr6] =>
            [bytes_recv] => 12221432
            [bytes_sent] => 4665136

        )

)
rbicelli commented 1 year ago

Please try pfsense_zbx.php with latest commit on develop. Will need other possible status descriptions in order to map correct values.

hvdhelm commented 1 year ago

Results with the pfsense_zbx.php on the develop branch, same result. I double checked if the php-file was updated.

[22.05-RELEASE][admin@dev]/root:  zabbix_get -s 127.0.0.1 -p 10050 -k "pfsense.value[openvpn_clientvalue,1,status]"
0
[22.05-RELEASE][admin@dev]/root:

Found the solution! Your code placed in the right mapping section. ;)

// Value mappings
// Each value map is represented by an associative array
function pfz_valuemap($valuename, $value, $default="0"){
     switch ($valuename){     

          case "openvpn.server.status":          
                    $valuemap = array(
                         "down" => "0",
                         "up" => "1",
                         "connected (success)" => "1",
                         "none" => "2",
                         "reconnecting; ping-restart" => "3",
                         "waiting" => "4",
                         "server_user_listening" => "5");          
          break;

          case "openvpn.client.status":          
                    $valuemap = array(
                         "up" => "1",
                         "connected (success)" => "1",
                         "down" => "0",
                         "none" => "0",
                         "reconnecting; ping-restart" => "2");          
          break;

Notice the case "openvpn.client.status": section.

[22.05-RELEASE][admin@dev]/root: zabbix_get -s 127.0.0.1 -p 10050 -k "pfsense.value[openvpn_clientvalue,1,status]"
1
[22.05-RELEASE][admin@dev]/root:

Now we have the right 1 value.

uuuusername1 commented 1 year ago

Hello, could you please specify what changes in value mapping helped exactly? I have tried manually adding this mapping into template, but tunnels that are up are still reported as down(their real status is Connected (Success)).