WIP: factoring with status catalog function (network parts)

This commit is contained in:
garnier-quentin 2019-01-15 11:59:12 +01:00
parent 4040a0c295
commit 505de51edc
34 changed files with 136 additions and 1404 deletions

View File

@ -22,6 +22,10 @@ package centreon::plugins::templates::catalog_functions;
use strict;
use warnings;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(catalog_status_threshold);
sub catalog_status_threshold {
my ($self, %options) = @_;

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -80,7 +55,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'current-con', set => {
@ -150,18 +125,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
my %map_status = (

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -79,7 +54,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'in-sessions-rate', set => {
@ -149,18 +124,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
my %map_status = (

View File

@ -24,34 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
my $label = $self->{label};
$label =~ s/-/_/g;
if (defined($instance_mode->{option_results}->{'critical_' . $label}) && $instance_mode->{option_results}->{'critical_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'critical_' . $label}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{'warning_' . $label}) && $instance_mode->{option_results}->{'warning_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'warning_' . $label}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -134,7 +107,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -159,18 +132,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_replication_status', 'critical_replication_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_replication_status', 'critical_replication_status']);
}
sub manage_selection {

View File

@ -26,32 +26,7 @@ use strict;
use warnings;
use centreon::plugins::misc;
use centreon::plugins::statefile;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -88,7 +63,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -118,8 +93,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
if (defined($self->{option_results}->{memory})) {
$self->{statefile_cache}->check_options(%options);
}
@ -127,16 +101,6 @@ sub check_options {
$self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq '');
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_type = (
0 => 'undefined', 5 => 'terminalLoopback', 6 => 'oosDisabled', 7 => 'oosManagement', 8 => 'oosMaintenance', 9 => 'oosAins', 10 => 'removed',
11 => 'lossOfSignal', 12 => 'optInputPwrReceivedTooLow', 13 => 'optInputPwrReceivedTooHigh', 14 => 'laserTemperatureTooHigh', 15 => 'laserTemperatureTooLow', 16 => 'optOutputPowerTransTooLow', 17 => 'optOutputPowerTransTooHigh',

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -82,7 +57,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'avg-calls', set => {
@ -135,8 +110,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_vpn_output {
@ -145,16 +119,6 @@ sub prefix_vpn_output {
return "Trunk '" . $options{instance_value}->{display} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_alarm = (0 => 'greyDisabled', 1 => 'greenActive', 2 => 'redLosLof',
3 => 'blueAis', 4 => 'yellowRai', 5 => 'orangeDChannel', 6 => 'purpleLowerLayerDown', 7 => 'darkOrangeNFASAlarm');
my %map_dchannel = (0 => 'dChannelEstablished', 1 => 'dChannelNotEstablished', 10 => 'dChannelNotApplicable');

View File

@ -24,30 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -75,7 +52,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -97,22 +74,11 @@ sub new {
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach ('warning_status', 'critical_status') {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
my %map_status = (

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -80,7 +55,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -106,8 +81,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_vpn_output {
@ -116,16 +90,6 @@ sub prefix_vpn_output {
return "VPN '" . $options{instance_value}->{display} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_type = (1 => 'regular', 2 => 'permanent');
my %map_state = (3 => 'active', 4 => 'destroy', 129 => 'idle', 130 => 'phase1',
131 => 'down', 132 => 'init'

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -95,7 +70,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -120,18 +95,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
my %map_failover = (

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -80,7 +55,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -131,8 +106,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_ccm_output {
@ -141,16 +115,6 @@ sub prefix_ccm_output {
return "CCM '" . $options{instance_value}->{ccmName} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %mapping_status = (1 => 'unknown', 2 => 'up', 3 => 'down');
my $mapping = {

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -80,7 +55,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -127,8 +102,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_gateway_output {
@ -143,16 +117,6 @@ sub prefix_global_output {
return "Total ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %mapping_status = (
1 => 'unknown', 2 => 'registered', 3 => 'unregistered',
4 => 'rejected', 5 => 'partiallyregistered',

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -80,7 +55,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -127,8 +102,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_md_output {
@ -143,16 +117,6 @@ sub prefix_global_output {
return "Total ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %mapping_status = (
1 => 'unknown', 2 => 'registered', 3 => 'unregistered',
4 => 'rejected', 5 => 'partiallyregistered',

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -81,7 +56,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -128,8 +103,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_phone_output {
@ -144,16 +118,6 @@ sub prefix_global_output {
return "Total ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %mapping_status = (
1 => 'unknown', 2 => 'registered', 3 => 'unregistered',
4 => 'rejected', 5 => 'partiallyregistered',

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_threshold_output {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -76,10 +51,10 @@ sub custom_traffic_perfdata {
}
my ($warning, $critical);
if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1);
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1);
} elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') {
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label});
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label});
}
@ -95,9 +70,9 @@ sub custom_traffic_threshold {
my ($self, %options) = @_;
my $exit = 'ok';
if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
} elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') {
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
}
return $exit;
@ -126,9 +101,9 @@ sub custom_traffic_calc {
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
my $diff_traffic = $options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label}} - $options{old_datas}->{$self->{instance} . '_' . $self->{result_values}->{label}};
$self->{result_values}->{traffic} = $diff_traffic / $options{delta_time};
if (defined($instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}}) && $instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} =~ /[0-9]/) {
$self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / ($instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000);
$self->{result_values}->{speed} = $instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000;
if (defined($self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}}) && $self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} =~ /[0-9]/) {
$self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / ($self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000);
$self->{result_values}->{speed} = $self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000;
}
return 0;
}
@ -158,7 +133,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_threshold_output'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'clients', set => {
@ -218,8 +193,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_device_output {
@ -234,16 +208,6 @@ sub prefix_interface_output {
return "Interface '" . $options{instance_value}->{display} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_status = (
0 => 'offline',
1 => 'online',

View File

@ -26,32 +26,7 @@ use strict;
use warnings;
use centreon::plugins::misc;
use centreon::plugins::statefile;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_ap_status}) && $instance_mode->{option_results}->{critical_ap_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_ap_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_ap_status}) && $instance_mode->{option_results}->{warning_ap_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_ap_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -99,7 +74,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'ap-clients', set => {
@ -168,8 +143,7 @@ sub check_options {
$self->SUPER::check_options(%options);
$self->{statefile_cache_ap}->check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_ap_status', 'critical_ap_status']);
}
sub prefix_controller_output {
@ -184,16 +158,6 @@ sub prefix_ap_output {
return "Access point '" . $options{instance_value}->{name} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_ap_status', 'critical_ap_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub manage_selection {
my ($self, %options) = @_;

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -133,12 +108,12 @@ sub set_counters {
},
];
$self->{maps_counters}->{calls} = [
{ label => 'state', set => {
{ label => 'status', set => {
key_values => [ { name => 'State' }, { name => 'Duration' }, { name => 'SerialNumber' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -171,22 +146,11 @@ sub new {
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub manage_selection {

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -82,7 +57,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -228,22 +203,11 @@ sub new {
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub manage_selection {

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -137,7 +112,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'calls-count', set => {
@ -180,22 +155,11 @@ sub new {
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub manage_selection {

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -71,14 +46,14 @@ sub custom_usage_perfdata {
my $label = 'used';
my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) {
if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = 'free';
$value_perf = $self->{result_values}->{free};
}
my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
@ -95,10 +70,10 @@ sub custom_usage_threshold {
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
@ -143,7 +118,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'usage', set => {
@ -179,8 +154,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_sr_output {
@ -189,16 +163,6 @@ sub prefix_sr_output {
return "Storage repository '" . $options{instance_value}->{display} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my $mapping = {
srName => { oid => '.1.3.6.1.4.1.5951.6.2.1000.4.1.1' },
srUtilized => { oid => '.1.3.6.1.4.1.5951.6.2.1000.4.1.5' },

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold_output {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -68,30 +43,6 @@ sub custom_status_calc {
return 0;
}
sub custom_tech_threshold_output {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_technology}) && $instance_mode->{option_results}->{critical_technology} ne '' &&
eval "$instance_mode->{option_results}->{critical_technology}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_technology}) && $instance_mode->{option_results}->{warning_technology} ne '' &&
eval "$instance_mode->{option_results}->{warning_technology}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_tech_output {
my ($self, %options) = @_;
my $msg;
@ -128,7 +79,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold_output'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'technology', threshold => 0, set => {
@ -136,7 +87,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_tech_calc'),
closure_custom_output => $self->can('custom_tech_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_tech_threshold_output'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -163,18 +114,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status', 'warning_technology', 'critical_technology' )) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_status', 'critical_status', 'warning_technology', 'critical_technology']);
}
my %map_gprs_registration = (

View File

@ -24,8 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub set_counters {
my ($self, %options) = @_;
@ -42,7 +41,7 @@ sub set_counters {
closure_custom_calc_extra_options => { output_label => 'Status', name_status => 'videoInputStatus' },
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -53,38 +52,12 @@ sub set_counters {
closure_custom_calc_extra_options => { output_label => 'Status', name_status => 'videoInputGroupStatus' },
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
}
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
my $label = $self->{label};
$label =~ s/-/_/g;
if (defined($instance_mode->{option_results}->{'critical_' . $label}) && $instance_mode->{option_results}->{'critical_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'critical_' . $label}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{'warning_' . $label}) && $instance_mode->{option_results}->{'warning_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'warning_' . $label}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = $self->{result_values}->{output_label} . ' : ' . $self->{result_values}->{status};
@ -122,18 +95,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_audio_status', 'critical_audio_status', 'warning_video_status', 'critical_video_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_audio_status', 'critical_audio_status', 'warning_video_status', 'critical_video_status']);
}
sub prefix_video_output {

View File

@ -24,8 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub set_counters {
my ($self, %options) = @_;
@ -40,38 +39,12 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
}
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
my $label = $self->{label};
$label =~ s/-/_/g;
if (defined($instance_mode->{option_results}->{'critical_' . $label}) && $instance_mode->{option_results}->{'critical_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'critical_' . $label}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{'warning_' . $label}) && $instance_mode->{option_results}->{'warning_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'warning_' . $label}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'is : ' . $self->{result_values}->{video_locked};
@ -107,18 +80,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_video_status', 'critical_video_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_video_status', 'critical_video_status']);
}
sub prefix_video_output {

View File

@ -20,57 +20,37 @@
package network::f5::bigip::snmp::mode::failover;
use base qw(centreon::plugins::mode);
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::values;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
my $instance_mode;
my $maps_counters = {
global => [
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' },
];
$self->{maps_counters}->{global} = [
{ label => 'sync-status', threshold => 0, set => {
key_values => [ { name => 'syncstatus' } ],
closure_custom_calc => \&custom_syncstatus_calc,
closure_custom_output => \&custom_syncstatus_output,
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&custom_syncstatus_threshold,
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'failover-status', threshold => 0, set => {
{ label => 'failover-status', threshold => 0, set => {
key_values => [ { name => 'failoverstatus' } ],
closure_custom_calc => \&custom_failoverstatus_calc,
closure_custom_output => \&custom_failoverstatus_output,
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&custom_failoverstatus_threshold,
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
]
};
sub custom_syncstatus_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_sync_status}) && $instance_mode->{option_results}->{critical_sync_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_sync_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_sync_status}) && $instance_mode->{option_results}->{warning_sync_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_sync_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
];
}
sub custom_syncstatus_output {
@ -87,30 +67,6 @@ sub custom_syncstatus_calc {
return 0;
}
sub custom_failoverstatus_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_failover_status}) && $instance_mode->{option_results}->{critical_failover_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_failover_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_failover_status}) && $instance_mode->{option_results}->{warning_failover_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_failover_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_failoverstatus_output {
my ($self, %options) = @_;
my $msg = "Failover status is '" . $self->{result_values}->{failoverstatus} . "'";
@ -139,103 +95,15 @@ sub new {
"warning-failover-status:s" => { name => 'warning_failover_status', default => '' },
"critical-failover-status:s" => { name => 'critical_failover_status', default => '%{failoverstatus} =~ /unknown/' },
});
foreach my $key (('global')) {
foreach (@{$maps_counters->{$key}}) {
if (!defined($_->{threshold}) || $_->{threshold} != 0) {
$options{options}->add_options(arguments => {
'warning-' . $_->{label} . ':s' => { name => 'warning-' . $_->{label} },
'critical-' . $_->{label} . ':s' => { name => 'critical-' . $_->{label} },
});
}
$_->{obj} = centreon::plugins::values->new(statefile => $self->{statefile_value},
output => $self->{output}, perfdata => $self->{perfdata},
label => $_->{label});
$_->{obj}->set(%{$_->{set}});
}
}
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach my $key (('global')) {
foreach (@{$maps_counters->{$key}}) {
$_->{obj}->init(option_results => $self->{option_results});
}
}
$instance_mode = $self;
$self->change_macros();
}
$self->SUPER::check_options(%options);
sub run_global {
my ($self, %options) = @_;
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits;
foreach (@{$maps_counters->{global}}) {
my $obj = $_->{obj};
next if (defined($self->{option_results}->{filter_counters}) && $self->{option_results}->{filter_counters} ne '' &&
$_->{name} !~ /$self->{option_results}->{filter_counters}/);
$obj->set(instance => 'global');
my ($value_check) = $obj->execute(values => $self->{global});
if ($value_check != 0) {
$long_msg .= $long_msg_append . $obj->output_error();
$long_msg_append = ' - ';
next;
}
my $exit2 = $obj->threshold_check();
push @exits, $exit2;
my $output = $obj->output();
$long_msg .= $long_msg_append . $output;
$long_msg_append = ' - ';
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
$short_msg .= $short_msg_append . $output;
$short_msg_append = ' - ';
}
$obj->perfdata();
}
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
$self->{output}->output_add(severity => $exit,
short_msg => "$short_msg"
);
} else {
$self->{output}->output_add(short_msg => "$long_msg");
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
$self->run_global();
$self->{output}->display();
$self->{output}->exit();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_sync_status', 'critical_sync_status', 'warning_failover_status', 'critical_failover_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_sync_status', 'critical_sync_status', 'warning_failover_status', 'critical_failover_status']);
}
my %map_boolean = (
@ -334,4 +202,4 @@ Can used special variables like: %{failoverstatus}
=back
=cut
=cut

View File

@ -25,8 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub set_counters {
my ($self, %options) = @_;
@ -42,7 +41,7 @@ sub set_counters {
closure_custom_calc_extra_options => { output_label => 'Status', name_status => 'fmDeviceEntState' },
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'device-con-status', threshold => 0, set => {
@ -51,7 +50,7 @@ sub set_counters {
closure_custom_calc_extra_options => { output_label => 'Connection Status', name_status => 'fmDeviceEntConnectState' },
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'device-db-status', threshold => 0, set => {
@ -60,7 +59,7 @@ sub set_counters {
closure_custom_calc_extra_options => { output_label => 'DB Status', name_status => 'fmDeviceEntDbState' },
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'device-config-status', threshold => 0, set => {
@ -69,38 +68,12 @@ sub set_counters {
closure_custom_calc_extra_options => { output_label => 'Configuration Status', name_status => 'fmDeviceEntConfigState' },
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
}
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
my $label = $self->{label};
$label =~ s/-/_/g;
if (defined($instance_mode->{option_results}->{'critical_' . $label}) && $instance_mode->{option_results}->{'critical_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'critical_' . $label}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{'warning_' . $label}) && $instance_mode->{option_results}->{'warning_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'warning_' . $label}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = $self->{result_values}->{output_label} . ' : ' . $self->{result_values}->{status};
@ -143,19 +116,8 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_device_status', 'critical_device_status', 'warning_device_con_status', 'critical_device_con_status',
'warning_device_db_status', 'critical_device_db_status', 'warning_device_config_status', 'critical_device_config_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_device_status', 'critical_device_status', 'warning_device_con_status', 'critical_device_con_status',
'warning_device_db_status', 'critical_device_db_status', 'warning_device_config_status', 'critical_device_config_status']);
}
sub prefix_device_output {

View File

@ -24,32 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{'critical_' . $self->{result_values}->{label}}) && $instance_mode->{option_results}->{'critical_' . $self->{result_values}->{label}} ne '' &&
eval "$instance_mode->{option_results}->{\"critical_\" . $self->{result_values}->{label}}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{'warning_' . $self->{result_values}->{label}}) && $instance_mode->{option_results}->{'warning_' . $self->{result_values}->{label}} ne '' &&
eval "$instance_mode->{option_results}->{\"warning_\" . $self->{result_values}->{label}}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_hastatus_output {
my ($self, %options) = @_;
@ -94,7 +69,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_hastatus_calc'),
closure_custom_output => $self->can('custom_hastatus_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'sync-status', threshold => 0, set => {
@ -102,7 +77,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_syncstatus_calc'),
closure_custom_output => $self->can('custom_syncstatus_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -129,18 +104,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_ha_status', 'critical_ha_status', 'warning_sync_status', 'critical_sync_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_ha_status', 'critical_ha_status', 'warning_sync_status', 'critical_sync_status']);
}
my %map_daemon_state = (

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -80,7 +55,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'active', set => {
@ -135,8 +110,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_rs_output {
@ -145,16 +119,6 @@ sub prefix_rs_output {
return "Real server '" . $options{instance_value}->{display} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_state = (
1 => 'inService',
2 => 'outOfService',

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -80,7 +55,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'active', set => {
@ -135,8 +110,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_vs_output {
@ -145,16 +119,6 @@ sub prefix_vs_output {
return "Virtual server '" . $options{instance_value}->{display} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_state = (
1 => 'inService',
2 => 'outOfService',

View File

@ -24,30 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -73,7 +50,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -94,22 +71,11 @@ sub new {
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach ('warning_status', 'critical_status') {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status');
}
my %map_status = (

View File

@ -24,30 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -73,7 +50,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -94,22 +71,11 @@ sub new {
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach ('warning_status', 'critical_status') {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
my %map_status = (

View File

@ -25,32 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -85,7 +60,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -117,18 +92,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
my $oid_ruckusSCGAPName = '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.5',

View File

@ -27,32 +27,7 @@ use warnings;
use POSIX;
use centreon::plugins::misc;
use centreon::plugins::statefile;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -89,7 +64,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -119,23 +94,12 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
if (defined($self->{option_results}->{memory})) {
$self->{statefile_cache}->check_options(%options);
}
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_severity = (0 => 'info', 1 => 'warning', 2 => 'minor', 3 => 'major',
4 => 'critical', 5 => 'cleared', 6 => 'acknowledged', 7 => 'unacknowledged', 8 => 'indeterminate');

View File

@ -24,30 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
@ -73,7 +50,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
@ -94,22 +71,11 @@ sub new {
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach ('warning_status', 'critical_status') {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub manage_selection {

View File

@ -24,8 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_node_perfdata {
my ($self, %options) = @_;
@ -39,7 +38,7 @@ sub custom_node_threshold {
my ($self, %options) = @_;
my ($exit, $threshold_value);
$threshold_value = defined($instance_mode->{option_results}->{percent}) ? $self->{result_values}->{prct_dead} : $self->{result_values}->{dead_nodes} ;
$threshold_value = defined($self->{instance_mode}->{option_results}->{percent}) ? $self->{result_values}->{prct_dead} : $self->{result_values}->{dead_nodes} ;
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-dead-nodes', exit_litteral => 'critical' }, { label => 'warning-dead-nodes', exit_litteral => 'warning' } ]);
return $exit;
}
@ -62,30 +61,6 @@ sub custom_node_calc {
return 0;
}
sub custom_state_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_state}) && $instance_mode->{option_results}->{critical_state} ne '' &&
eval "$instance_mode->{option_results}->{critical_state}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_state}) && $instance_mode->{option_results}->{warning_state} ne '' &&
eval "$instance_mode->{option_results}->{warning_state}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter state issue: ' . $message);
}
return $status;
}
sub custom_state_output {
my ($self, %options) = @_;
@ -126,7 +101,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_state_calc'),
closure_custom_output => $self->can('custom_state_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_state_threshold'),
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'health', set => {
@ -163,22 +138,11 @@ sub new {
return $self;
}
sub change_macros {
my ($self, %options) = @_;
foreach ('warning_state', 'critical_state') {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
$self->change_macros(macros => ['warning_state', 'critical_state']);
}
my %map_status = (

View File

@ -57,7 +57,7 @@ sub set_counters {
];
$self->{maps_counters}->{mountpoints} = [
{ label => 'options', set => {
{ label => 'status', set => {
key_values => [ { name => 'display' }, { name => 'options' }, { name => 'type' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),