This commit is contained in:
qgarnier 2021-04-12 17:15:33 +02:00 committed by GitHub
parent 75b0ebe2f1
commit 64f3e8c9a6
9 changed files with 177 additions and 151 deletions

View File

@ -48,8 +48,10 @@ sub check {
} else { } else {
$oid_nvramBatteryStatus = '.1.3.6.1.4.1.19746.1.2.3.1.1.2'; $oid_nvramBatteryStatus = '.1.3.6.1.4.1.19746.1.2.3.1.1.2';
$oid_nvramBatteryCharge = '.1.3.6.1.4.1.19746.1.2.3.1.1.3'; $oid_nvramBatteryCharge = '.1.3.6.1.4.1.19746.1.2.3.1.1.3';
%map_battery_status = (1 => 'ok', 2 => 'disabled', 3 => 'discharged', 4 => 'unknown', %map_battery_status = (
5 => 'softdisabled'); 1 => 'ok', 2 => 'disabled', 3 => 'discharged', 4 => 'unknown',
5 => 'softdisabled'
);
} }
foreach my $oid (keys %{$self->{results}->{$oid_nvramBatteryEntry}}) { foreach my $oid (keys %{$self->{results}->{$oid_nvramBatteryEntry}}) {
@ -64,20 +66,28 @@ sub check {
$self->absent_problem(section => 'battery', instance => $instance)); $self->absent_problem(section => 'battery', instance => $instance));
$self->{components}->{battery}->{total}++; $self->{components}->{battery}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Nvram battery '%s' status is '%s'", $self->{output}->output_add(
$instance, $batt_status)); long_msg => sprintf(
"Nvram battery '%s' status is '%s'",
$instance, $batt_status
)
);
my $exit = $self->get_severity(section => 'battery', value => $batt_status); my $exit = $self->get_severity(section => 'battery', value => $batt_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Nvram battery '%s' status is '%s'", $instance, $batt_status)); severity => $exit,
short_msg => sprintf("Nvram battery '%s' status is '%s'", $instance, $batt_status)
);
} }
if (defined($batt_value) && $batt_value =~ /[0-9]/) { if (defined($batt_value) && $batt_value =~ /[0-9]/) {
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'battery', instance => $instance, value => $batt_value); my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'battery', instance => $instance, value => $batt_value);
$self->{output}->output_add(long_msg => sprintf("Nvram battery '%s' charge is %s %%", $instance, $batt_value)); $self->{output}->output_add(long_msg => sprintf("Nvram battery '%s' charge is %s %%", $instance, $batt_value));
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Nvram battery '%s' charge is %s %%", $instance, $batt_value)); severity => $exit,
short_msg => sprintf("Nvram battery '%s' charge is %s %%", $instance, $batt_value)
);
} }
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'nvram_battery', unit => '%', label => 'nvram_battery', unit => '%',

View File

@ -35,7 +35,7 @@ my %map_disk_status = (
6 => 'available', # since OS 5.4 6 => 'available', # since OS 5.4
8 => 'raidReconstruction', # since OS 7.x 8 => 'raidReconstruction', # since OS 7.x
9 => 'copyReconstruction', # since OS 7.x 9 => 'copyReconstruction', # since OS 7.x
10 => 'system', # since OS 7.x 10 => 'system' # since OS 7.x
); );
sub load { sub load {
@ -67,12 +67,18 @@ sub check {
$self->absent_problem(section => 'disk', instance => $instance)); $self->absent_problem(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++; $self->{components}->{disk}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Disk '%s' status is '%s'", $self->{output}->output_add(
$instance, $disk_status)); long_msg => sprintf(
"Disk '%s' status is '%s'",
$instance, $disk_status
)
);
my $exit = $self->get_severity(section => 'disk', value => $disk_status); my $exit = $self->get_severity(section => 'disk', value => $disk_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Disk '%s' status is '%s'", $instance, $disk_status)); severity => $exit,
short_msg => sprintf("Disk '%s' status is '%s'", $instance, $disk_status)
);
} }
} }
} }

View File

