enh(server/fujitsu): add disk and raid component (#2811)

This commit is contained in:
qgarnier 2021-05-20 10:15:03 +02:00 committed by GitHub
parent 4657372851
commit da13d106e6
10 changed files with 430 additions and 186 deletions

View File

@ -25,21 +25,21 @@ use warnings;
my $map_sc_cpu_status = {
1 => 'unknown', 2 => 'disabled', 3 => 'ok', 4 => 'not-present', 5 => 'error',
6 => 'fail', 7 => 'missing-termination', 8 => 'prefailure-warning',
6 => 'fail', 7 => 'missing-termination', 8 => 'prefailure-warning'
};
my $map_sc2_cpu_status = {
1 => 'unknown', 2 => 'not-present', 3 => 'ok', 4 => 'disabled', 5 => 'error',
6 => 'failed', 7 => 'missing-termination', 8 => 'prefailure-warning',
6 => 'failed', 7 => 'missing-termination', 8 => 'prefailure-warning'
};
my $mapping = {
sc => {
cpuStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.4.1.1.6', map => $map_sc_cpu_status },
cpuStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.4.1.1.6', map => $map_sc_cpu_status }
},
sc2 => {
sc2cpuDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.4.1.3' },
sc2cpuStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.4.1.4', map => $map_sc2_cpu_status },
},
sc2cpuStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.4.1.4', map => $map_sc2_cpu_status }
}
};
my $oid_sc2CPUs = '.1.3.6.1.4.1.231.2.10.2.2.10.6.4.1';
@ -64,14 +64,19 @@ sub check_cpu {
$self->absent_problem(section => 'cpu', instance => $instance));
$self->{components}->{cpu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("cpu '%s' status is '%s' [instance = %s]",
$result->{$options{name}}, $result->{$options{status}}, $instance,
));
$self->{output}->output_add(
long_msg => sprintf(
"cpu '%s' status is '%s' [instance: %s]",
$result->{$options{name}}, $result->{$options{status}}, $instance
)
);
$exit = $self->get_severity(section => 'cpu', value => $result->{$options{status}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Cpu '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Cpu '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}})
);
}
}
}
@ -79,16 +84,20 @@ sub check_cpu {
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking cpu");
$self->{output}->output_add(long_msg => 'Checking cpu');
$self->{components}->{cpu} = { name => 'cpu', total => 0, skip => 0 };
return if ($self->check_filter(section => 'cpu'));
if (defined($self->{results}->{$oid_sc2CPUs}) && scalar(keys %{$self->{results}->{$oid_sc2CPUs}}) > 0) {
check_cpu($self, entry => $oid_sc2CPUs, mapping => $mapping->{sc2}, name => 'sc2cpuDesignation',
status => 'sc2cpuStatus');
check_cpu(
$self, entry => $oid_sc2CPUs, mapping => $mapping->{sc2}, name => 'sc2cpuDesignation',
status => 'sc2cpuStatus'
);
} else {
check_cpu($self, entry => $mapping->{sc}->{cpuStatus}, mapping => $mapping->{sc}, name => 'instance',
status => 'cpuStatus');
check_cpu(
$self, entry => $mapping->{sc}->{cpuStatus}, mapping => $mapping->{sc}, name => 'instance',
status => 'cpuStatus'
);
}
}

View File

@ -0,0 +1,78 @@
#
# Copyright 2021 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::fujitsu::snmp::mode::components::disk;
use strict;
use warnings;
my $map_drive_status = {
1 => 'unknown', 2 => 'noDisk',
3 => 'online', 4 => 'ready',
5 => 'failed', 6 => 'rebuilding',
7 => 'hotspareGlobal', 8 => 'hotspareDedicated',
9 => 'offline', 10 => 'unconfiguredFailed',
11 => 'formatting', 12 => 'dead'
};
my $mapping = {
status => { oid => '.1.3.6.1.4.1.231.2.49.1.5.2.1.15', map => $map_drive_status } # svrPhysicalDeviceStatus
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{status}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'Checking disks');
$self->{components}->{disk} = { name => 'disks', total => 0, skip => 0 };
return if ($self->check_filter(section => 'disk'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping->{status}->{oid} }})) {
next if ($oid !~ /^$mapping->{status}->{oid}\.(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
my $instance = $1 . '.' . $2 . '.' . $3 . '.' . $4;
my $name = $1 . ':' . $2 . ':' . $3 . ':' . $4;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{status}->{oid} }, instance => $instance);
next if ($self->check_filter(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"disk '%s' status is '%s' [instance: %s]",
$name, $result->{status}, $instance
)
);
my $exit = $self->get_severity(section => 'disk', value => $result->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Disk '%s' status is '%s'", $name, $result->{status})
);
}
}
}
1;

View File

@ -26,25 +26,25 @@ use warnings;
my $map_sc_fan_status = {
1 => 'unknown', 2 => 'disabled', 3 => 'ok', 4 => 'fail',
5 => 'prefailure-predicted', 6 => 'redundant-fan-failed',
7 => 'not-manageable', 8 => 'not-present',
7 => 'not-manageable', 8 => 'not-present'
};
my $map_sc2_fan_status = {
1 => 'unknown', 2 => 'disabled', 3 => 'ok', 4 => 'failed',
5 => 'prefailure-predicted', 6 => 'redundant-fan-failed',
7 => 'not-manageable', 8 => 'not-present',
7 => 'not-manageable', 8 => 'not-present'
};
my $mapping = {
sc => {
fanStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.2.2.1.3', map => $map_sc_fan_status },
fanCurrentSpeed => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.2.2.1.8' },
fanDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.2.2.1.16' },
fanDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.2.2.1.16' }
},
sc2 => {
sc2fanDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.5.2.1.3' },
sc2fanStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.5.2.1.5', map => $map_sc2_fan_status },
sc2fanCurrentSpeed => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.5.2.1.6' },
},
sc2fanCurrentSpeed => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.5.2.1.6' }
}
};
my $oid_sc2Fans = '.1.3.6.1.4.1.231.2.10.2.2.10.5.2.1';
my $oid_fans = '.1.3.6.1.4.1.231.2.10.2.2.5.2.2.1';
@ -70,14 +70,19 @@ sub check_fan {
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s] [speed = %s]",
$self->{output}->output_add(
long_msg => sprintf(
"fan '%s' status is '%s' [instance: %s] [speed: %s]",
$result->{$options{name}}, $result->{$options{status}}, $instance, $result->{$options{speed}}
));
)
);
$exit = $self->get_severity(section => 'fan', value => $result->{$options{status}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Fan '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}})
);
}
next if (!defined($result->{$options{speed}}) || $result->{$options{speed}} == -1);
@ -85,12 +90,14 @@ sub check_fan {
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{$options{speed}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' speed is %s rpm", $result->{$options{name}}, $result->{$options{speed}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Fan '%s' speed is %s rpm", $result->{$options{name}}, $result->{$options{speed}})
);
}
$self->{output}->perfdata_add(
label => 'fan', unit => 'rpm',
nlabel => 'hardware.fan.speed.rpm',
unit => 'rpm',
instances => $result->{$options{name}},
value => $result->{$options{speed}},
warning => $warn,
@ -103,16 +110,20 @@ sub check_fan {
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{output}->output_add(long_msg => 'Checking fans');
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
return if ($self->check_filter(section => 'fan'));
if (defined($self->{results}->{$oid_sc2Fans}) && scalar(keys %{$self->{results}->{$oid_sc2Fans}}) > 0) {
check_fan($self, entry => $oid_sc2Fans, mapping => $mapping->{sc2}, name => 'sc2fanDesignation',
speed => 'sc2fanCurrentSpeed', status => 'sc2fanStatus');
check_fan(
$self, entry => $oid_sc2Fans, mapping => $mapping->{sc2}, name => 'sc2fanDesignation',
speed => 'sc2fanCurrentSpeed', status => 'sc2fanStatus'
);
} else {
check_fan($self, entry => $oid_fans, mapping => $mapping->{sc}, name => 'fanDesignation',
speed => 'fanCurrentSpeed', status => 'fanStatus');
check_fan(
$self, entry => $oid_fans, mapping => $mapping->{sc}, name => 'fanDesignation',
speed => 'fanCurrentSpeed', status => 'fanStatus'
);
}
}

View File

@ -26,21 +26,21 @@ use warnings;
my $map_sc_memory_status = {
1 => 'unknown', 2 => 'error', 3 => 'ok', 4 => 'not-available', 5 => 'fail',
6 => 'prefailure-warning', 7 => 'hot-spare', 8 => 'mirror',
9 => 'disabled', 10 => 'raid',
9 => 'disabled', 10 => 'raid'
};
my $map_sc2_memory_status = {
1 => 'unknown', 2 => 'not-present', 3 => 'ok', 4 => 'disabled', 5 => 'error', 6 => 'failed',
7 => 'prefailure-predicted', 8 => 'hot-spare', 9 => 'mirror', 10 => 'raid', 11 => 'hidden',
7 => 'prefailure-predicted', 8 => 'hot-spare', 9 => 'mirror', 10 => 'raid', 11 => 'hidden'
};
my $mapping = {
sc => {
memModuleStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.4.10.1.3', map => $map_sc_memory_status },
memModuleStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.4.10.1.3', map => $map_sc_memory_status }
},
sc2 => {
sc2memModuleDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.5.1.3' },
sc2memModuleStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.5.1.4', map => $map_sc2_memory_status },
},
sc2memModuleStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.5.1.4', map => $map_sc2_memory_status }
}
};
my $oid_sc2MemoryModules = '.1.3.6.1.4.1.231.2.10.2.2.10.6.5.1';
@ -65,14 +65,19 @@ sub check_memory {
$self->absent_problem(section => 'memory', instance => $instance));
$self->{components}->{memory}->{total}++;
$self->{output}->output_add(long_msg => sprintf("memory '%s' status is '%s' [instance = %s]",
$result->{$options{name}}, $result->{$options{status}}, $instance,
));
$self->{output}->output_add(
long_msg => sprintf(
"memory '%s' status is '%s' [instance: %s]",
$result->{$options{name}}, $result->{$options{status}}, $instance
)
);
$exit = $self->get_severity(section => 'memory', value => $result->{$options{status}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Memory '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}})
);
}
}
}
@ -80,16 +85,20 @@ sub check_memory {
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking memories");
$self->{output}->output_add(long_msg => 'Checking memories');
$self->{components}->{memory} = { name => 'memories', total => 0, skip => 0 };
return if ($self->check_filter(section => 'memory'));
if (defined($self->{results}->{$oid_sc2MemoryModules}) && scalar(keys %{$self->{results}->{$oid_sc2MemoryModules}}) > 0) {
check_memory($self, entry => $oid_sc2MemoryModules, mapping => $mapping->{sc2}, name => 'sc2memModuleDesignation',
status => 'sc2memModuleStatus');
check_memory(
$self, entry => $oid_sc2MemoryModules, mapping => $mapping->{sc2}, name => 'sc2memModuleDesignation',
status => 'sc2memModuleStatus'
);
} else {
check_memory($self, entry => $mapping->{sc}->{memModuleStatus}, mapping => $mapping->{sc}, name => 'instance',
status => 'memModuleStatus');
check_memory(
$self, entry => $mapping->{sc}->{memModuleStatus}, mapping => $mapping->{sc}, name => 'instance',
status => 'memModuleStatus'
);
}
}

View File

@ -26,19 +26,19 @@ use warnings;
my $map_psu_status = {
1 => 'unknown', 2 => 'not-present', 3 => 'ok', 4 => 'failed', 5 => 'ac-fail', 6 => 'dc-fail',
7 => 'critical-temperature', 8 => 'not-manageable', 9 => 'fan-failure-predicted', 10 => 'fan-failure',
11 => 'power-safe-mode', 12 => 'non-redundant-dc-fail', 13 => 'non-redundant-ac-fail',
11 => 'power-safe-mode', 12 => 'non-redundant-dc-fail', 13 => 'non-redundant-ac-fail'
};
my $mapping = {
sc => {
powerSupplyUnitStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.11.2.1.3', map => $map_psu_status },
powerSupplyUnitDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.11.2.1.4' },
powerSupplyUnitDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.11.2.1.4' }
},
sc2 => {
sc2PowerSupplyDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.2.1.3' },
sc2PowerSupplyStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.2.1.5', map => $map_psu_status },
sc2psPowerSupplyLoad => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.2.1.6' },
},
sc2psPowerSupplyLoad => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.2.1.6' }
}
};
my $oid_sc2PowerSupply = '.1.3.6.1.4.1.231.2.10.2.2.10.6.2.1';
my $oid_powerSupplyUnits = '.1.3.6.1.4.1.231.2.10.2.2.5.11.2.1';
@ -63,27 +63,33 @@ sub check_psu {
$self->absent_problem(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s] [value = %s]",
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is '%s' [instance: %s] [value: %s]",
$result->{$options{name}}, $result->{$options{status}}, $instance, $result->{$options{current}}
));
)
);
$exit = $self->get_severity(section => 'psu', value => $result->{$options{status}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Power supply '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}})
);
}
next if (!defined($result->{$options{current}}) || $result->{$options{current}} == 0);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'power', instance => $instance, value => $result->{$options{current}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' is %s W", $result->{$options{name}}, $result->{$options{current}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Power supply '%s' is %s W", $result->{$options{name}}, $result->{$options{current}})
);
}
$self->{output}->perfdata_add(
label => 'power', unit => 'W',
nlabel => 'hardware.powersupply.power.watt',
unit => 'W',
instances => $result->{$options{name}},
value => $result->{$options{current}},
warning => $warn,
@ -96,16 +102,20 @@ sub check_psu {
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking poer supplies");
$self->{output}->output_add(long_msg => 'Checking poer supplies');
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
return if ($self->check_filter(section => 'psu'));
if (defined($self->{results}->{$oid_sc2PowerSupply}) && scalar(keys %{$self->{results}->{$oid_sc2PowerSupply}}) > 0) {
check_psu($self, entry => $oid_sc2PowerSupply, mapping => $mapping->{sc2}, name => 'sc2PowerSupplyDesignation',
current => 'sc2psPowerSupplyLoad', status => 'sc2PowerSupplyStatus');
check_psu(
$self, entry => $oid_sc2PowerSupply, mapping => $mapping->{sc2}, name => 'sc2PowerSupplyDesignation',
current => 'sc2psPowerSupplyLoad', status => 'sc2PowerSupplyStatus'
);
} else {
check_psu($self, entry => $oid_powerSupplyUnits, mapping => $mapping->{sc}, name => 'powerSupplyUnitDesignation',
status => 'powerSupplyUnitStatus');
check_psu(
$self, entry => $oid_powerSupplyUnits, mapping => $mapping->{sc}, name => 'powerSupplyUnitDesignation',
status => 'powerSupplyUnitStatus'
);
}
}

View File

@ -0,0 +1,82 @@
#
# Copyright 2021 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::fujitsu::snmp::mode::components::raid;
use strict;
use warnings;
my $map_raid_status = {
1 => 'unknown', 2 => 'online',
3 => 'degraded', 4 => 'offline',
5 => 'rebuilding', 6 => 'verifying',
7 => 'initializing', 8 => 'morphing',
9 => 'partialDegraded'
};
my $mapping = {
status => { oid => '.1.3.6.1.4.1.231.2.49.1.6.2.1.10', map => $map_raid_status }, # svrLogicalDriveStatus
name => { oid => '.1.3.6.1.4.1.231.2.49.1.6.2.1.11' } # svrLogicalDriveName
};
my $oid_ldrive_table = '.1.3.6.1.4.1.231.2.49.1.6.2'; # svrLogicalDriveTable
sub load {
my ($self) = @_;
push @{$self->{request}}, {
oid => $oid_ldrive_table,
start => $mapping->{status}->{oid},
end => $mapping->{name}->{oid}
};
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'Checking raids');
$self->{components}->{raid} = { name => 'raids', total => 0, skip => 0 };
return if ($self->check_filter(section => 'raid'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $oid_ldrive_table }})) {
next if ($oid !~ /^$mapping->{status}->{oid}\.(\d+)\.(\d+)$/);
my $instance = $1 . '.' . $2;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $oid_ldrive_table }, instance => $instance);
next if ($self->check_filter(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"raid '%s' status is '%s' [instance: %s]",
$result->{name}, $result->{status}, $instance
)
);
my $exit = $self->get_severity(section => 'raid', value => $result->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Raid '%s' status is '%s'", $result->{name}, $result->{status})
);
}
}
}
1;

View File

@ -26,25 +26,25 @@ use warnings;
my $map_sc_temp_status = {
1 => 'unknown', 2 => 'sensor-disabled', 3 => 'ok', 4 => 'sensor-fail',
5 => 'warning-temp-warm', 6 => 'warning-temp-cold', 7 => 'critical-temp-warm',
8 => 'critical-temp-cold', 9 => 'damage-temp-warm', 10 => 'damage-temp-cold', 99 => 'not-available',
8 => 'critical-temp-cold', 9 => 'damage-temp-warm', 10 => 'damage-temp-cold', 99 => 'not-available'
};
my $map_sc2_temp_status = {
1 => 'unknown', 2 => 'not-available', 3 => 'ok', 4 => 'sensor-failed', 5 => 'failed',
6 => 'temperature-warning-toohot', 7 => 'temperature-critical-toohot', 8 => 'temperature-normal',
9 => 'temperature-warning',
9 => 'temperature-warning'
};
my $mapping = {
sc => {
tempSensorStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.2.1.1.3', map => $map_sc_temp_status },
tempCurrentValue => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.2.1.1.11' },
tempSensorDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.2.1.1.13' },
tempSensorDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.2.1.1.13' }
},
sc2 => {
sc2tempSensorDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.5.1.1.3' },
sc2tempSensorStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.5.1.1.5', map => $map_sc2_temp_status },
sc2tempCurrentTemperature => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.5.1.1.6' },
},
sc2tempCurrentTemperature => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.5.1.1.6' }
}
};
my $oid_sc2TemperatureSensors = '.1.3.6.1.4.1.231.2.10.2.2.10.5.1.1';
my $oid_temperatureSensors = '.1.3.6.1.4.1.231.2.10.2.2.5.2.1.1';
@ -69,31 +69,37 @@ sub check_temperature {
$self->absent_problem(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]",
$self->{output}->output_add(
long_msg => sprintf(
"temperature '%s' status is '%s' [instance: %s] [value: %s]",
$result->{$options{name}}, $result->{$options{status}}, $instance, $result->{$options{current}}
));
)
);
$exit = $self->get_severity(section => 'temperature', value => $result->{$options{status}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Temperature '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}})
);
}
next if (!defined($result->{$options{current}}) || $result->{$options{current}} <= 0 || $result->{$options{current}} == 255);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{$options{current}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' is %s V", $result->{$options{name}}, $result->{$options{current}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Temperature '%s' is %s V", $result->{$options{name}}, $result->{$options{current}})
);
}
$self->{output}->perfdata_add(
label => 'temperature', unit => 'C',
nlabel => 'hardware.temperature.celsius',
unit => 'C',
instances => $result->{$options{name}},
value => $result->{$options{current}},
warning => $warn,
critical => $crit,
critical => $crit
);
}
}
@ -101,16 +107,20 @@ sub check_temperature {
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{output}->output_add(long_msg => 'Checking temperatures');
$self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
return if ($self->check_filter(section => 'temperature'));
if (defined($self->{results}->{$oid_sc2TemperatureSensors}) && scalar(keys %{$self->{results}->{$oid_sc2TemperatureSensors}}) > 0) {
check_temperature($self, entry => $oid_sc2TemperatureSensors, mapping => $mapping->{sc2}, name => 'sc2tempSensorDesignation',
current => 'sc2tempCurrentTemperature', status => 'sc2tempSensorStatus');
check_temperature(
$self, entry => $oid_sc2TemperatureSensors, mapping => $mapping->{sc2}, name => 'sc2tempSensorDesignation',
current => 'sc2tempCurrentTemperature', status => 'sc2tempSensorStatus'
);
} else {
check_temperature($self, entry => $oid_temperatureSensors, mapping => $mapping->{sc}, name => 'tempSensorDesignation',
current => 'tempCurrentValue', status => 'tempSensorStatus');
check_temperature(
$self, entry => $oid_temperatureSensors, mapping => $mapping->{sc}, name => 'tempSensorDesignation',
current => 'tempCurrentValue', status => 'tempSensorStatus'
);
}
}

