add fujitsu snmp plugin

This commit is contained in:
qgarnier 2017-09-05 14:22:10 +02:00
parent d1d7eeaf4b
commit 3b7c40bf1f
8 changed files with 883 additions and 0 deletions

View File

@ -0,0 +1,95 @@
#
# Copyright 2017 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::cpu;
use strict;
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',
};
my $map_sc2_cpu_status = {
1 => 'unknown', 2 => 'not-present', 3 => 'ok', 4 => 'disabled', 5 => 'error',
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 },
},
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 },
},
};
my $oid_sc2CPUs = '.1.3.6.1.4.1.231.2.10.2.2.10.6.4.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sc2CPUs, end => $mapping->{sc2}->{sc2cpuStatus} }, { oid => $mapping->{sc}->{cpuStatus}->{oid} };
}
sub check_cpu {
my ($self, %options) = @_;
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
next if ($oid !~ /^$options{mapping}->{$options{status}}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
$result->{instance} = $instance;
next if ($self->check_filter(section => 'cpu', instance => $instance));
next if ($result->{$options{status}} =~ /not-present|not-available/i &&
$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,
));
$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}}));
}
}
}
sub check {
my ($self) = @_;
$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');
} else {
check_cpu($self, entry => $mapping->{sc}->{cpuStatus}, mapping => $mapping->{sc}, name => 'instance',
status => 'cpuStatus');
}
}
1;

View File

@ -0,0 +1,116 @@
#
# Copyright 2017 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::fan;
use strict;
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',
};
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',
};
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' },
},
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' },
},
};
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';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sc2Fans, end => $mapping->{sc2}->{sc2fanCurrentSpeed} }, { oid => $oid_fans };
}
sub check_fan {
my ($self, %options) = @_;
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
next if ($oid !~ /^$options{mapping}->{$options{status}}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance));
next if ($result->{$options{status}} =~ /not-present|not-available/i &&
$self->absent_problem(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++;
$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}}));
}
next if (!defined($result->{$options{speed}}) || $result->{$options{speed}} == -1);
($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}->perfdata_add(label => 'fan_' . $result->{$options{name}}, unit => 'rpm',
value => $result->{$options{speed}},
warning => $warn,
critical => $crit,
min => 0
);
}
}
sub check {
my ($self) = @_;
$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');
} else {
check_fan($self, entry => $oid_fans, mapping => $mapping->{sc}, name => 'fanDesignation',
speed => 'fanCurrentSpeed', status => 'fanStatus');
}
}
1;

View File

@ -0,0 +1,96 @@
#
# Copyright 2017 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::memory;
use strict;
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',
};
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',
};
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 },
},
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 },
},
};
my $oid_sc2MemoryModules = '.1.3.6.1.4.1.231.2.10.2.2.10.6.5.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sc2MemoryModules, end => $mapping->{sc2}->{sc2memModuleStatus} }, { oid => $mapping->{sc}->{memModuleStatus}->{oid} };
}
sub check_memory {
my ($self, %options) = @_;
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
next if ($oid !~ /^$options{mapping}->{$options{status}}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
$result->{instance} = $instance;
next if ($self->check_filter(section => 'memory', instance => $instance));
next if ($result->{$options{status}} =~ /not-present|not-available/i &&
$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,
));
$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}}));
}
}
}
sub check {
my ($self) = @_;
$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');
} else {
check_memory($self, entry => $mapping->{sc}->{memModuleStatus}, mapping => $mapping->{sc}, name => 'instance',
status => 'memModuleStatus');
}
}
1;

View File

@ -0,0 +1,109 @@
#
# Copyright 2017 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::psu;
use strict;
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',
};
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' },
},
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' },
},
};
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';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sc2PowerSupply }, { oid => $oid_powerSupplyUnits };
}
sub check_psu {
my ($self, %options) = @_;
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
next if ($oid !~ /^$options{mapping}->{$options{status}}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
next if ($result->{$options{status}} =~ /not-present|not-available/i &&
$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]",
$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}}));
}
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}->perfdata_add(label => 'power_' . $result->{$options{name}}, unit => 'W',
value => $result->{$options{current}},
warning => $warn,
critical => $crit,
min => 0
);
}
}
sub check {
my ($self) = @_;
$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');
} else {
check_psu($self, entry => $oid_powerSupplyUnits, mapping => $mapping->{sc}, name => 'powerSupplyUnitDesignation',
status => 'powerSupplyUnitStatus');
}
}
1;

