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

View File

@ -24,7 +24,7 @@ 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); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -50,7 +50,7 @@ sub set_counters {
key_values => [ { name => 'status' }, { name => 'display' } ], key_values => [ { name => 'status' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_status_output'), closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; }, 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 => { { 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 strict;
use warnings; 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 { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -69,7 +69,7 @@ sub set_counters {
key_values => [ { name => 'error' }, { name => 'service' } ], key_values => [ { name => 'error' }, { name => 'service' } ],
closure_custom_output => $self->can('custom_status_output'), closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; }, 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; package hardware::devices::polycom::dma::snmp::mode::clusters;
use base qw(centreon::plugins::templates::counter); 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 strict;
use warnings; use warnings;
@ -53,7 +53,7 @@ sub set_counters {
key_values => [ { name => 'cluster_status' }, { name => 'display' } ], key_values => [ { name => 'cluster_status' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_cluster_status_output'), closure_custom_output => $self->can('custom_cluster_status_output'),
closure_custom_perfdata => sub { return 0; }, 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; package hardware::devices::polycom::rprm::snmp::mode::clusterstatus;
use base qw(centreon::plugins::templates::counter); 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 strict;
use warnings; use warnings;
@ -38,14 +38,14 @@ sub set_counters {
key_values => [ { name => 'cluster_status' } ], key_values => [ { name => 'cluster_status' } ],
output_template => 'Current status %s', output_template => 'Current status %s',
closure_custom_perfdata => sub { return 0; }, 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 => { { label => 'cluster-change-cause', type => 2, set => {
key_values => [ { name => 'cluster_change_cause' } ], key_values => [ { name => 'cluster_change_cause' } ],
output_template => 'Last change cause: %s', output_template => 'Last change cause: %s',
closure_custom_perfdata => sub { return 0; }, 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; package hardware::devices::polycom::rprm::snmp::mode::license;
use base qw(centreon::plugins::templates::counter); use base qw(centreon::plugins::templates::counter);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use strict; use strict;
use warnings; use warnings;

View File

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

View File

@ -21,7 +21,7 @@
package hardware::devices::polycom::rprm::snmp::mode::sitelinks; package hardware::devices::polycom::rprm::snmp::mode::sitelinks;
use base qw(centreon::plugins::templates::counter); 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 strict;
use warnings; use warnings;
@ -48,7 +48,7 @@ sub set_counters {
key_values => [ { name => 'sitelink_status' }, { name => 'display' } ], key_values => [ { name => 'sitelink_status' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_sitelink_status_output'), closure_custom_output => $self->can('custom_sitelink_status_output'),
closure_custom_perfdata => sub { return 0; }, 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 => { { 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; package hardware::devices::polycom::rprm::snmp::mode::updates;
use base qw(centreon::plugins::templates::counter); 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 strict;
use warnings; use warnings;
@ -38,7 +38,7 @@ sub set_counters {
key_values => [ { name => 'updates_status' } ], key_values => [ { name => 'updates_status' } ],
closure_custom_output => $self->can('custom_updates_status_output'), closure_custom_output => $self->can('custom_updates_status_output'),
closure_custom_perfdata => sub { return 0; }, 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 => { { 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 strict;
use warnings; use warnings;
use Digest::MD5 qw(md5_hex); 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 { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -58,15 +58,14 @@ sub set_counters {
]; ];
$self->{maps_counters}->{tunnels} = [ $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 => [ key_values => [
{ name => 'state' }, { name => 'ike_phase1_state' }, { name => 'state' }, { name => 'ike_phase1_state' },
{ name => 'monitor_status' }, { name => 'display' } { name => 'monitor_status' }, { name => 'display' }
], ],
closure_custom_calc => \&catalog_status_calc,
closure_custom_output => $self->can('custom_status_output'), closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; }, 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; bless $self, $class;
$options{options}->add_options(arguments => { $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; 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 { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;

View File

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

View File

@ -20,57 +20,81 @@
package network::stonesoft::snmp::mode::clusterstate; 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 strict;
use warnings; use warnings;
my %oper_state = ( sub custom_status_output {
0 => ['unknown', 'UNKNOWN'], my ($self, %options) = @_;
1 => ['online', 'OK'],
2 => ['goingOnline', 'WARNING'], return sprintf(
3 => ['lockedOnline', 'WARNING'], "Node status is '%s' [Member id: %s]",
4 => ['goingLockedOnline', 'WARNING'], $self->{result_values}->{node_status},
5 => ['offline', 'CRITICAL'], $self->{result_values}->{node_member_id}
6 => ['goingOffline', 'CRITICAL'], );
7 => ['lockedOffline', 'CRITICAL'], }
8 => ['goingLockedOffline', 'CRITICAL'],
9 => ['standby', 'CRITICAL'], sub set_counters {
10 => ['goingStandby', 'CRITICAL'], 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 { 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 => {
{ });
});
return $self; return $self;
} }
sub check_options { my $map_oper_state = {
my ($self, %options) = @_; 0 => 'unknown',
$self->SUPER::init(%options); 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) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_nodeMemberId = '.1.3.6.1.4.1.1369.6.1.1.2.0'; 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 $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); my $snmp_result = $options{snmp}->get_leef(oids => [$oid_nodeMemberId, $oid_nodeOperState], nothing_quit => 1);
$self->{global} = {
$self->{output}->output_add(severity => ${$oper_state{$result->{$oid_nodeOperState}}}[1], node_status => $map_oper_state->{ $snmp_result->{$oid_nodeOperState} },
short_msg => sprintf("Node status is '%s' [Member id : %s]", node_member_id => $snmp_result->{$oid_nodeMemberId}
${$oper_state{$result->{$oid_nodeOperState}}}[0], };
$result->{$oid_nodeMemberId}));
$self->{output}->display();
$self->{output}->exit();
} }
1; 1;
@ -83,6 +107,21 @@ Check status of clustered node.
=over 8 =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 =back
=cut =cut

View File

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