This commit is contained in:
garnier-quentin 2020-07-27 10:32:22 +02:00
parent 0d8b52c436
commit d6168f3ac6
2 changed files with 59 additions and 52 deletions

View File

@ -34,40 +34,40 @@ sub set_counters {
]; ];
$self->{maps_counters}->{policy} = [ $self->{maps_counters}->{policy} = [
{ label => 'current-connections', set => { { label => 'current-connections', nlabel => 'policy.connections.current.count', set => {
key_values => [ { name => 'wgPolicyCurrActiveConns' }, { name => 'display' } ], key_values => [ { name => 'wgPolicyCurrActiveConns' }, { name => 'display' } ],
output_template => 'Current connections : %s', output_template => 'current connections: %s',
perfdatas => [ perfdatas => [
{ label => 'current_connections', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, { label => 'current_connections', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'total-connections', set => { { label => 'total-connections', nlabel => 'policy.connections.total.count', set => {
key_values => [ { name => 'wgPolicyActiveStreams', diff => 1 }, { name => 'display' } ], key_values => [ { name => 'wgPolicyActiveStreams', diff => 1 }, { name => 'display' } ],
output_template => 'Total connections : %s', output_template => 'total connections: %s',
perfdatas => [ perfdatas => [
{ label => 'total_connections', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, { label => 'total_connections', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'l3-traffic', set => { { label => 'l3-traffic', nlabel => 'policy.traffic.l3.bitspersecond', set => {
key_values => [ { name => 'wgPolicyL3PackageBytes', per_second => 1 }, { name => 'display' } ], key_values => [ { name => 'wgPolicyL3PackageBytes', per_second => 1 }, { name => 'display' } ],
output_template => 'L3 Traffic : %s %s/s', output_template => 'L3 traffic: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'traffic_l3', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'traffic_l3', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'l2-traffic', set => { { label => 'l2-traffic', nlabel => 'policy.traffic.l2.bitspersecond', set => {
key_values => [ { name => 'wgPolicyL2PackageBytes', per_second => 1 }, { name => 'display' } ], key_values => [ { name => 'wgPolicyL2PackageBytes', per_second => 1 }, { name => 'display' } ],
output_template => 'L2 Traffic : %s %s/s', output_template => 'L2 traffic: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'traffic_l2', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, { label => 'traffic_l2', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, }
]; ];
} }
@ -94,7 +94,7 @@ my $mapping = {
wgPolicyL3PackageBytes => { oid => '.1.3.6.1.4.1.3097.4.2.2.1.3' }, wgPolicyL3PackageBytes => { oid => '.1.3.6.1.4.1.3097.4.2.2.1.3' },
wgPolicyActiveStreams => { oid => '.1.3.6.1.4.1.3097.4.2.2.1.12' }, wgPolicyActiveStreams => { oid => '.1.3.6.1.4.1.3097.4.2.2.1.12' },
wgPolicyCurrActiveConns => { oid => '.1.3.6.1.4.1.3097.4.2.2.1.18' }, wgPolicyCurrActiveConns => { oid => '.1.3.6.1.4.1.3097.4.2.2.1.18' },
wgPolicyL2PackageBytes => { oid => '.1.3.6.1.4.1.3097.4.2.2.1.19' }, wgPolicyL2PackageBytes => { oid => '.1.3.6.1.4.1.3097.4.2.2.1.19' }
}; };
my $oid_wgPolicyEntry = '.1.3.6.1.4.1.3097.4.2.2.1'; my $oid_wgPolicyEntry = '.1.3.6.1.4.1.3097.4.2.2.1';
@ -108,9 +108,10 @@ sub manage_selection {
} }
$self->{policy} = {}; $self->{policy} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_wgPolicyEntry, my $snmp_result = $options{snmp}->get_table(
nothing_quit => 1); oid => $oid_wgPolicyEntry,
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{wgPolicyName}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{wgPolicyName}->{oid}\.(.*)$/);
@ -127,8 +128,12 @@ sub manage_selection {
if ($result->{wgPolicyCurrActiveConns} == 4294967295) { if ($result->{wgPolicyCurrActiveConns} == 4294967295) {
$result->{wgPolicyCurrActiveConns} = 0; $result->{wgPolicyCurrActiveConns} = 0;
} }
$self->{policy}->{$instance} = { display => $result->{wgPolicyName}, $result->{wgPolicyL3PackageBytes} *= 8;
$result->{wgPolicyL2PackageBytes} *= 8;
$self->{policy}->{$instance} = {
display => $result->{wgPolicyName},
%$result %$result
}; };
} }
@ -137,8 +142,8 @@ sub manage_selection {
$self->{output}->add_option_msg(short_msg => "No policy found."); $self->{output}->add_option_msg(short_msg => "No policy found.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
$self->{cache_name} = "watchguard_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{cache_name} = 'watchguard_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
} }

View File

@ -34,32 +34,32 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'connections', set => { { label => 'connections', nlabel => 'system.connections.current.count', set => {
key_values => [ { name => 'connections' } ], key_values => [ { name => 'connections' } ],
output_template => 'Current connections : %s', output_template => 'Current connections: %s',
perfdatas => [ perfdatas => [
{ label => 'current_connections', template => '%s', min => 0 }, { label => 'current_connections', template => '%s', min => 0 }
], ]
} }
}, },
{ label => 'in-traffic', set => { { label => 'in-traffic', nlabel => 'system.traffic.in.bitspersecond', set => {
key_values => [ { name => 'in_traffic', per_second => 1 } ], key_values => [ { name => 'in_traffic', per_second => 1 } ],
output_template => 'Traffic In : %s %s/s', output_template => 'Traffic in: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'traffic_in', template => '%s', min => 0, unit => 'b/s' }, { label => 'traffic_in', template => '%s', min => 0, unit => 'b/s' }
], ]
} }
}, },
{ label => 'out-traffic', set => { { label => 'out-traffic', nlabel => 'system.traffic.out.bitspersecond', set => {
key_values => [ { name => 'out_traffic', per_second => 1 } ], key_values => [ { name => 'out_traffic', per_second => 1 } ],
output_template => 'Traffic Out : %s %s/s', output_template => 'Traffic out: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'traffic_out', template => '%s', min => 0, unit => 'b/s' }, { label => 'traffic_out', template => '%s', min => 0, unit => 'b/s' }
], ]
} }
}, }
]; ];
} }
@ -78,20 +78,27 @@ sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
if ($options{snmp}->is_snmpv1()) { if ($options{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); $self->{output}->add_option_msg(short_msg => 'Need to use SNMP v2c or v3.');
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
my $oid_wgSystemTotalSendBytes = '.1.3.6.1.4.1.3097.6.3.8.0'; my $oid_wgSystemTotalSendBytes = '.1.3.6.1.4.1.3097.6.3.8.0';
my $oid_wgSystemTotalRecvBytes = '.1.3.6.1.4.1.3097.6.3.9.0'; my $oid_wgSystemTotalRecvBytes = '.1.3.6.1.4.1.3097.6.3.9.0';
my $oid_wgSystemCurrActiveConns = '.1.3.6.1.4.1.3097.6.3.80.0'; my $oid_wgSystemCurrActiveConns = '.1.3.6.1.4.1.3097.6.3.80.0';
my $snmp_result = $options{snmp}->get_leef(oids => [ my $snmp_result = $options{snmp}->get_leef(
oids => [
$oid_wgSystemTotalSendBytes, $oid_wgSystemTotalRecvBytes, $oid_wgSystemCurrActiveConns $oid_wgSystemTotalSendBytes, $oid_wgSystemTotalRecvBytes, $oid_wgSystemCurrActiveConns
], nothing_quit => 1); ],
nothing_quit => 1
);
$self->{global} = { out_traffic => $snmp_result->{$oid_wgSystemTotalSendBytes}, $self->{global} = {
in_traffic => $snmp_result->{$oid_wgSystemTotalRecvBytes}, connections => $snmp_result->{$oid_wgSystemCurrActiveConns} }; out_traffic => $snmp_result->{$oid_wgSystemTotalSendBytes} * 8,
$self->{cache_name} = "watchguard_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . in_traffic => $snmp_result->{$oid_wgSystemTotalRecvBytes} * 8,
connections => $snmp_result->{$oid_wgSystemCurrActiveConns}
};
$self->{cache_name} = 'watchguard_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
} }
@ -108,16 +115,11 @@ Check system statistics.
=item B<--filter-counters> =item B<--filter-counters>
Only display some counters (regexp can be used). Only display some counters (regexp can be used).
Example: --filter-counters='^(connections)$' Example: --filter-counters='^connections$'
=item B<--warning-*> =item B<--warning-*> B<--critical-*>
Threshold warning. Thresholds.
Can be: 'in-traffic', 'out-traffic', 'connections'.
=item B<--critical-*>
Threshold critical.
Can be: 'in-traffic', 'out-traffic', 'connections'. Can be: 'in-traffic', 'out-traffic', 'connections'.
=back =back