enh(paloalto/snmp): mode sessions - add filter for vsys name (#2782)

This commit is contained in:
qgarnier 2021-05-11 08:46:51 +02:00 committed by GitHub
parent 970652b191
commit 7866300a6d
1 changed files with 29 additions and 14 deletions

View File

@ -63,6 +63,18 @@ sub custom_active_output {
);
}
sub prefix_global_output {
my ($self, %options) = @_;
return "Sessions ";
}
sub prefix_vsys_output {
my ($self, %options) = @_;
return "Vsys '" . $options{instance_value}->{display} . "' sessions ";
}
sub set_counters {
my ($self, %options) = @_;
@ -158,25 +170,14 @@ sub set_counters {
];
}
sub prefix_global_output {
my ($self, %options) = @_;
return "Sessions ";
}
sub prefix_vsys_output {
my ($self, %options) = @_;
return "Vsys '" . $options{instance_value}->{display} . "' sessions ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, force_new_perfdata => 1, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'add-vsys' => { name => 'add_vsys' },
'add-vsys' => { name => 'add_vsys' },
'filter-vsys-name:s' => { name => 'filter_vsys_name' }
});
return $self;
@ -214,6 +215,12 @@ sub add_vsys {
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping_vsys, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_vsys_name}) && $self->{option_results}->{filter_vsys_name} ne '' &&
$result->{display} !~ /$self->{option_results}->{filter_vsys_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{display} . "'.", debug => 1);
next;
}
$self->{vsys}->{$result->{display}} = $result;
$self->{vsys}->{$result->{display}}->{sessions_max} = 0 if (!defined($result->{sessions_max}));
$self->{vsys}->{$result->{display}}->{sessions_active_prct} = $result->{sessions_active} * 100 / $self->{vsys}->{$result->{display}}->{sessions_max}
@ -247,6 +254,14 @@ Check sessions.
=over 8
=item B<--add-vsys>
Monitor virtual systems.
=item B<--filter-vsys-name>
Filter virtual systems by name (can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds.