update panorama and fix gp-usage
This commit is contained in:
parent
aadc9e29bb
commit
26545d48bb
|
@ -91,11 +91,10 @@ sub manage_selection {
|
||||||
|
|
||||||
my $oid_panGPGWUtilizationMaxTunnels = '.1.3.6.1.4.1.25461.2.1.2.5.1.2.0';
|
my $oid_panGPGWUtilizationMaxTunnels = '.1.3.6.1.4.1.25461.2.1.2.5.1.2.0';
|
||||||
my $oid_panGPGWUtilizationActiveTunnels = '.1.3.6.1.4.1.25461.2.1.2.5.1.3.0';
|
my $oid_panGPGWUtilizationActiveTunnels = '.1.3.6.1.4.1.25461.2.1.2.5.1.3.0';
|
||||||
#my $snmp_result = $options{snmp}->get_leef(
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
# oids => [$oid_panGPGWUtilizationMaxTunnels, $oid_panGPGWUtilizationActiveTunnels],
|
oids => [$oid_panGPGWUtilizationMaxTunnels, $oid_panGPGWUtilizationActiveTunnels],
|
||||||
# nothing_quit => 1
|
nothing_quit => 1
|
||||||
#);
|
);
|
||||||
my $snmp_result = { $oid_panGPGWUtilizationMaxTunnels => 10000, $oid_panGPGWUtilizationActiveTunnels => 1000 };
|
|
||||||
|
|
||||||
my ($used, $total) = ($snmp_result->{$oid_panGPGWUtilizationActiveTunnels}, $snmp_result->{$oid_panGPGWUtilizationMaxTunnels});
|
my ($used, $total) = ($snmp_result->{$oid_panGPGWUtilizationActiveTunnels}, $snmp_result->{$oid_panGPGWUtilizationMaxTunnels});
|
||||||
|
|
||||||
|
|
|
@ -20,122 +20,83 @@
|
||||||
|
|
||||||
package network::paloalto::snmp::mode::panorama;
|
package network::paloalto::snmp::mode::panorama;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||||
|
|
||||||
my $thresholds = {
|
sub custom_status_output {
|
||||||
panorama => [
|
my ($self, %options) = @_;
|
||||||
['^connected$', 'OK'],
|
|
||||||
['^not-connected$', 'CRITICAL'],
|
return "connection status is '" . $self->{result_values}->{status} . "'";
|
||||||
],
|
}
|
||||||
};
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'pan', type => 1, cb_prefix_output => 'prefix_pan_output', message_multiple => 'All panorama connection statuses are ok', skipped_code => { -10 => 1 } },
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{pan} = [
|
||||||
|
{ label => 'status', threshold => 0, set => {
|
||||||
|
key_values => [ { name => 'status' }, { name => 'display' } ],
|
||||||
|
closure_custom_calc => \&catalog_status_calc,
|
||||||
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_pan_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "panorama '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /not-connected/i' },
|
||||||
"exclude:s" => { name => 'exclude' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_threshold_overload {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->{overload_th} = {};
|
|
||||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
|
||||||
if ($val !~ /^(.*?),(.*)$/) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
my ($section, $status, $filter) = ('panorama', $1, $2);
|
|
||||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
|
||||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::check_options(%options);
|
||||||
$self->check_threshold_overload();
|
|
||||||
|
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_exclude {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{instance} instance."));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub get_severity {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
my $status = 'UNKNOWN'; # default
|
|
||||||
|
|
||||||
if (defined($self->{overload_th}->{$options{section}})) {
|
|
||||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
|
||||||
if ($options{value} =~ /$_->{filter}/i) {
|
|
||||||
$status = $_->{status};
|
|
||||||
return $status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (@{$thresholds->{$options{section}}}) {
|
|
||||||
if ($options{value} =~ /$$_[0]/i) {
|
|
||||||
$status = $$_[1];
|
|
||||||
return $status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $status;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
|
|
||||||
my $oid_panMgmtPanoramaConnected = '.1.3.6.1.4.1.25461.2.1.2.4.1.0';
|
my $oid_panMgmtPanoramaConnected = '.1.3.6.1.4.1.25461.2.1.2.4.1.0';
|
||||||
my $oid_panMgmtPanorama2Connected = '.1.3.6.1.4.1.25461.2.1.2.4.2.0';
|
my $oid_panMgmtPanorama2Connected = '.1.3.6.1.4.1.25461.2.1.2.4.2.0';
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_panMgmtPanoramaConnected, $oid_panMgmtPanorama2Connected], nothing_quit => 1);
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
$self->{output}->output_add(severity => 'OK',
|
oids => [$oid_panMgmtPanoramaConnected, $oid_panMgmtPanorama2Connected],
|
||||||
short_msg => 'Panorama connection statuses are ok.');
|
nothing_quit => 1
|
||||||
if (!$self->check_exclude(section => 'panorama', instance => 1)) {
|
);
|
||||||
my $exit = $self->get_severity(section => 'panorama', value => $result->{$oid_panMgmtPanoramaConnected});
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("panorama '1' connection status is %s",
|
|
||||||
$result->{$oid_panMgmtPanoramaConnected}));
|
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => sprintf("panorama '1' connection status is %s",
|
|
||||||
$result->{$oid_panMgmtPanoramaConnected}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$self->check_exclude(section => 'panorama', instance => 2)) {
|
|
||||||
my $exit = $self->get_severity(section => 'panorama', value => $result->{$oid_panMgmtPanorama2Connected});
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("panorama '2' connection status is %s",
|
|
||||||
$result->{$oid_panMgmtPanorama2Connected}));
|
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => sprintf("panorama '2' connection status is %s",
|
|
||||||
$result->{$oid_panMgmtPanorama2Connected}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$self->{pan} = {
|
||||||
$self->{output}->display();
|
1 => {
|
||||||
$self->{output}->exit();
|
display => 1,
|
||||||
|
status => $snmp_result->{$oid_panMgmtPanoramaConnected},
|
||||||
|
},
|
||||||
|
2 => {
|
||||||
|
display => 2,
|
||||||
|
status => $snmp_result->{$oid_panMgmtPanorama2Connected},
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -148,15 +109,15 @@ Check panorama connection status.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--threshold-overload>
|
=item B<--warning-status>
|
||||||
|
|
||||||
Set to overload default threshold value.
|
Set warning threshold for status (Default: '').
|
||||||
Example: --threshold-overload='warning,(not-connected)'
|
Can used special variables like: %{status}, %{display}
|
||||||
|
|
||||||
=item B<--exclude>
|
=item B<--critical-status>
|
||||||
|
|
||||||
Exclude some parts (comma seperated list)
|
Set critical threshold for status (Default: '%{status} =~ /not-connected/i').
|
||||||
Can also exclude specific instance: --exclude=panorama#2#
|
Can used special variables like: %{status}, %{display}
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue