enhance colubris snmp ap-usage mode
This commit is contained in:
parent
2543a56b14
commit
d6dc18a085
|
@ -30,7 +30,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = 'Operational State : ' . $self->{result_values}->{state};
|
my $msg = 'operational state: ' . $self->{result_values}->{state};
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ sub set_counters {
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'total-ap', set => {
|
{ label => 'total-ap', set => {
|
||||||
key_values => [ { name => 'total_ap' } ],
|
key_values => [ { name => 'total_ap' } ],
|
||||||
output_template => 'Total AP : %s',
|
output_template => 'total AP: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'total_ap', value => 'total_ap_absolute', template => '%s', min => 0 },
|
{ label => 'total_ap', value => 'total_ap_absolute', template => '%s', min => 0 },
|
||||||
],
|
],
|
||||||
|
@ -61,7 +61,7 @@ sub set_counters {
|
||||||
},
|
},
|
||||||
{ label => 'total-users', set => {
|
{ label => 'total-users', set => {
|
||||||
key_values => [ { name => 'total_users' } ],
|
key_values => [ { name => 'total_users' } ],
|
||||||
output_template => 'Total Users : %s',
|
output_template => 'total users: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'total_users', value => 'total_users_absolute', template => '%s', min => 0 },
|
{ label => 'total_users', value => 'total_users_absolute', template => '%s', min => 0 },
|
||||||
],
|
],
|
||||||
|
@ -80,7 +80,7 @@ sub set_counters {
|
||||||
},
|
},
|
||||||
{ label => 'ap-users', set => {
|
{ label => 'ap-users', set => {
|
||||||
key_values => [ { name => 'users' }, { name => 'display' } ],
|
key_values => [ { name => 'users' }, { name => 'display' } ],
|
||||||
output_template => 'Current Users: %s',
|
output_template => 'current users: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'ap_users', value => 'users_absolute', template => '%s',
|
{ label => 'ap_users', value => 'users_absolute', template => '%s',
|
||||||
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
@ -102,9 +102,10 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-name:s' => { name => 'filter_name' },
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
'warning-ap-status:s' => { name => 'warning_ap_status', default => '' },
|
'check-device-without-ctrl' => { name => 'check_device_without_ctrl' },
|
||||||
'critical-ap-status:s' => { name => 'critical_ap_status', default => '%{state} eq "disconnected"' },
|
'warning-ap-status:s' => { name => 'warning_ap_status', default => '' },
|
||||||
|
'critical-ap-status:s' => { name => 'critical_ap_status', default => '%{state} eq "disconnected"' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -123,8 +124,9 @@ my %map_device_state = (
|
||||||
);
|
);
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
coDevDisState => { oid => '.1.3.6.1.4.1.8744.5.23.1.2.1.1.5', map => \%map_device_state },
|
coDevDisState => { oid => '.1.3.6.1.4.1.8744.5.23.1.2.1.1.5', map => \%map_device_state },
|
||||||
coDevDisSystemName => { oid => '.1.3.6.1.4.1.8744.5.23.1.2.1.1.6' },
|
coDevDisSystemName => { oid => '.1.3.6.1.4.1.8744.5.23.1.2.1.1.6' },
|
||||||
|
coDevDisControllerIndex => { oid => '.1.3.6.1.4.1.8744.5.23.1.2.1.1.11' },
|
||||||
};
|
};
|
||||||
|
|
||||||
my $mapping2 = {
|
my $mapping2 = {
|
||||||
|
@ -137,29 +139,43 @@ sub manage_selection {
|
||||||
$self->{cache_name} = "colubris_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
$self->{cache_name} = "colubris_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
||||||
(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'));
|
||||||
|
|
||||||
|
my $oid_coDeviceDiscoveryEntry = '.1.3.6.1.4.1.8744.5.23.1.2.1.1';
|
||||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||||
oids => [
|
oids => [
|
||||||
{ oid => $mapping->{coDevDisState}->{oid} },
|
{ oid => $oid_coDeviceDiscoveryEntry, start => $mapping->{coDevDisState}->{oid}, end => $mapping->{coDevDisSystemName}->{oid} },
|
||||||
{ oid => $mapping->{coDevDisSystemName}->{oid} },
|
{ oid => $mapping->{coDevDisControllerIndex}->{oid} },
|
||||||
{ oid => $mapping2->{coDevWirCliStaMACAddress}->{oid} },
|
{ oid => $mapping2->{coDevWirCliStaMACAddress}->{oid} },
|
||||||
],
|
],
|
||||||
nothing_quit => 1,
|
nothing_quit => 1,
|
||||||
return_type => 1
|
return_type => 1
|
||||||
);
|
);
|
||||||
|
|
||||||
$self->{ap} = {};
|
|
||||||
$self->{global} = { total_ap => 0, total_users => 0 };
|
$self->{global} = { total_ap => 0, total_users => 0 };
|
||||||
foreach my $oid (sort keys %{$snmp_result}) {
|
$self->{ap} = {};
|
||||||
|
my @oids = $options{snmp}->oid_lex_sort(keys %$snmp_result);
|
||||||
|
my $checked = {};
|
||||||
|
foreach my $oid (reverse @oids) {
|
||||||
next if ($oid !~ /^$mapping->{coDevDisSystemName}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{coDevDisSystemName}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
$result->{coDevDisSystemName} !~ /$self->{option_results}->{filter_name}/) {
|
$result->{coDevDisSystemName} !~ /$self->{option_results}->{filter_name}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{coDevDisSystemName} . "': no matching filter.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{coDevDisSystemName} . "': no matching filter.", debug => 1);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
if (!defined($self->{option_results}->{check_device_without_ctrl})) {
|
||||||
|
if ($result->{coDevDisControllerIndex} == 0) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{coDevDisSystemName} . "': no controller associated.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (defined($checked->{$result->{coDevDisSystemName}})) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{coDevDisSystemName} . "': duplicated name.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$checked->{$result->{coDevDisSystemName}} = 1;
|
||||||
$self->{global}->{total_ap}++;
|
$self->{global}->{total_ap}++;
|
||||||
$self->{ap}->{$instance} = {
|
$self->{ap}->{$instance} = {
|
||||||
display => $result->{coDevDisSystemName},
|
display => $result->{coDevDisSystemName},
|
||||||
|
@ -167,17 +183,17 @@ sub manage_selection {
|
||||||
users => 0,
|
users => 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $oid (sort keys %{$snmp_result}) {
|
foreach my $oid (sort keys %$snmp_result) {
|
||||||
next if ($oid !~ /^$mapping2->{coDevWirCliStaMACAddress}->{oid}\.(.*?)\./);
|
next if ($oid !~ /^$mapping2->{coDevWirCliStaMACAddress}->{oid}\.(.*?)\./);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
|
|
||||||
next if (!defined($self->{ap}->{$instance}));
|
next if (!defined($self->{ap}->{$instance}));
|
||||||
|
|
||||||
$self->{global}->{total_users}++;
|
$self->{global}->{total_users}++;
|
||||||
$self->{ap}->{$instance}->{users}++;
|
$self->{ap}->{$instance}->{users}++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{ap}}) <= 0) {
|
if (scalar(keys %{$self->{ap}}) <= 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "No access point found.");
|
$self->{output}->add_option_msg(short_msg => "No access point found.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
@ -198,6 +214,10 @@ Check AP status and users connected.
|
||||||
|
|
||||||
Filter ap name with regexp.
|
Filter ap name with regexp.
|
||||||
|
|
||||||
|
=item B<--check-device-without-ctrl>
|
||||||
|
|
||||||
|
Check device even if it doesn't belongs to an controller team.
|
||||||
|
|
||||||
=item B<--warning-*>
|
=item B<--warning-*>
|
||||||
|
|
||||||
Threshold warning.
|
Threshold warning.
|
||||||
|
|
Loading…
Reference in New Issue