riskersen / Monitoring

Monitoring plugins wich are Nagios/icinga compatible
65 stars 112 forks source link

Fortigate SSLVpn with Vdom #57

Open dcec opened 3 years ago

dcec commented 3 years ago

with multiple vdom this code calculate only the vpn on first, example: SNMPv2-SMI::enterprises.12356.101.12.2.3.1.2.1 = Gauge32: 0 SNMPv2-SMI::enterprises.12356.101.12.2.3.1.2.2 = Gauge32: 0 SNMPv2-SMI::enterprises.12356.101.12.2.3.1.2.3 = Gauge32: 2

with this change working fine for me:

# Unless specifically requesting IPSec checks only, do an SSL connection check
  if ($vpnmode ne "ipsec"){
    my $oid_ActiveSSL         = ".1.3.6.1.4.1.12356.101.12.2.3.1.2.";  # Location of Fortinet firewall SSL VPN Tunnel connection count
    my $oid_ActiveSSLTunnel   = ".1.3.6.1.4.1.12356.101.12.2.3.1.6.";  # Location of Fortinet firewall SSL VPN Tunnel connection count
    my $oidf_fgVdNumber       = ".1.3.6.1.4.1.12356.101.3.1.1.0";      # Vdom number
    $ActiveVdom = get_snmp_value($session, $oidf_fgVdNumber);
    for (my $i = 1; $i < $ActiveVdom+1; $i++) {
        $ActiveSSL += get_snmp_value($session, $oid_ActiveSSL.$i);
        $ActiveSSLTunnel += get_snmp_value($session, $oid_ActiveSSLTunnel.$i);
    }
  }
dcec commented 3 years ago

or with get_snmp_table:

my $oid_ActiveSSL         = ".1.3.6.1.4.1.12356.101.12.2.3.1.2";  # Location of Fortinet firewall SSL VPN Tunnel connection count
    my $oid_ActiveSSLTunnel   = ".1.3.6.1.4.1.12356.101.12.2.3.1.6";  # Location of Fortinet firewall SSL VPN Tunnel connection count
    my %ActiveSSL_table = %{get_snmp_table($session, $oid_ActiveSSL)};
    my %ActiveSSLTunnel_table = %{get_snmp_table($session, $oid_ActiveSSLTunnel)};
    my $k;
    foreach $k (keys(%ActiveSSL_table)) {
      $ActiveSSL += $ActiveSSL_table{$k};
    }     
    foreach $k (keys(%ActiveSSLTunnel_table)) {
      $ActiveSSLTunnel += $ActiveSSLTunnel_table{$k};
    }`
riskersen commented 3 years ago

Would you mind to create a pull request?