This commit is contained in:
qgarnier 2020-09-07 16:21:13 +02:00 committed by GitHub
parent fd845dff88
commit d2579dfba4
13 changed files with 98 additions and 75 deletions

View File

@ -26,7 +26,7 @@ use strict;
use warnings;
use centreon::plugins::misc;
use XML::Simple;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
my %map_node_state = (
0 => 'down',
@ -52,7 +52,7 @@ sub set_counters {
{ label => 'node', type => 2, critical_default => '%{state} !~ /up|clean/', set => {
key_values => [ { name => 'state' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_state_output'),
closure_custom_threshold_check => \&catalog_status_threshold,
closure_custom_threshold_check => \&catalog_status_threshold_ng,
closure_custom_perfdata => sub { return 0; }
}
}
@ -62,7 +62,7 @@ sub set_counters {
{ label => 'group', type => 2, critical_default => '%{state} !~ /starting|started/', set => {
key_values => [ { name => 'state' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_state_output'),
closure_custom_threshold_check => \&catalog_status_threshold,
closure_custom_threshold_check => \&catalog_status_threshold_ng,
closure_custom_perfdata => sub { return 0; }
}
}

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output {
my ($self, %options) = @_;
@ -50,7 +50,7 @@ sub set_counters {
key_values => [ { name => 'status' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'packets-delay', nlabel => 'gateway.packets.delay.milliseconds', set => {

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output {
my ($self, %options) = @_;
@ -69,7 +69,7 @@ sub set_counters {
key_values => [ { name => 'error' }, { name => 'service' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
];

View File

@ -21,7 +21,7 @@
package hardware::devices::polycom::dma::snmp::mode::clusters;
use base qw(centreon::plugins::templates::counter);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use strict;
use warnings;
@ -53,7 +53,7 @@ sub set_counters {
key_values => [ { name => 'cluster_status' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_cluster_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{

View File

@ -21,7 +21,7 @@
package hardware::devices::polycom::rprm::snmp::mode::clusterstatus;
use base qw(centreon::plugins::templates::counter);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use strict;
use warnings;
@ -38,14 +38,14 @@ sub set_counters {
key_values => [ { name => 'cluster_status' } ],
output_template => 'Current status %s',
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'cluster-change-cause', type => 2, set => {
key_values => [ { name => 'cluster_change_cause' } ],
output_template => 'Last change cause: %s',
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
];

View File

@ -21,7 +21,6 @@
package hardware::devices::polycom::rprm::snmp::mode::license;
use base qw(centreon::plugins::templates::counter);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use strict;
use warnings;

View File

@ -21,7 +21,7 @@
package hardware::devices::polycom::rprm::snmp::mode::provisioning;
use base qw(centreon::plugins::templates::counter);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use strict;
use warnings;
@ -38,7 +38,7 @@ sub set_counters {
key_values => [ { name => 'provisioning_status' } ],
closure_custom_output => $self->can('custom_provisioning_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'provisioning-failed', nlabel => 'rprm.provisioning.failed.count', set => {

View File

@ -21,7 +21,7 @@
package hardware::devices::polycom::rprm::snmp::mode::sitelinks;
use base qw(centreon::plugins::templates::counter);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use strict;
use warnings;
@ -48,7 +48,7 @@ sub set_counters {
key_values => [ { name => 'sitelink_status' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_sitelink_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'sitelink-active-calls', nlabel => 'rprm.sitelink.calls.active.count', set => {

View File

@ -21,7 +21,7 @@
package hardware::devices::polycom::rprm::snmp::mode::updates;
use base qw(centreon::plugins::templates::counter);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use strict;
use warnings;
@ -38,7 +38,7 @@ sub set_counters {
key_values => [ { name => 'updates_status' } ],
closure_custom_output => $self->can('custom_updates_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'updates-failed', nlabel => 'rprm.updates.failed.count', set => {

View File

@ -25,7 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output {
my ($self, %options) = @_;
@ -58,15 +58,14 @@ sub set_counters {
];
$self->{maps_counters}->{tunnels} = [
{ label => 'status', threshold => 0, set => {
{ label => 'status', type => 2, critical_default => '%{ike_phase1_state} eq "down" or %{state} ne "active"', set => {
key_values => [
{ name => 'state' }, { name => 'ike_phase1_state' },
{ name => 'monitor_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
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
];
@ -84,25 +83,11 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{ike_phase1_state} eq "down" or %{state} ne "active"' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(
macros => [
'unknown_status', 'warning_status', 'critical_status'
]
);
}
sub manage_selection {
my ($self, %options) = @_;

View File

@ -30,14 +30,14 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
$self->{modes} = {
'environment' => 'network::paloalto::ssh::mode::environment',
'ha' => 'network::paloalto::ssh::mode::ha',
'interfaces' => 'network::paloalto::ssh::mode::interfaces',
'ipsec' => 'network::paloalto::ssh::mode::ipsec',
'licenses' => 'network::paloalto::ssh::mode::licenses',
'system' => 'network::paloalto::ssh::mode::system'
);
};
$self->{custom_modes}{ssh} = 'network::paloalto::ssh::custom::cli';
return $self;

View File

@ -20,57 +20,81 @@
package network::stonesoft::snmp::mode::clusterstate;
use base qw(centreon::plugins::mode);
use base qw(centreon::plugins::templates::counter);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use strict;
use warnings;
my %oper_state = (
0 => ['unknown', 'UNKNOWN'],
1 => ['online', 'OK'],
2 => ['goingOnline', 'WARNING'],
3 => ['lockedOnline', 'WARNING'],
4 => ['goingLockedOnline', 'WARNING'],
5 => ['offline', 'CRITICAL'],
6 => ['goingOffline', 'CRITICAL'],
7 => ['lockedOffline', 'CRITICAL'],
8 => ['goingLockedOffline', 'CRITICAL'],
9 => ['standby', 'CRITICAL'],
10 => ['goingStandby', 'CRITICAL'],
);
sub custom_status_output {
my ($self, %options) = @_;
return sprintf(
"Node status is '%s' [Member id: %s]",
$self->{result_values}->{node_status},
$self->{result_values}->{node_member_id}
);
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 }
];
$self->{maps_counters}->{global} = [
{
label => 'status',
type => 2,
unknown_default => '%{node_status} =~ /unknown/i',
warning_default => '%{node_status} =~ /lockedOnline/i',
critical_default => '%{node_status} =~ /^(?:offline|goingOffline|lockedOffline|goingLockedOffline|standby|goingStandby)$/i',
set => {
key_values => [ { name => 'node_status' }, { name => 'node_member_id' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
]
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
my $map_oper_state = {
0 => 'unknown',
1 => 'online',
2 => 'goingOnline',
3 => 'lockedOnline',
4 => 'goingLockedOnline',
5 => 'offline',
6 => 'goingOffline',
7 => 'lockedOffline',
8 => 'goingLockedOffline',
9 => 'standby',
10 => 'goingStandby'
};
sub run {
sub manage_selection {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_nodeMemberId = '.1.3.6.1.4.1.1369.6.1.1.2.0';
my $oid_nodeOperState = '.1.3.6.1.4.1.1369.6.1.1.3.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_nodeMemberId, $oid_nodeOperState], nothing_quit => 1);
$self->{output}->output_add(severity => ${$oper_state{$result->{$oid_nodeOperState}}}[1],
short_msg => sprintf("Node status is '%s' [Member id : %s]",
${$oper_state{$result->{$oid_nodeOperState}}}[0],
$result->{$oid_nodeMemberId}));
$self->{output}->display();
$self->{output}->exit();
my $snmp_result = $options{snmp}->get_leef(oids => [$oid_nodeMemberId, $oid_nodeOperState], nothing_quit => 1);
$self->{global} = {
node_status => $map_oper_state->{ $snmp_result->{$oid_nodeOperState} },
node_member_id => $snmp_result->{$oid_nodeMemberId}
};
}
1;
@ -83,6 +107,21 @@ Check status of clustered node.
=over 8
=item B<--unknown-status>
Set unknown threshold for status (Default: '%{node_status} =~ /unknown/i').
Can used special variables like: %{node_status}, %{node_member_id}.
=item B<--warning-status>
Set warning threshold for status (Default: '%{node_status} =~ /lockedOnline/i').
Can used special variables like: %{node_status}, %{node_member_id}.
=item B<--critical-status>
Set critical threshold for status (Default: '%{node_status} =~ /^(?:offline|goingOffline|lockedOffline|goingLockedOffline|standby|goingStandby)$/i').
Can used special variables like: %{node_status}, %{node_member_id}.
=back
=cut

View File

@ -30,7 +30,7 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
$self->{modes} = {
'memory' => 'network::stonesoft::snmp::mode::memory',
'cpu' => 'network::stonesoft::snmp::mode::cpu',
'connections' => 'network::stonesoft::snmp::mode::connections',
@ -40,8 +40,8 @@ sub new {
'cluster-load' => 'network::stonesoft::snmp::mode::clusterload',
'rejected-packets' => 'network::stonesoft::snmp::mode::rejectedpackets',
'dropped-packets' => 'network::stonesoft::snmp::mode::droppedpackets',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
);
'list-interfaces' => 'snmp_standard::mode::listinterfaces'
};
return $self;
}