@ -27,13 +27,13 @@ use centreon::plugins::misc;
my %map_fan_status = ( my %map_fan_status = (
0 => 'notfound', 0 => 'notfound',
1 => 'ok', 1 => 'ok',
2 => 'failed', 2 => 'failed'
); );
my %level_map = ( my %level_map = (
0 => 'unknown', 0 => 'unknown',
1 => 'low', 1 => 'low',
2 => 'normal', 2 => 'normal',
3 => 'high', 3 => 'high'
); );
my ($oid_fanDescription, $oid_fanLevel, $oid_fanStatus); my ($oid_fanDescription, $oid_fanLevel, $oid_fanStatus);
@ -75,12 +75,18 @@ sub check {
$self->absent_problem(section => 'fan', instance => $instance)); $self->absent_problem(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++; $self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s, level = %s]", $self->{output}->output_add(
$fan_descr, $fan_status, $instance, $level_map{$fan_level})); long_msg => sprintf(
"Fan '%s' status is '%s' [instance = %s, level = %s]",
$fan_descr, $fan_status, $instance, $level_map{$fan_level}
)
);
my $exit = $self->get_severity(section => 'fan', value => $fan_status); my $exit = $self->get_severity(section => 'fan', value => $fan_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Fan '%s' status is '%s'", $fan_descr, $fan_status)); severity => $exit,
short_msg => sprintf("Fan '%s' status is '%s'", $fan_descr, $fan_status)
);
} }
} }
} }

View File

@ -43,8 +43,10 @@ sub check {
if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) {
$oid_powerModuleDescription = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.3'; $oid_powerModuleDescription = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.3';
$oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.4'; $oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.4';
%map_psu_status = (0 => 'absent', 1 => 'ok', 2 => 'failed', 3 => 'faulty', 4 => 'acnone', %map_psu_status = (
99 => 'unknown'); 0 => 'absent', 1 => 'ok', 2 => 'failed', 3 => 'faulty', 4 => 'acnone',
99 => 'unknown'
);
} else { } else {
$oid_powerModuleDescription = ''; # none $oid_powerModuleDescription = ''; # none
$oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.4'; $oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.4';
@ -64,12 +66,18 @@ sub check {
$self->absent_problem(section => 'psu', instance => $instance)); $self->absent_problem(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++; $self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is '%s' [description = %s]", $self->{output}->output_add(
$instance, $psu_status, $instance)); long_msg => sprintf(
"Power Supply '%s' status is '%s' [description = %s]",
$instance, $psu_status, $instance
)
);
my $exit = $self->get_severity(section => 'psu', value => $psu_status); my $exit = $self->get_severity(section => 'psu', value => $psu_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Power Supply '%s' status is '%s'", $instance, $psu_status)); severity => $exit,
short_msg => sprintf("Power Supply '%s' status is '%s'", $instance, $psu_status)
);
} }
} }
} }

View File

@ -45,8 +45,10 @@ sub check {
$oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4'; $oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4';
$oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.5'; $oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.5';
$oid_tempSensorStatus = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.6'; $oid_tempSensorStatus = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.6';
%map_temp_status = (0 => 'failed', 1 => 'ok', 2 => 'notfound', 3 => 'overheatWarning', %map_temp_status = (
4 => 'overheatCritical'); 0 => 'failed', 1 => 'ok', 2 => 'notfound', 3 => 'overheatWarning',
4 => 'overheatCritical'
);
} else { } else {
$oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.3'; $oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.3';
$oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4'; $oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4';
@ -68,20 +70,28 @@ sub check {
$self->absent_problem(section => 'temperature', instance => $instance)); $self->absent_problem(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++; $self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is '%s' [instance = %s]", $self->{output}->output_add(
$temp_descr, $temp_status, $instance)); long_msg => sprintf(
"Temperature '%s' status is '%s' [instance = %s]",
$temp_descr, $temp_status, $instance
)
);
my $exit = $self->get_severity(section => 'temperature', value => $temp_status); my $exit = $self->get_severity(section => 'temperature', value => $temp_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Temperature '%s' status is '%s'", $temp_descr, $temp_status)); severity => $exit,
short_msg => sprintf("Temperature '%s' status is '%s'", $temp_descr, $temp_status)
);
} }
if (defined($temp_value) && $temp_value =~ /[0-9]/) { if (defined($temp_value) && $temp_value =~ /[0-9]/) {
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temp_value); my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temp_value);
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %s degree centigrade", $temp_descr, $temp_value)); $self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %s degree centigrade", $temp_descr, $temp_value));
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Temperature '%s' is %s degree centigrade", $temp_descr, $temp_value)); severity => $exit,
short_msg => sprintf("Temperature '%s' is %s degree centigrade", $temp_descr, $temp_value)
);
} }
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'temp', unit => 'C', label => 'temp', unit => 'C',
@ -89,7 +99,7 @@ sub check {
instances => $instance, instances => $instance,
value => $temp_value, value => $temp_value,
warning => $warn, warning => $warn,
critical => $crit, critical => $crit
); );
} }
} }

View File