View File

@ -26,25 +26,25 @@ use warnings;
my $map_sc_voltage_status = {
1 => 'unknown', 2 => 'not-available', 3 => 'ok',
4 => 'too-low', 5 => 'too-high', 6 => 'out-of-range',
7 => 'battery-prefailure',
7 => 'battery-prefailure'
};
my $map_sc2_voltage_status = {
1 => 'unknown', 2 => 'not-available', 3 => 'ok',
4 => 'too-low', 5 => 'too-high', 6 => 'out-of-range',
7 => 'warning',
7 => 'warning'
};
my $mapping = {
sc => {
sniScVoltageStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.11.4.1.3', map => $map_sc_voltage_status },
sniScVoltageDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.11.4.1.4' },
sniScVoltageCurrentValue => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.11.4.1.7' },
sniScVoltageCurrentValue => { oid => '.1.3.6.1.4.1.231.2.10.2.2.5.11.4.1.7' }
},
sc2 => {
sc2VoltageDesignation => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.3.1.3' },
sc2VoltageStatus => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.3.1.4', map => $map_sc2_voltage_status },
sc2VoltageCurrentValue => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.3.1.5' },
},
sc2VoltageCurrentValue => { oid => '.1.3.6.1.4.1.231.2.10.2.2.10.6.3.1.5' }
}
};
my $oid_sc2Voltages = '.1.3.6.1.4.1.231.2.10.2.2.10.6.3.1';
my $oid_sniScVoltages = '.1.3.6.1.4.1.231.2.10.2.2.5.11.4.1';
@ -71,31 +71,37 @@ sub check_voltage {
$result->{$options{current}} = $result->{$options{current}} / 1000 if (defined($result->{$options{current}}));
$self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s] [value = %s]",
$self->{output}->output_add(
long_msg => sprintf(
"voltage '%s' status is '%s' [instance: %s] [value: %s]",
$result->{$options{name}}, $result->{$options{status}}, $instance, $result->{$options{current}}
));
)
);
$exit = $self->get_severity(section => 'voltage', value => $result->{$options{status}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Voltage '%s' status is '%s'", $result->{$options{name}}, $result->{$options{status}})
);
}
next if (!defined($result->{$options{current}}));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{$options{current}});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage '%s' is %s V", $result->{$options{name}}, $result->{$options{current}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Voltage '%s' is %s V", $result->{$options{name}}, $result->{$options{current}})
);
}
$self->{output}->perfdata_add(
label => 'voltage', unit => 'V',
nlabel => 'hardware.voltage.volt',
unit => 'V',
instances => $result->{$options{name}},
value => $result->{$options{current}},
warning => $warn,
critical => $crit,
critical => $crit
);
}
}
@ -103,16 +109,20 @@ sub check_voltage {
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking voltages");
$self->{output}->output_add(long_msg => 'Checking voltages');
$self->{components}->{voltage} = { name => 'voltages', total => 0, skip => 0 };
return if ($self->check_filter(section => 'voltage'));
if (defined($self->{results}->{$oid_sc2Voltages}) && scalar(keys %{$self->{results}->{$oid_sc2Voltages}}) > 0) {
check_voltage($self, entry => $oid_sc2Voltages, mapping => $mapping->{sc2}, name => 'sc2VoltageDesignation',
current => 'sc2VoltageCurrentValue', status => 'sc2VoltageStatus');
check_voltage(
$self, entry => $oid_sc2Voltages, mapping => $mapping->{sc2}, name => 'sc2VoltageDesignation',
current => 'sc2VoltageCurrentValue', status => 'sc2VoltageStatus'
);
} else {
check_voltage($self, entry => $oid_sniScVoltages, mapping => $mapping->{sc}, name => 'sniScVoltageDesignation',
current => 'sniScVoltageCurrentValue', status => 'sniScVoltageStatus');
check_voltage(
$self, entry => $oid_sniScVoltages, mapping => $mapping->{sc}, name => 'sniScVoltageDesignation',
current => 'sniScVoltageCurrentValue', status => 'sniScVoltageStatus'
);
}
}

