rbicelli / pfsense-zabbix-template

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

Repaired get_ipsecifnum. Working with pre 2.6 and 2.6 pfsense #118

Closed limosek closed 1 year ago

limosek commented 2 years ago

Hi. Just repaired main script so it supports older and newer pfsense versions. I have added zabbix6 directory with template saved from Zabbix 6.

There are new very important triggers: image

Because if connection is not working, it was not visible.

limosek commented 2 years ago

Thanks to Steffen Schiffel for initial idea!

minenordlicht commented 2 years ago

Good job, It is woking for me ( Zabbix 6.0 & pfSense 2.6)

minenordlicht commented 2 years ago

ipsec status is not working properly for me, I have 2 tunnels but

php /root/scripts/pfsense_zbx.php ipsec_ph1 1 status php /root/scripts/pfsense_zbx.php ipsec_ph1 2 status

both are returning always 0 regardless if tunnel is connected or disconnected

minenordlicht commented 2 years ago

get_ipsecifnum function does not exist in my system, so I modified your code by adding: $conmap[$cname] = $ph1ent['ikeid']; to function pfz_ipsec_status:

function pfz_ipsec_status($ikeid,$reqid=-1,$valuekey='state'){

    require_once("ipsec.inc");
    global $config;
    init_config_arr(array('ipsec', 'phase1'));

    $a_phase1 = &$config['ipsec']['phase1'];
    $conmap = array();
    foreach ($a_phase1 as $ph1ent) {
        if (function_exists('get_ipsecifnum')) {
        if (get_ipsecifnum($ph1ent['ikeid'], 0)) {
            $cname = "con" . get_ipsecifnum($ph1ent['ikeid'], 0);
        } else {
            $cname = "con{$ph1ent['ikeid']}00000";
        }
        $conmap[$cname] = $ph1ent['ikeid'];
    } else{
        $cname = ipsec_conid($ph1ent);
        $conmap[$cname] = $ph1ent['ikeid'];
    }
    }

....

gcortese22 commented 2 years ago

Hi, I added $conmap[$cname] = $ph1ent['ikeid']; like you wrote, now it's work as well about ipsec phase1 status but doesn't work to about ipsec phase 2 status. Do you have any idea? Thanks