@ -26,35 +26,6 @@ use strict;
use warnings; use warnings;
use storage::emc::DataDomain::lib::functions; use storage::emc::DataDomain::lib::functions;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'fs', type => 1, cb_prefix_output => 'prefix_fs_output', message_multiple => 'All filesystems are ok.' },
];
$self->{maps_counters}->{fs} = [
{ label => 'usage', set => {
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_used_calc'),
closure_custom_output => $self->can('custom_used_output'),
threshold_use => 'used_prct', output_error_template => '%s',
perfdatas => [
{ value => 'used', label => 'used', cast_int => 1,
unit => 'B', min => 0, max => 'total', threshold_total => 'total',
label_extra_instance => 1, instance_use => 'display' }
]
}
}
];
}
sub prefix_fs_output {
my ($self, %options) = @_;
return "Filesystem '" . $options{instance_value}->{display} . "' ";
}
sub custom_used_calc { sub custom_used_calc {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -82,6 +53,35 @@ sub custom_used_output {
); );
} }
sub prefix_fs_output {
my ($self, %options) = @_;
return "Filesystem '" . $options{instance_value}->{display} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'fs', type => 1, cb_prefix_output => 'prefix_fs_output', message_multiple => 'All filesystems are ok.' }
];
$self->{maps_counters}->{fs} = [
{ label => 'usage', set => {
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_used_calc'),
closure_custom_output => $self->can('custom_used_output'),
threshold_use => 'used_prct', output_error_template => '%s',
perfdatas => [
{ value => 'used', label => 'used', cast_int => 1,
unit => 'B', min => 0, max => 'total', threshold_total => 'total',
label_extra_instance => 1, instance_use => 'display' }
]
}
}
];
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -98,29 +98,26 @@ sub new {
} }
my $oid_fileSystemSpaceEntry = '.1.3.6.1.4.1.19746.1.3.2.1.1'; my $oid_fileSystemSpaceEntry = '.1.3.6.1.4.1.19746.1.3.2.1.1';
my $oid_sysDescr = '.1.3.6.1.2.1.1.1'; # 'Data Domain OS 5.4.1.1-411752' my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0'; # 'Data Domain OS 5.4.1.1-411752'
my ($oid_fileSystemResourceName, $oid_fileSystemSpaceUsed, $oid_fileSystemSpaceAvail); my ($oid_fileSystemResourceName, $oid_fileSystemSpaceUsed, $oid_fileSystemSpaceAvail);
sub add_result { sub add_result {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{fs}->{ $options{instance} } = {}; $self->{fs}->{ $options{instance} } = {};
$self->{fs}->{$options{instance}}->{display} = $self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $options{instance}}; $self->{fs}->{ $options{instance} }->{display} = $options{snmp_result}->{$oid_fileSystemResourceName . '.' . $options{instance}};
$self->{fs}->{$options{instance}}->{free} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceAvail . '.' . $options{instance}} * 1024 * 1024 * 1024); $self->{fs}->{ $options{instance} }->{free} = int($options{snmp_result}->{$oid_fileSystemSpaceAvail . '.' . $options{instance}} * 1024 * 1024 * 1024);
$self->{fs}->{$options{instance}}->{used} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceUsed . '.' . $options{instance}} * 1024 * 1024 * 1024); $self->{fs}->{ $options{instance} }->{used} = int($options{snmp_result}->{$oid_fileSystemSpaceUsed . '.' . $options{instance}} * 1024 * 1024 * 1024);
} }
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{results} = $options{snmp}->get_multiple_table( my $snmp_result = $options{snmp}->get_leef(
oids => [ oids => [ $oid_sysDescr ],
{ oid => $oid_sysDescr },
{ oid => $oid_fileSystemSpaceEntry },
],
nothing_quit => 1 nothing_quit => 1
); );
if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results}->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) { if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $snmp_result->{$oid_sysDescr}))) {
$self->{output}->output_add( $self->{output}->output_add(
severity => 'UNKNOWN', severity => 'UNKNOWN',
short_msg => 'Cannot get DataDomain OS version.' short_msg => 'Cannot get DataDomain OS version.'
@ -128,6 +125,12 @@ sub manage_selection {
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }
$snmp_result = $options{snmp}->get_table(
oid => $oid_fileSystemSpaceEntry,
nothing_quit => 1
);
if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) {
$oid_fileSystemResourceName = '.1.3.6.1.4.1.19746.1.3.2.1.1.3'; $oid_fileSystemResourceName = '.1.3.6.1.4.1.19746.1.3.2.1.1.3';
$oid_fileSystemSpaceUsed = '.1.3.6.1.4.1.19746.1.3.2.1.1.5'; $oid_fileSystemSpaceUsed = '.1.3.6.1.4.1.19746.1.3.2.1.1.5';
@ -139,28 +142,28 @@ sub manage_selection {
} }
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{filesystem})) { if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{filesystem})) {
if (!defined($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $self->{option_results}->{filesystem}})) { if (!defined($snmp_result->{$oid_fileSystemResourceName . '.' . $self->{option_results}->{filesystem}})) {
$self->{output}->add_option_msg(short_msg => "No filesystem found for id '" . $self->{option_results}->{filesystem} . "'."); $self->{output}->add_option_msg(short_msg => "No filesystem found for id '" . $self->{option_results}->{filesystem} . "'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
$self->add_result(instance => $self->{option_results}->{filesystem}); $self->add_result(instance => $self->{option_results}->{filesystem}, snmp_result => $snmp_result);
} else { } else {
foreach my $oid (keys %{$self->{results}->{$oid_fileSystemSpaceEntry}}) { foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$oid_fileSystemResourceName\.(\d+)$/); next if ($oid !~ /^$oid_fileSystemResourceName\.(\d+)$/);
my $instance = $1; my $instance = $1;
my $filter_name = $self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $instance}; my $filter_name = $snmp_result->{$oid_fileSystemResourceName . '.' . $instance};
if (!defined($self->{option_results}->{filesystem})) { if (!defined($self->{option_results}->{filesystem})) {
$self->add_result(instance => $instance); $self->add_result(instance => $instance, snmp_result => $snmp_result);
next; next;
} }
if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{filesystem}/i) { if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{filesystem}/i) {
$self->add_result(instance => $instance); $self->add_result(instance => $instance, snmp_result => $snmp_result);
} }
if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{filesystem}/) { if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{filesystem}/) {
$self->add_result(instance => $instance); $self->add_result(instance => $instance, snmp_result => $snmp_result);
} }
if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name eq $self->{option_results}->{filesystem}) { if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name eq $self->{option_results}->{filesystem}) {
$self->add_result(instance => $instance); $self->add_result(instance => $instance, snmp_result => $snmp_result);
} }
} }
} }
@ -184,8 +187,7 @@ sub disco_format {
sub disco_show { sub disco_show {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp}; $self->manage_selection(disco => 1, snmp => $options{snmp});
$self->manage_selection(disco => 1);
foreach (sort keys %{$self->{fs}}) { foreach (sort keys %{$self->{fs}}) {
$self->{output}->add_disco_entry( $self->{output}->add_disco_entry(
name => $self->{fs}->{$_}->{display}, name => $self->{fs}->{$_}->{display},

View File

@ -38,7 +38,7 @@ sub set_system {
fan => [ fan => [
['notfound', 'OK'], ['notfound', 'OK'],
['ok', 'OK'], ['ok', 'OK'],
['failed', 'CRITICAL'], ['failed', 'CRITICAL']
], ],
temperature => [ temperature => [
['failed', 'CRITICAL'], ['failed', 'CRITICAL'],
@ -46,7 +46,7 @@ sub set_system {
['notfound', 'OK'], ['notfound', 'OK'],
['absent', 'OK'], ['absent', 'OK'],
['overheatWarning', 'WARNING'], ['overheatWarning', 'WARNING'],
['overheatCritical', 'CRITICAL'], ['overheatCritical', 'CRITICAL']
], ],
psu => [ psu => [
['absent', 'OK'], ['absent', 'OK'],
@ -54,7 +54,7 @@ sub set_system {
['failed', 'CRITICAL'], ['failed', 'CRITICAL'],
['faulty', 'WARNING'], ['faulty', 'WARNING'],
['acnone', 'WARNING'], ['acnone', 'WARNING'],
['unknown', 'UNKNOWN'], ['unknown', 'UNKNOWN']
], ],
disk => [ disk => [
['ok', 'OK'], ['ok', 'OK'],
@ -62,15 +62,15 @@ sub set_system {
['available', 'OK'], ['available', 'OK'],
['unknown', 'UNKNOWN'], ['unknown', 'UNKNOWN'],
['absent', 'OK'], ['absent', 'OK'],
['failed', 'CRITICAL'], ['failed', 'CRITICAL']
], ],
battery => [ battery => [
['ok', 'OK'], ['ok', 'OK'],
['disabled', 'OK'], ['disabled', 'OK'],
['discharged', 'WARNING'], ['discharged', 'WARNING'],
['softdisabled', 'OK'], ['softdisabled', 'OK'],
['UNKNOWN', 'UNKNOWN'], ['UNKNOWN', 'UNKNOWN']
], ]
}; };
$self->{components_path} = 'storage::emc::DataDomain::mode::components'; $self->{components_path} = 'storage::emc::DataDomain::mode::components';

View File

@ -24,14 +24,13 @@ 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);
use storage::emc::DataDomain::lib::functions; use storage::emc::DataDomain::lib::functions;
sub custom_status_calc { sub prefix_repl_output {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; return "Replication '" . $options{instance_value}->{display} . "' ";
return 0;
} }
sub set_counters { sub set_counters {
@ -42,13 +41,17 @@ sub set_counters {
]; ];
$self->{maps_counters}->{repl} = [ $self->{maps_counters}->{repl} = [
{ label => 'status', threshold => 0, set => { {
label => 'status',
type => 2,
warning_default => '%{state} =~ /initializing|recovering/i',
critical_default => '%{state} =~ /disabledNeedsResync|uninitialized/i',
set => {
key_values => [ { name => 'state' } ], key_values => [ { name => 'state' } ],
output_template => "status is '%s'", output_template => "status is '%s'",
output_use => 'state', output_use => 'state',
closure_custom_calc => $self->can('custom_status_calc'),
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 => 'offset', set => { { label => 'offset', set => {
@ -63,48 +66,29 @@ sub set_counters {
]; ];
} }
sub prefix_repl_output {
my ($self, %options) = @_;
return "Replication '" . $options{instance_value}->{display} . "' ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '%{state} =~ /initializing|recovering/i' },
'critical-status:s' => { name => 'critical_status', default => '%{state} =~ /disabledNeedsResync|uninitialized/i' }
}); });
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']);
}
my $oid_sysDescr = '.1.3.6.1.2.1.1.1'; # 'Data Domain OS 5.4.1.1-411752'
my $oid_replicationInfoEntry = '.1.3.6.1.4.1.19746.1.8.1.1.1';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_multiple_table( my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0'; # 'Data Domain OS 5.4.1.1-411752'
oids => [ my $oid_replicationInfoEntry = '.1.3.6.1.4.1.19746.1.8.1.1.1';
{ oid => $oid_sysDescr },
{ oid => $oid_replicationInfoEntry } my $snmp_result = $options{snmp}->get_leef(
], oids => [ $oid_sysDescr ],
nothing_quit => 1 nothing_quit => 1
); );
if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $snmp_result->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) { if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $snmp_result->{$oid_sysDescr}))) {
$self->{output}->output_add( $self->{output}->output_add(
severity => 'UNKNOWN', severity => 'UNKNOWN',
short_msg => 'Cannot get DataDomain OS version.' short_msg => 'Cannot get DataDomain OS version.'
@ -113,10 +97,10 @@ sub manage_selection {
$self->{output}->exit(); $self->{output}->exit();
} }
if (scalar(keys %{$snmp_result->{$oid_replicationInfoEntry}}) <= 0) { $snmp_result = $options{snmp}->get_table(
$self->{output}->add_option_msg(short_msg => 'no replication informations'); oid => $oid_replicationInfoEntry,
$self->{output}->option_exit(); nothing_quit => 1
} );
my ($oid_replSource, $oid_replDestination, $oid_replState); my ($oid_replSource, $oid_replDestination, $oid_replState);
my %map_state = ( my %map_state = (
@ -147,10 +131,10 @@ sub manage_selection {
}; };
$self->{repl} = {}; $self->{repl} = {};
foreach my $oid (keys %{$snmp_result->{$oid_replicationInfoEntry}}) { foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{replState}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{replState}->{oid}\.(.*)$/);
my $instance = $1; my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_replicationInfoEntry}, instance => $instance); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{repl}->{$instance} = { $self->{repl}->{$instance} = {
display => $result->{replSource} . '/' . $result->{replDestination}, display => $result->{replSource} . '/' . $result->{replDestination},
state => $result->{replState}, state => $result->{replState},

View File

@ -30,11 +30,11 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
%{$self->{modes}} = ( $self->{modes} = {
'hardware' => 'storage::emc::DataDomain::mode::hardware', 'hardware' => 'storage::emc::DataDomain::mode::hardware',
'filesystem-usage' => 'storage::emc::DataDomain::mode::filesystem', 'filesystem-usage' => 'storage::emc::DataDomain::mode::filesystem',
'replication' => 'storage::emc::DataDomain::mode::replication', 'replication' => 'storage::emc::DataDomain::mode::replication'
); };
return $self; return $self;
} }