View File

@ -33,6 +33,40 @@ sub set_system {
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
cpu => [
['unknown', 'UNKNOWN'],
['disabled', 'OK'],
['ok', 'OK'],
['not-present', 'OK'],
['error', 'CRITICAL'],
['prefailure-warning', 'WARNING'],
['fail', 'CRITICAL'], # can be failed also
['missing-termination', 'WARNING']
],
disk => [
['unknown', 'UNKNOWN'],
['noDisk', 'OK'],
['online', 'OK'],
['ready', 'OK'],
['failed', 'CRITICAL'],
['rebuilding', 'WARNING'],
['hotspareGlobal', 'OK'],
['hotspareDedicated', 'OK'],
['offline', 'OK'],
['unconfiguredFailed', 'WARNING'],
['formatting', 'WARNING'],
['dead', 'CRITICAL']
],
fan => [
['unknown', 'UNKNOWN'],
['disabled', 'OK'],
['ok', 'OK'],
['prefailure-predicted', 'WARNING'],
['fail', 'CRITICAL'],
['redundant-fan-failed', 'WARNING'],
['not-manageable', 'OK'],
['not-present', 'OK'],
],
memory => [
['unknown', 'UNKNOWN'],
['not-present|not-available', 'OK'],
@ -47,52 +81,6 @@ sub set_system {
['raid', 'OK'],
['hidden', 'OK']
],
cpu => [
['unknown', 'UNKNOWN'],
['disabled', 'OK'],
['ok', 'OK'],
['not-present', 'OK'],
['error', 'CRITICAL'],
['prefailure-warning', 'WARNING'],
['fail', 'CRITICAL'], # can be failed also
['missing-termination', 'WARNING']
],
voltage => [
['unknown', 'UNKNOWN'],
['not-available', 'OK'],
['ok', 'OK'],
['too-low', 'WARNING'],
['too-high', 'WARNING'],
['out-of-range', 'CRITICAL'],
['battery-prefailure', 'CRITICAL'],
['warning', 'WARNING']
],
fan => [
['unknown', 'UNKNOWN'],
['disabled', 'OK'],
['ok', 'OK'],
['prefailure-predicted', 'WARNING'],
['fail', 'CRITICAL'],
['redundant-fan-failed', 'WARNING'],
['not-manageable', 'OK'],
['not-present', 'OK'],
],
temperature => [
['unknown', 'UNKNOWN'],
['sensor-disabled', 'OK'],
['ok', 'OK'],
['sensor-fail', 'CRITICAL'], # can be also sensor-failed
['warning-temp-warm', 'WARNING'],
['warning-temp-cold', 'WARNING'],
['critical-temp-warm', 'CRITICAL'],
['critical-temp-cold', 'CRITICAL'],
['damage-temp-warm', 'WARNING'],
['damage-temp-cold', 'CRITICAL'],
['not-available', 'OK'],
['temperature-warning', 'WARNING'], # can be also temperature-warning-toohot
['temperature-critical-toohot', 'CRITICAL'],
['temperature-normal', 'OK']
],
psu => [
['unknown', 'UNKNOWN'],
['not-present', 'OK'],
@ -110,11 +98,48 @@ sub set_system {
['degraded', 'WARNING'],
['critical', 'CRITICAL']
],
raid => [
['unknown', 'UNKNOWN'],
['online', 'OK'],
['degraded', 'WARNING'],
['offline', 'ok'],
['rebuilding', 'WARNING'],
['verifying', 'OK'],
['initializing', 'OK'],
['morphing', 'OK'],
['partialDegraded', 'WARNING']
],
temperature => [
['unknown', 'UNKNOWN'],
['sensor-disabled', 'OK'],
['ok', 'OK'],
['sensor-fail', 'CRITICAL'], # can be also sensor-failed
['warning-temp-warm', 'WARNING'],
['warning-temp-cold', 'WARNING'],
['critical-temp-warm', 'CRITICAL'],
['critical-temp-cold', 'CRITICAL'],
['damage-temp-warm', 'WARNING'],
['damage-temp-cold', 'CRITICAL'],
['not-available', 'OK'],
['temperature-warning', 'WARNING'], # can be also temperature-warning-toohot
['temperature-critical-toohot', 'CRITICAL'],
['temperature-normal', 'OK']
],
voltage => [
['unknown', 'UNKNOWN'],
['not-available', 'OK'],
['ok', 'OK'],
['too-low', 'WARNING'],
['too-high', 'WARNING'],
['out-of-range', 'CRITICAL'],
['battery-prefailure', 'CRITICAL'],
['warning', 'WARNING']
]
};
$self->{components_path} = 'hardware::server::fujitsu::snmp::mode::components';
$self->{components_module} = ['fan', 'voltage', 'psu', 'memory', 'cpu', 'temperature'];
$self->{components_module} = ['cpu', 'disk', 'fan', 'memory', 'psu', 'raid', 'temperature', 'voltage'];
}
sub snmp_execute {
@ -126,7 +151,7 @@ sub snmp_execute {
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {});

View File

@ -30,9 +30,9 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'hardware' => 'hardware::server::fujitsu::snmp::mode::hardware',
);
$self->{modes} = {
'hardware' => 'hardware::server::fujitsu::snmp::mode::hardware'
};
return $self;
}