Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vpn.pm to add IPSec Tunnel Counter #5382

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ sub set_counters {
{ label => 'active_tunnels', template => '%d', min => 0, unit => 'tunnels', label_extra_instance => 1 }
]
}
},
{ label => 'ipsec_tunnels_count', nlabel => 'vpn.ipsec.tunnels.state.count', set => {
key_values => [ { name => 'ipsec_tunnels_count' } ],
output_template => 'IPSec tunnels state up: %s',
perfdatas => [
{ label => 'ipsec_tunnels_count', template => '%d', min => 0, unit => 'tunnels', label_extra_instance => 1 }
]
}
}
];

Expand Down Expand Up @@ -128,7 +136,7 @@ sub new {
'filter-vpn:s' => { name => 'filter_vpn' },
'filter-vdomain:s' => { name => 'filter_vdomain' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{state} eq "down"' }
'critical-status:s' => { name => 'critical_status', default => '' }
});

return $self;
Expand Down Expand Up @@ -186,6 +194,7 @@ sub manage_selection {

$self->{vd} = {};
my $duplicated = {};
my $ipsec_tunnels_counter = 0;
foreach my $oid (keys %{$snmp_result->{ $oid_fgVdEntName }}) {
$oid =~ /^$oid_fgVdEntName\.(.*)$/;
my $vdom_instance = $1;
Expand All @@ -203,7 +212,8 @@ sub manage_selection {
global => {
users => $result->{fgVpnSslStatsLoginUsers},
tunnels => $result->{fgVpnSslStatsActiveTunnels},
sessions => $result->{fgVpnSslStatsActiveWebSessions}
sessions => $result->{fgVpnSslStatsActiveWebSessions},
ipsec_tunnels_count => $ipsec_tunnels_counter
},
vpn => {},
};
Expand Down Expand Up @@ -238,8 +248,13 @@ sub manage_selection {
traffic_in => $result->{fgVpnTunEntInOctets} * 8,
traffic_out => $result->{fgVpnTunEntOutOctets} * 8
};
# count tunnels in state up
if ($self->{vd}->{$vdomain_name}->{vpn}->{$name}->{state} eq "up") {
$ipsec_tunnels_counter++;
};
}
}
$self->{vd}->{$vdomain_name}->{global}->{ipsec_tunnels_count} = $ipsec_tunnels_counter;
}
}

1;
Expand All @@ -258,11 +273,11 @@ Filter name with regexp. Can be ('vdomain', 'vpn')

=item B<--warning-*>

Warning on counters. Can be ('users', 'sessions', 'tunnels', 'traffic-in', 'traffic-out')
Warning on counters. Can be ('users', 'sessions', 'tunnels', 'traffic-in', 'traffic-out', 'ipsec_tunnels_count')

=item B<--critical-*>

Warning on counters. Can be ('users', 'sessions', 'tunnels', 'traffic-in', 'traffic-out')
Warning on counters. Can be ('users', 'sessions', 'tunnels', 'traffic-in', 'traffic-out', 'ipsec_tunnels_count'))

=item B<--warning-status>

Expand Down