View File

@ -0,0 +1,114 @@
#
# Copyright 2017 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::temperature;
use strict;
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',
};
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',
};
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' },
},
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' },
},
};
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';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sc2TemperatureSensors, end => $mapping->{sc2}->{sc2tempCurrentTemperature} }, { oid => $oid_temperatureSensors };
}
sub check_temperature {
my ($self, %options) = @_;
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
next if ($oid !~ /^$options{mapping}->{$options{status}}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance));
next if ($result->{$options{status}} =~ /not-present|not-available/i &&
$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]",
$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}}));
}
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}->perfdata_add(label => 'temperature_' . $result->{$options{name}}, unit => 'C',
value => $result->{$options{current}},
warning => $warn,
critical => $crit,
);
}
}
sub check {
my ($self) = @_;
$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');
} else {
check_temperature($self, entry => $oid_temperatureSensors, mapping => $mapping->{sc}, name => 'tempSensorDesignation',
current => 'tempCurrentValue', status => 'tempSensorStatus');
}
}
1;

View File

@ -0,0 +1,116 @@
#
# Copyright 2017 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::voltage;
use strict;
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',
};
my $map_sc2_voltage_status = {
1 => 'unknown', 2 => 'not-available', 3 => 'ok',
4 => 'too-low', 5 => 'too-high', 6 => 'out-of-range',
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' },
},
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' },
},
};
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';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_sc2Voltages, end => $mapping->{sc2}->{sc2VoltageCurrentValue} }, { oid => $oid_sniScVoltages };
}
sub check_voltage {
my ($self, %options) = @_;
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
next if ($oid !~ /^$options{mapping}->{$options{status}}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
next if ($self->check_filter(section => 'voltage', instance => $instance));
next if ($result->{$options{status}} =~ /not-present|not-available/i &&
$self->absent_problem(section => 'voltage', instance => $instance));
$self->{components}->{voltage}->{total}++;
$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]",
$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}}));
}
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}->perfdata_add(label => 'voltage_' . $result->{$options{name}}, unit => 'V',
value => $result->{$options{current}},
warning => $warn,
critical => $crit,
);
}
}
sub check {
my ($self) = @_;
$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');
} else {
check_voltage($self, entry => $oid_sniScVoltages, mapping => $mapping->{sc}, name => 'sniScVoltageDesignation',
current => 'sniScVoltageCurrentValue', status => 'sniScVoltageStatus');
}
}
1;

View File

@ -0,0 +1,189 @@
#
# Copyright 2017 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::hardware;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(temperature|fan|psu|voltage|cpu|memory)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan|voltage|power)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
memory => [
['unknown', 'UNKNOWN'],
['not-present|not-available', 'OK'],
['ok', 'OK'],
['disabled', 'OK'],
['error', 'CRITICAL'],
['prefailure-predicted|prefailure-warning', 'WARNING'],
['fail', 'CRITICAL'], # can be failed
['disabled', 'OK'],
['hot-spare', 'OK'],
['mirror', 'OK'],
['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'],
['ok', 'OK'],
['ac-fail', 'CRITICAL'],
['dc-fail', 'CRITICAL'],
['failed', 'CRITICAL'],
['critical-temperature', 'CRITICAL'],
['not-manageable', 'OK'],
['fan-failure-predicted', 'WARNING'],
['fan-failure', 'CRITICAL'],
['power-safe-mode', 'WARNING'],
['non-redundant-dc-fail', 'WARNING'],
['non-redundant-ac-fail', 'WARNING'],
['degraded', 'WARNING'],
['critical', 'CRITICAL'],
],
};
$self->{components_path} = 'hardware::server::fujitsu::snmp::mode::components';
$self->{components_module} = ['fan', 'voltage', 'psu', 'memory', 'cpu', 'temperature'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'temperature', 'fan', 'psu', 'voltage', 'cpu', 'memory'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=temperature)
Can also exclude specific instance: --filter=temperature,1
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping)
Can be specific or global: --absent-problem="fan,1.1"
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='psu,CRITICAL,^(?!(ok)$)'
=item B<--warning>
Set warning threshold (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,40'
=back
=cut

View File

@ -0,0 +1,48 @@
#
# Copyright 2017 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::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'hardware' => 'hardware::server::fujitsu::snmp::mode::hardware',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Fujitsu server in SNMP.
=cut