From 0c94ea6f6baa4057d5afe9e16240e3f6de361d34 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 18 Apr 2019 11:35:29 +0200 Subject: [PATCH] WIP: new perfdata system --- .../raritan/snmp/mode/components/resources.pm | 48 +++++++++---------- .../raritan/snmp/mode/components/sensor.pm | 22 +++++---- .../pdu/raritan/snmp/mode/ocprotsensors.pm | 7 ++- .../pdu/raritan/snmp/mode/outletsensors.pm | 7 ++- .../dell/cmc/snmp/mode/components/chassis.pm | 18 ++++--- .../dell/cmc/snmp/mode/components/psu.pm | 20 ++++---- .../cmc/snmp/mode/components/temperature.pm | 20 ++++---- .../idrac/snmp/mode/components/amperage.pm | 15 +++--- .../snmp/mode/components/coolingdevice.pm | 15 +++--- .../idrac/snmp/mode/components/temperature.pm | 15 +++--- .../idrac/snmp/mode/components/voltage.pm | 15 +++--- .../openmanage/snmp/mode/components/fan.pm | 15 +++--- .../openmanage/snmp/mode/components/psu.pm | 15 +++--- .../snmp/mode/components/temperature.pm | 15 +++--- .../bladechassis/snmp/mode/components/psu.pm | 33 +++++++++---- .../snmp/mode/components/temperature.pm | 10 ++-- .../hp/proliant/snmp/mode/components/fan.pm | 10 ++-- .../hp/proliant/snmp/mode/components/psu.pm | 20 +++++--- .../snmp/mode/components/temperature.pm | 14 ++++-- .../lenovo/xcc/snmp/mode/components/fan.pm | 13 +++-- .../xcc/snmp/mode/components/temperature.pm | 12 +++-- .../xcc/snmp/mode/components/voltage.pm | 12 +++-- hardware/server/sun/mseries/mode/hardware.pm | 22 +++++---- .../server/supermicro/snmp/mode/hardware.pm | 14 ++++-- network/a10/ax/snmp/mode/hardware.pm | 31 +++++++----- network/brocade/snmp/mode/hardware.pm | 20 ++++---- network/nokia/timos/snmp/mode/hardware.pm | 13 +++-- storage/purestorage/restapi/mode/hardware.pm | 13 +++-- 28 files changed, 295 insertions(+), 189 deletions(-) diff --git a/hardware/pdu/raritan/snmp/mode/components/resources.pm b/hardware/pdu/raritan/snmp/mode/components/resources.pm index eece42266..c5fa2c8f5 100644 --- a/hardware/pdu/raritan/snmp/mode/components/resources.pm +++ b/hardware/pdu/raritan/snmp/mode/components/resources.pm @@ -33,29 +33,29 @@ our @ISA = qw(Exporter); our @EXPORT_OK = qw($thresholds $mapping %raritan_type %map_type); my %map_units = ( - -1 => '', # none - 0 => 'other', - 1 => 'V', # volt, - 2 => 'A', # amp, - 3 => 'W', # watt - 4 => 'voltamp', - 5 => 'wattHour', - 6 => 'voltampHour', - 7 => 'C', # degreeC - 8 => 'Hz', # hertz - 9 => '%', # percent - 10 => 'meterpersec', - 11 => 'pascal', - 12 => 'psi', - 13 => 'g', - 14 => 'degreeF', - 15 => 'feet', - 16 => 'inches', - 17 => 'cm', - 18 => 'meters', - 19 => 'rpm', - 20 => 'degrees', - 21 => 'lux', + -1 => { unit => '' }, # none + 0 => { unit => 'other', nunit => 'count' }, + 1 => { unit => 'V', nunit => 'volt' }, # volt, + 2 => { unit => 'A', nunit => 'ampere' }, # amp, + 3 => { unit => 'W', nunit => 'watt' }, # watt + 4 => { unit => 'voltamp' }, + 5 => { unit => 'wattHour' }, + 6 => { unit => 'voltampHour' }, + 7 => { unit => 'C', nunit => 'celsius' }, # degreeC + 8 => { unit => 'Hz', nunit => 'hertz' }, # hertz + 9 => { unit => '%', nunit => 'percentage' }, # percent + 10 => { unit => 'meterpersec' }, + 11 => { unit => 'pascal' }, + 12 => { unit => 'psi' }, + 13 => { unit => 'g' }, + 14 => { unit => 'degreeF', nunit => 'fahrenheit' }, + 15 => { unit => 'feet' }, + 16 => { unit => 'inches' }, + 17 => { unit => 'cm' }, + 18 => { unit => 'meters' }, + 19 => { unit => 'rpm' }, + 20 => { unit => 'degrees' }, + 21 => { unit => 'lux' }, ); my %map_state = ( @@ -247,4 +247,4 @@ $thresholds = { ], }; -1; \ No newline at end of file +1; diff --git a/hardware/pdu/raritan/snmp/mode/components/sensor.pm b/hardware/pdu/raritan/snmp/mode/components/sensor.pm index 706e5c003..4949c1d36 100644 --- a/hardware/pdu/raritan/snmp/mode/components/sensor.pm +++ b/hardware/pdu/raritan/snmp/mode/components/sensor.pm @@ -74,7 +74,7 @@ sub check { } $self->{output}->output_add(long_msg => sprintf("'%s' %s state is '%s' [instance: %s, value: %s, unit: %s, label: %s]", $instance, $component, $result->{State}, - $instance, $value, $result->{Unit}, $result2->{Label})); + $instance, $value, $result->{Unit}->{unit}, $result2->{Label})); my $exit = $self->get_severity(section => $component, label => $value_type, instance => $instance, value => $result->{State}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { @@ -84,7 +84,7 @@ sub check { } if ($value =~ /[0-9]/) { - next if ($value =~ /^0$/ && $result->{Unit} eq ''); + next if ($value =~ /^0$/ && $result->{Unit}->{unit} eq ''); my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => $component, instance => $instance, value => $value); if ($checked == 0) { $result->{EnabledThresholds} = oct("0b". unpack('b*', $result->{EnabledThresholds})); @@ -114,15 +114,21 @@ sub check { if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit2, short_msg => sprintf("'%s' %s value is %s %s", - $instance, $component, $value, $result->{Unit})); + $instance, $component, $value, $result->{Unit}->{unit})); } - $self->{output}->perfdata_add(label => $instance . "_" . $component, unit => $result->{Unit}, - value => $value, - warning => $warn, - critical => $crit); + + my $nunit = (!defined($result->{Unit}->{nunit}) ? $result->{Unit}->{nunit} : lc($result->{Unit}->{unit})); + $self->{output}->perfdata_add( + label => $component, unit => $result->{Unit}->{unit}, + nlabel => 'hardware.sensor.' . $options{type} . '.' . lc($component) . '.' . $nunit, + instances => $instance, + value => $value, + warning => $warn, + critical => $crit + ); } } } } -1; \ No newline at end of file +1; diff --git a/hardware/pdu/raritan/snmp/mode/ocprotsensors.pm b/hardware/pdu/raritan/snmp/mode/ocprotsensors.pm index 9a8285a07..84e8ca213 100644 --- a/hardware/pdu/raritan/snmp/mode/ocprotsensors.pm +++ b/hardware/pdu/raritan/snmp/mode/ocprotsensors.pm @@ -80,9 +80,8 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } @@ -129,4 +128,4 @@ Example: --critical='powerQuality,.*,40' =back -=cut \ No newline at end of file +=cut diff --git a/hardware/pdu/raritan/snmp/mode/outletsensors.pm b/hardware/pdu/raritan/snmp/mode/outletsensors.pm index 782c5b0a5..dc6ba649b 100644 --- a/hardware/pdu/raritan/snmp/mode/outletsensors.pm +++ b/hardware/pdu/raritan/snmp/mode/outletsensors.pm @@ -80,9 +80,8 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } @@ -129,4 +128,4 @@ Example: --critical='powerQuality,.*,40' =back -=cut \ No newline at end of file +=cut diff --git a/hardware/server/dell/cmc/snmp/mode/components/chassis.pm b/hardware/server/dell/cmc/snmp/mode/components/chassis.pm index 483d013bf..a36ca0114 100644 --- a/hardware/server/dell/cmc/snmp/mode/components/chassis.pm +++ b/hardware/server/dell/cmc/snmp/mode/components/chassis.pm @@ -25,8 +25,8 @@ use warnings; # In MIB 'DELL-RAC-MIB' my $mapping = { - drsWattsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.13', section => 'power', label => 'power', unit => 'W' }, - drsAmpsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.14', section => 'current', label => 'current', unit => 'A' }, + drsWattsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.13', section => 'power', label => 'power', unit => 'watt' }, + drsAmpsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.14', section => 'current', label => 'current', unit => 'ampere' }, }; my $oid_drsCMCPowerTableEntrydrsCMCPowerTableEntry = '.1.3.6.1.4.1.674.10892.2.4.1.1'; @@ -63,12 +63,16 @@ sub check { short_msg => sprintf("Chassis '%s' %s is %s%s", $instance, $mapping->{$probe}->{section}, $result->{$probe}, $mapping->{$probe}->{unit})); } - $self->{output}->perfdata_add(label => 'chassis_' . $mapping->{$probe}->{label} . '_' . $instance, unit => $mapping->{$probe}->{unit}, - value => $result->{$probe}, - warning => $warn, - critical => $crit); + $self->{output}->perfdata_add( + label => 'chassis_' . $mapping->{$probe}->{label}, unit => $mapping->{$probe}->{unit}, + nlabel => 'hardware.chassis.' . $mapping->{$probe}->{label} . '.' . $mapping->{$probe}->{unit}, + instances => $instance, + value => $result->{$probe}, + warning => $warn, + critical => $crit + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/cmc/snmp/mode/components/psu.pm b/hardware/server/dell/cmc/snmp/mode/components/psu.pm index 5cd98df3b..a0d15df09 100644 --- a/hardware/server/dell/cmc/snmp/mode/components/psu.pm +++ b/hardware/server/dell/cmc/snmp/mode/components/psu.pm @@ -33,9 +33,9 @@ my %map_psu_capable = ( my $mapping = { drsPSULocation => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.3' }, drsPSUMonitoringCapable => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.4', map => \%map_psu_capable }, - drsPSUVoltsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.5', section => 'voltage', label => 'voltage', unit => 'V' }, - drsPSUAmpsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.6', section => 'current', label => 'current', unit => 'A' }, - drsPSUWattsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.7', section => 'power', label => 'power', unit => 'W' }, + drsPSUVoltsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.5', section => 'voltage', label => 'voltage', unit => 'volt' }, + drsPSUAmpsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.6', section => 'current', label => 'current', unit => 'ampere' }, + drsPSUWattsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.7', section => 'power', label => 'power', unit => 'watt' }, }; my $oid_drsCMCPSUTableEntry = '.1.3.6.1.4.1.674.10892.2.4.2.1'; @@ -73,12 +73,16 @@ sub check { short_msg => sprintf("Power supply '%s' %s is %s%s", $result->{drsPSULocation}, $mapping->{$probe}->{section}, $result->{$probe}, $mapping->{$probe}->{unit})); } - $self->{output}->perfdata_add(label => 'psu_' . $mapping->{$probe}->{label} . '_' . $instance, unit => $mapping->{$probe}->{unit}, - value => $result->{$probe}, - warning => $warn, - critical => $crit); + $self->{output}->perfdata_add( + label => 'psu_' . $mapping->{$probe}->{label}, unit => $mapping->{$probe}->{unit}, + nlabel => 'hardware.' . $mapping->{$probe}->{label} . '.' . $mapping->{$probe}->{unit}, + instances => $instance, + value => $result->{$probe}, + warning => $warn, + critical => $crit + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/cmc/snmp/mode/components/temperature.pm b/hardware/server/dell/cmc/snmp/mode/components/temperature.pm index 8086d65ef..30aa9e7b1 100644 --- a/hardware/server/dell/cmc/snmp/mode/components/temperature.pm +++ b/hardware/server/dell/cmc/snmp/mode/components/temperature.pm @@ -25,9 +25,9 @@ use warnings; # In MIB 'DELL-RAC-MIB' my $mapping = { - drsChassisFrontPanelAmbientTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.10', instance => 'chassis', label => 'temp_chassis', descr => 'Chassis Ambient temperature' }, - drsCMCAmbientTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.11', instance => 'ambient', label => 'temp_ambient', descr => 'CMC Ambient temperarture' }, - drsCMCProcessorTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.12', instance => 'processor', label => 'temp_processor', descr => 'Processor temperature' }, + drsChassisFrontPanelAmbientTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.10', instance => 'chassis', descr => 'Chassis Ambient temperature' }, + drsCMCAmbientTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.11', instance => 'ambient', descr => 'CMC Ambient temperarture' }, + drsCMCProcessorTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.12', instance => 'processor', descr => 'Processor temperature' }, }; my $oid_drsChassisStatusGroup = '.1.3.6.1.4.1.674.10892.2.3'; @@ -61,11 +61,15 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("%s is %sC", $mapping->{$probe}->{descr}, $result->{$probe})); } - $self->{output}->perfdata_add(label => $mapping->{$probe}->{label}, unit => 'C', - value => $result->{$probe}, - warning => $warn, - critical => $crit); + $self->{output}->perfdata_add( + label => 'temp', unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => $mapping->{$probe}->{instance}, + value => $result->{$probe}, + warning => $warn, + critical => $crit + ); } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/amperage.pm b/hardware/server/dell/idrac/snmp/mode/components/amperage.pm index caad1f879..8eb118bf4 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/amperage.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/amperage.pm @@ -110,13 +110,16 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Amperage '%s' is %s %s", $result->{amperageProbeLocationName}, $result->{amperageProbeReading}, $unit)); } - $self->{output}->perfdata_add(label => 'amperage_' . $result->{amperageProbeLocationName}, unit => $unit, - value => $result->{amperageProbeReading}, - warning => $warn, - critical => $crit, - ); + $self->{output}->perfdata_add( + label => 'amperage', unit => $unit, + nlabel => 'hardware.probe.amperage.' . ($unit eq 'A' ? 'ampere' : 'watt'), + instances => $result->{amperageProbeLocationName}, + value => $result->{amperageProbeReading}, + warning => $warn, + critical => $crit, + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm b/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm index 327ea0c56..558d1763b 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm @@ -101,13 +101,16 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Cooling device '%s' is %s rpm", $result->{coolingDeviceLocationName}, $result->{coolingDeviceReading})); } - $self->{output}->perfdata_add(label => 'fan_' . $result->{coolingDeviceLocationName}, unit => 'rpm', - value => $result->{coolingDeviceReading}, - warning => $warn, - critical => $crit, - ); + $self->{output}->perfdata_add( + label => 'fan', unit => 'rpm', + nlabel => 'hardware.fan.speed.rpm', + instances => $result->{coolingDeviceLocationName}, + value => $result->{coolingDeviceReading}, + warning => $warn, + critical => $crit, + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/temperature.pm b/hardware/server/dell/idrac/snmp/mode/components/temperature.pm index 8964fdc1f..ea81c9cac 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/temperature.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/temperature.pm @@ -109,13 +109,16 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Temperature '%s' is %s degree centigrade", $result->{temperatureProbeLocationName}, $result->{temperatureProbeReading})); } - $self->{output}->perfdata_add(label => 'temp_' . $result->{temperatureProbeLocationName}, unit => 'C', - value => $result->{temperatureProbeReading}, - warning => $warn, - critical => $crit, - ); + $self->{output}->perfdata_add( + label => 'temp', unit => 'C', + nlabel => 'hardware.probe.temperature.celsius', + instances => $result->{temperatureProbeLocationName}, + value => $result->{temperatureProbeReading}, + warning => $warn, + critical => $crit, + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/voltage.pm b/hardware/server/dell/idrac/snmp/mode/components/voltage.pm index 0ba98b994..fd37b8ad3 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/voltage.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/voltage.pm @@ -101,13 +101,16 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Voltage '%s' is %s V", $result->{voltageProbeLocationName}, $result->{voltageProbeReading})); } - $self->{output}->perfdata_add(label => 'voltage_' . $result->{voltageProbeLocationName}, unit => 'V', - value => $result->{voltageProbeReading}, - warning => $warn, - critical => $crit, - ); + $self->{output}->perfdata_add( + label => 'voltage', unit => 'V', + nlabel => 'hardware.probe.voltage.volt', + instances => $result->{voltageProbeLocationName}, + value => $result->{voltageProbeReading}, + warning => $warn, + critical => $crit, + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/openmanage/snmp/mode/components/fan.pm b/hardware/server/dell/openmanage/snmp/mode/components/fan.pm index a826ef9c0..815ed3fca 100644 --- a/hardware/server/dell/openmanage/snmp/mode/components/fan.pm +++ b/hardware/server/dell/openmanage/snmp/mode/components/fan.pm @@ -88,12 +88,15 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Fan '%s' speed is %s rpm", $instance, $result->{coolingDeviceReading})); } - $self->{output}->perfdata_add(label => 'fan_' . $instance, unit => 'rpm', - value => $result->{coolingDeviceReading}, - warning => $warn, - critical => $crit, - min => 0 - ); + $self->{output}->perfdata_add( + label => 'fan', unit => 'rpm', + nlabel => 'hardware.fan.speed.rpm', + instances => $instance, + value => $result->{coolingDeviceReading}, + warning => $warn, + critical => $crit, + min => 0 + ); } } } diff --git a/hardware/server/dell/openmanage/snmp/mode/components/psu.pm b/hardware/server/dell/openmanage/snmp/mode/components/psu.pm index 6b333c64e..e55704144 100644 --- a/hardware/server/dell/openmanage/snmp/mode/components/psu.pm +++ b/hardware/server/dell/openmanage/snmp/mode/components/psu.pm @@ -119,12 +119,15 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Power supply '%s' power is %s W", $instance, $result->{powerSupplyOutputWatts})); } - $self->{output}->perfdata_add(label => 'psu_power_' . $instance, unit => 'W', - value => $result->{powerSupplyOutputWatts}, - warning => $warn, - critical => $crit, - min => 0 - ); + $self->{output}->perfdata_add( + label => 'psu_power', unit => 'W', + nlabel => 'hardware.powersupply.power.watt', + instances => $instance, + value => $result->{powerSupplyOutputWatts}, + warning => $warn, + critical => $crit, + min => 0 + ); } } } diff --git a/hardware/server/dell/openmanage/snmp/mode/components/temperature.pm b/hardware/server/dell/openmanage/snmp/mode/components/temperature.pm index cd7d38bf1..e37c7f710 100644 --- a/hardware/server/dell/openmanage/snmp/mode/components/temperature.pm +++ b/hardware/server/dell/openmanage/snmp/mode/components/temperature.pm @@ -92,12 +92,15 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Temperature '%s' is %s degree centigrade", $instance, $result->{temperatureProbeReading})); } - $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', - value => $result->{temperatureProbeReading}, - warning => $warn, - critical => $crit, - min => 0 - ); + $self->{output}->perfdata_add( + label => 'temp', unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => $instance, + value => $result->{temperatureProbeReading}, + warning => $warn, + critical => $crit, + min => 0 + ); } } } diff --git a/hardware/server/hp/bladechassis/snmp/mode/components/psu.pm b/hardware/server/hp/bladechassis/snmp/mode/components/psu.pm index 76bdd9c86..5e44e2b67 100644 --- a/hardware/server/hp/bladechassis/snmp/mode/components/psu.pm +++ b/hardware/server/hp/bladechassis/snmp/mode/components/psu.pm @@ -136,20 +136,35 @@ sub check { $psu_index, $map_conditions{$psu_condition})); } - $self->{output}->perfdata_add(label => "psu_" . $psu_index . "_power", unit => 'W', - value => $psu_pwrout); + $self->{output}->perfdata_add( + label => 'psu_power', unit => 'W', + nlabel => 'hardware.powersupply.power.watt', + instances => $psu_index, + value => $psu_pwrout + ); if (defined($psu_intemp) && $psu_intemp != -1) { - $self->{output}->perfdata_add(label => "psu_" . $psu_index . "_temp_intake", unit => 'C', - value => $psu_intemp); + $self->{output}->perfdata_add( + label => 'psu_temp', unit => 'C', + nlabel => 'hardware.powersupply.temperature.celsius', + instances => [$psu_index, 'intake'], + value => $psu_intemp + ); } if (defined($psu_exhtemp) && $psu_exhtemp != -1) { - $self->{output}->perfdata_add(label => "psu_" . $psu_index . "_temp_exhaust", unit => 'C', - value => $psu_exhtemp); + $self->{output}->perfdata_add( + label => 'psu_temp', unit => 'C', + nlabel => 'hardware.powersupply.temperature.celsius', + instances => [$psu_index, 'exhaust'], + value => $psu_exhtemp + ); } } - $self->{output}->perfdata_add(label => "total_power", unit => 'W', - value => $total_watts); + $self->{output}->perfdata_add( + label => 'total_power', unit => 'W', + nlabel => 'hardware.powersupply.power.watt', + value => $total_watts + ); } -1; \ No newline at end of file +1; diff --git a/hardware/server/hp/bladechassis/snmp/mode/components/temperature.pm b/hardware/server/hp/bladechassis/snmp/mode/components/temperature.pm index 2f55c1bbb..2eb61307b 100644 --- a/hardware/server/hp/bladechassis/snmp/mode/components/temperature.pm +++ b/hardware/server/hp/bladechassis/snmp/mode/components/temperature.pm @@ -98,9 +98,13 @@ sub check { $temp_index, $map_conditions{$temp_condition})); } - $self->{output}->perfdata_add(label => "temp_" . $temp_index, unit => 'C', - value => $temp_current, - warning => $temp_threshold); + $self->{output}->perfdata_add( + label => "temp", unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => $temp_index, + value => $temp_current, + warning => $temp_threshold + ); } } diff --git a/hardware/server/hp/proliant/snmp/mode/components/fan.pm b/hardware/server/hp/proliant/snmp/mode/components/fan.pm index 0c2770f2c..c2bcec34d 100644 --- a/hardware/server/hp/proliant/snmp/mode/components/fan.pm +++ b/hardware/server/hp/proliant/snmp/mode/components/fan.pm @@ -114,10 +114,14 @@ sub check { } if (defined($result->{cpqHeFltTolFanCurrentSpeed})) { - $self->{output}->perfdata_add(label => "fan_speed_" . $instance, unit => 'rpm', - value => $result->{cpqHeFltTolFanCurrentSpeed}); + $self->{output}->perfdata_add( + label => 'fan_speed', unit => 'rpm', + nlabel => 'hardware.fan.speed.rpm', + instances => $instance, + value => $result->{cpqHeFltTolFanCurrentSpeed} + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/hp/proliant/snmp/mode/components/psu.pm b/hardware/server/hp/proliant/snmp/mode/components/psu.pm index 5c4d270d6..36e60e98d 100644 --- a/hardware/server/hp/proliant/snmp/mode/components/psu.pm +++ b/hardware/server/hp/proliant/snmp/mode/components/psu.pm @@ -115,12 +115,20 @@ sub check { $instance, $result->{cpqHeFltTolPowerSupplyCondition})); } - $self->{output}->perfdata_add(label => "psu_power_" . $instance, unit => 'W', - value => $result->{cpqHeFltTolPowerSupplyCapacityUsed}, - critical => $result->{cpqHeFltTolPowerSupplyCapacityMaximum}); - $self->{output}->perfdata_add(label => "psu_voltage" . $instance, unit => 'V', - value => $result->{cpqHeFltTolPowerSupplyMainVoltage}); + $self->{output}->perfdata_add( + label => 'psu_power', unit => 'W', + nlabel => 'hardware.powersupply.power.watt', + instances => $instance, + value => $result->{cpqHeFltTolPowerSupplyCapacityUsed}, + critical => $result->{cpqHeFltTolPowerSupplyCapacityMaximum} + ); + $self->{output}->perfdata_add( + label => 'psu_voltage', unit => 'V', + nlabel => 'hardware.powersupply.voltage.volt', + instances => $instance, + value => $result->{cpqHeFltTolPowerSupplyMainVoltage} + ); } } -1; \ No newline at end of file +1; diff --git a/hardware/server/hp/proliant/snmp/mode/components/temperature.pm b/hardware/server/hp/proliant/snmp/mode/components/temperature.pm index a12b5bc77..e59dd59fe 100644 --- a/hardware/server/hp/proliant/snmp/mode/components/temperature.pm +++ b/hardware/server/hp/proliant/snmp/mode/components/temperature.pm @@ -105,12 +105,16 @@ sub check { $self->{output}->output_add(severity => $exit2, short_msg => sprintf("Temperature '%s' %s is %s degree centigrade", $instance, $result->{cpqHeTemperatureLocale}, $result->{cpqHeTemperatureCelsius})); } - $self->{output}->perfdata_add(label => "temp_" . $instance . "_" . $result->{cpqHeTemperatureLocale}, unit => 'C', - value => $result->{cpqHeTemperatureCelsius}, - warning => $warn, - critical => $crit); + $self->{output}->perfdata_add( + label => "temp", unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => [$instance, $result->{cpqHeTemperatureLocale}], + value => $result->{cpqHeTemperatureCelsius}, + warning => $warn, + critical => $crit + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/fan.pm b/hardware/server/lenovo/xcc/snmp/mode/components/fan.pm index 87d531b48..eada336c0 100644 --- a/hardware/server/lenovo/xcc/snmp/mode/components/fan.pm +++ b/hardware/server/lenovo/xcc/snmp/mode/components/fan.pm @@ -71,11 +71,14 @@ sub check { $self->{output}->output_add(severity => $exit2, short_msg => sprintf("Fan '%s' is '%s' %%", $result->{fanDescr}, $fan_speed)); } - $self->{output}->perfdata_add(label => 'fan_' . $result->{fanDescr}, unit => '%', - value => $fan_speed, - warning => $warn, - critical => $crit, min => 0, max => 100 - ); + $self->{output}->perfdata_add( + label => 'fan', unit => '%', + nlabel => 'hardware.fan.speed.percentage', + instances => $result->{fanDescr}, + value => $fan_speed, + warning => $warn, + critical => $crit, min => 0, max => 100 + ); } } diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/temperature.pm b/hardware/server/lenovo/xcc/snmp/mode/components/temperature.pm index 57663586f..7fc720773 100644 --- a/hardware/server/lenovo/xcc/snmp/mode/components/temperature.pm +++ b/hardware/server/lenovo/xcc/snmp/mode/components/temperature.pm @@ -85,10 +85,14 @@ sub check { $self->{output}->output_add(severity => $exit2, short_msg => sprintf("Temperature '%s' is %s C", $result->{tempDescr}, $result->{tempReading})); } - $self->{output}->perfdata_add(label => "temp_" . $result->{tempDescr}, unit => 'C', - value => $result->{tempReading}, - warning => $warn, - critical => $crit); + $self->{output}->perfdata_add( + label => 'temp', unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => $result->{tempDescr}, + value => $result->{tempReading}, + warning => $warn, + critical => $crit + ); } } } diff --git a/hardware/server/lenovo/xcc/snmp/mode/components/voltage.pm b/hardware/server/lenovo/xcc/snmp/mode/components/voltage.pm index a7ebcbc32..e74fe9ade 100644 --- a/hardware/server/lenovo/xcc/snmp/mode/components/voltage.pm +++ b/hardware/server/lenovo/xcc/snmp/mode/components/voltage.pm @@ -86,10 +86,14 @@ sub check { $self->{output}->output_add(severity => $exit2, short_msg => sprintf("Voltage '%s' is %s", $result->{voltDescr}, $result->{voltReading})); } - $self->{output}->perfdata_add(label => "volt_" . $result->{voltDescr}, - value => $result->{voltReading}, - warning => $warn, - critical => $crit); + $self->{output}->perfdata_add( + label => 'volt', + nlabel => 'hardware.voltage.volt', + instances => $result->{voltDescr}, + value => $result->{voltReading}, + warning => $warn, + critical => $crit + ); } } diff --git a/hardware/server/sun/mseries/mode/hardware.pm b/hardware/server/sun/mseries/mode/hardware.pm index fdb7b1152..7f2b4de74 100644 --- a/hardware/server/sun/mseries/mode/hardware.pm +++ b/hardware/server/sun/mseries/mode/hardware.pm @@ -128,11 +128,10 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "with-sensors" => { name => 'with_sensors' }, - "exclude:s@" => { name => 'exclude' }, - }); + $options{options}->add_options(arguments => { + "with-sensors" => { name => 'with_sensors' }, + "exclude:s@" => { name => 'exclude' }, + }); return $self; } @@ -196,9 +195,14 @@ sub run { my $oid_end = $2; my $hex_val = md5_hex($board_type . '.' . $oid_end); - $self->{output}->perfdata_add(label => $components_board_types{$board_type} . "_" . $hex_val, - unit => $oids_monitor_units->{$oid_scfMonitorUnits . '.' . $board_type . '.' . $oid_end}, - value => $oids_monitor_values->{$oid}); + # need some snmpwalk to do unit mapping!! experimental + $self->{output}->perfdata_add( + label => $components_board_types{$board_type}, + unit => $oids_monitor_units->{$oid_scfMonitorUnits . '.' . $board_type . '.' . $oid_end}, + nlabel => 'hardware.' . lc($components_board_types{$board_type}) . '.' . $oids_monitor_units->{$oid_scfMonitorUnits . '.' . $board_type . '.' . $oid_end}, + instances => $hex_val, + value => $oids_monitor_values->{$oid} + ); } } @@ -230,4 +234,4 @@ PART = name =back =cut - \ No newline at end of file + diff --git a/hardware/server/supermicro/snmp/mode/hardware.pm b/hardware/server/supermicro/snmp/mode/hardware.pm index 4e19b7ce3..6a6983358 100644 --- a/hardware/server/supermicro/snmp/mode/hardware.pm +++ b/hardware/server/supermicro/snmp/mode/hardware.pm @@ -182,10 +182,16 @@ sub check { short_msg => sprintf("Sensor '%s' is %s %s", $result->{smHealthMonitorName}, $result->{smHealthMonitorReading}, defined($result->{smHealthMonitorReadingUnit}) ? $result->{smHealthMonitorReadingUnit} : '')); } - $self->{output}->perfdata_add(label => $component . '_' . $result->{smHealthMonitorName}, unit => $result->{smHealthMonitorReadingUnit}, - value => $result->{smHealthMonitorReading}, - warning => $warn, - critical => $crit); + + # need some snmpwalk to do unit mapping!! experimental + $self->{output}->perfdata_add( + label => $component, unit => $result->{smHealthMonitorReadingUnit}, + nlabel => 'hardware.sensor.' . $result->{smHealthMonitorType} . '.' . $result->{smHealthMonitorReadingUnit}, + instances => $result->{smHealthMonitorName}, + value => $result->{smHealthMonitorReading}, + warning => $warn, + critical => $crit + ); } } diff --git a/network/a10/ax/snmp/mode/hardware.pm b/network/a10/ax/snmp/mode/hardware.pm index 25a17f847..c90c051e6 100644 --- a/network/a10/ax/snmp/mode/hardware.pm +++ b/network/a10/ax/snmp/mode/hardware.pm @@ -60,9 +60,8 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } @@ -165,11 +164,14 @@ sub check { $self->{output}->output_add(severity => $exit2, short_msg => sprintf("fan '%s' speed is %s rpm", $result->{axFanName}, $result->{axFanSpeed})); } - $self->{output}->perfdata_add(label => $result->{axFanName}, unit => 'rpm', - value => $result->{axFanSpeed}, - warning => $warn, - critical => $crit, min => 0 - ); + $self->{output}->perfdata_add( + label => 'fan', unit => 'rpm', + nlabel => 'hardware.fan.speed.rpm', + instances => $result->{axFanName}, + value => $result->{axFanSpeed}, + warning => $warn, + critical => $crit, min => 0 + ); } } } @@ -250,11 +252,14 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("physical temperature is %s C", $result->{axSysHwPhySystemTemp})); } - $self->{output}->perfdata_add(label => 'temperature_physical', unit => 'C', - value => $result->{axSysHwPhySystemTemp}, - warning => $warn, - critical => $crit - ); + $self->{output}->perfdata_add( + label => 'temperature', unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => 'physical', + value => $result->{axSysHwPhySystemTemp}, + warning => $warn, + critical => $crit + ); } 1; diff --git a/network/brocade/snmp/mode/hardware.pm b/network/brocade/snmp/mode/hardware.pm index e20b7a931..ecebb53f6 100644 --- a/network/brocade/snmp/mode/hardware.pm +++ b/network/brocade/snmp/mode/hardware.pm @@ -61,9 +61,8 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } @@ -131,7 +130,7 @@ use centreon::plugins::misc; my %map_status = (1 => 'unknown', 2 => 'faulty', 3 => 'below-min', 4 => 'nominal', 5 => 'above-max', 6 => 'absent'); my %map_type = (1 => 'temperature', 2 => 'fan', 3 => 'power-supply'); -my %map_unit = (temperature => 'C', fan => 'rpm'); # No voltage value available +my %map_unit = (temperature => 'celsius', fan => 'rpm'); # No voltage value available my $mapping = { swSensorType => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', map => \%map_type }, @@ -180,11 +179,14 @@ sub check { short_msg => sprintf("%s sensor '%s' is %s %s", $result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorValue}, $map_unit{$result->{swSensorType}})); } - $self->{output}->perfdata_add(label => $result->{swSensorInfo}, unit => $map_unit{$result->{swSensorType}}, - value => $result->{swSensorValue}, - warning => $warn, - critical => $crit - ); + $self->{output}->perfdata_add( + label => 'sensor', unit => $map_unit{$result->{swSensorType}}, + nlabel => 'hardware.sensor.' . $result->{swSensorType} . '.' . $map_unit{$result->{swSensorType}}, + instances => $result->{swSensorInfo}, + value => $result->{swSensorValue}, + warning => $warn, + critical => $crit + ); } } } diff --git a/network/nokia/timos/snmp/mode/hardware.pm b/network/nokia/timos/snmp/mode/hardware.pm index 872a7a746..93bf0cb1d 100644 --- a/network/nokia/timos/snmp/mode/hardware.pm +++ b/network/nokia/timos/snmp/mode/hardware.pm @@ -201,11 +201,14 @@ sub check { short_msg => sprintf("%s '%s' temperature is '%s' C", $result->{tmnxHwClass}, $result->{tmnxHwName}, $result->{tmnxHwTemperature})); } - $self->{output}->perfdata_add(label => 'temperature_' . $result->{tmnxHwName}, unit => 'C', - value => $result->{tmnxHwTemperature}, - warning => $warn, - critical => $crit - ); + $self->{output}->perfdata_add( + label => 'temperature' . , unit => 'C', + nlabel => 'hardware.entity.temperature.celsius', + instances => $result->{tmnxHwName}, + value => $result->{tmnxHwTemperature}, + warning => $warn, + critical => $crit + ); } } diff --git a/storage/purestorage/restapi/mode/hardware.pm b/storage/purestorage/restapi/mode/hardware.pm index 85a955d1e..926bfe0f6 100644 --- a/storage/purestorage/restapi/mode/hardware.pm +++ b/storage/purestorage/restapi/mode/hardware.pm @@ -150,11 +150,14 @@ sub check { $self->{output}->output_add(severity => $exit2, short_msg => sprintf("entity '%s' temperature is %s C", $entry->{name}, $entry->{temperature})); } - $self->{output}->perfdata_add(label => 'temperature_' . $entry->{name}, unit => 'C', - value => $entry->{temperature}, - warning => $warn, - critical => $crit, min => 0 - ); + $self->{output}->perfdata_add( + label => 'temperature', unit => 'C', + nlabel => 'hardware.entity.temperature.celsius', + instances => $entry->{name}, + value => $entry->{temperature}, + warning => $warn, + critical => $crit, min => 0 + ); } } }