Fix power unit and add Voltage metric (#5187)

Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-PORT-A198>
Co-authored-by: sfarouq-ext <116093375+sfarouq-ext@users.noreply.github.com>
Refs : CTOR-887
This commit is contained in:
Lucie Dubrunfaut 2024-09-30 17:03:45 +02:00 committed by GitHub
parent 11482e4d40
commit bc6c0ae9b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 1240 additions and 2 deletions

View File

@ -120,6 +120,14 @@ sub set_counters {
{ template => '%s', unit => 'W', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'phase-voltage', nlabel => 'phase.voltage.volt', set => {
key_values => [ { name => 'voltage' } ],
output_template => 'voltage : %s V',
perfdatas => [
{ template => '%s', unit => 'V', min => 0, label_extra_instance => 1 }
]
}
}
];
}
@ -197,6 +205,7 @@ sub check_pdu2 {
number => { oid => '.1.3.6.1.4.1.3808.1.1.6.4.4.1.3' }, # ePDU2PhaseStatusNumber
state => { oid => '.1.3.6.1.4.1.3808.1.1.6.4.4.1.4', map => $map_pdu_status }, # ePDU2PhaseStatusLoadState
current => { oid => '.1.3.6.1.4.1.3808.1.1.6.4.4.1.5' }, # ePDU2PhaseStatusLoad
voltage => { oid => '.1.3.6.1.4.1.3808.1.1.6.4.4.1.6' }, # ePDU2PhaseStatusVoltage
power => { oid => '.1.3.6.1.4.1.3808.1.1.6.4.4.1.7' } # ePDU2PhaseStatusPower
};
my $mapping_bank = {
@ -230,7 +239,8 @@ sub check_pdu2 {
display => $result->{number},
state => $result->{state},
current => $result->{current} / 10,
power => $result->{power} * 10 # hundreth of kW. So * 10 for watt
voltage => $result->{voltage}/10,
power => $result->{power}
}
}
@ -317,7 +327,7 @@ You can use the following variables: %{state}, %{display}
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'phase-current', 'phase-power', 'bank-current'.
Can be: 'phase-current', 'phase-power', 'phase-voltage', 'bank-current'.
=back

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
***Settings***
Documentation Hardware Camera Avigilon memory
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s
*** Variables ***
${CMD} ${CENTREON_PLUGINS}
... --plugin=hardware::pdu::cyberpower::snmp::plugin
*** Test Cases ***
load ${tc}
[Documentation] Hardware Camera Avigilon Memory
[Tags] hardware cyberpower load
${command} Catenate
... ${CMD}
... --mode=load
... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT}
... --snmp-community=hardware/pdu/cyberpower/snmp/CyberPower
... ${extraoptions}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc extraoptions expected_result --
... 1 --warning-phase-status='\\\%{state} =~ /low|nearOverload/i' OK: Device 'ATS011' bank '1' current : 1 A - phase '1' state: normal, current : 1 A, power : 219 W, voltage : 217.8 V | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;
... 2 --critical-phase-status='\\\%{state} =~ /^overload/i' OK: Device 'ATS011' bank '1' current : 1 A - phase '1' state: normal, current : 1 A, power : 219 W, voltage : 217.8 V | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;
... 4 --warning-phase-power='0' WARNING: Device 'ATS011' phase '1' power : 219 W | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;0:0;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;
... 5 --warning-phase-voltage='0' WARNING: Device 'ATS011' phase '1' voltage : 217.8 V | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;0:0;;0;
... 6 --warning-bank-current='' OK: Device 'ATS011' bank '1' current : 1 A - phase '1' state: normal, current : 1 A, power : 219 W, voltage : 217.8 V | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;
... 7 --critical-phase-current='0' CRITICAL: Device 'ATS011' phase '1' current : 1 A | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;0:0;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;
... 8 --critical-phase-power='0' CRITICAL: Device 'ATS011' phase '1' power : 219 W | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;0:0;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;
... 9 --critical-phase-voltage='300' OK: Device 'ATS011' bank '1' current : 1 A - phase '1' state: normal, current : 1 A, power : 219 W, voltage : 217.8 V | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;0:300;0;
... 10 --critical-bank-current='' OK: Device 'ATS011' bank '1' current : 1 A - phase '1' state: normal, current : 1 A, power : 219 W, voltage : 217.8 V | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;
... 11 --warning-phase-status='\\\%{display} =~ /low|nearOverload/i' OK: Device 'ATS011' bank '1' current : 1 A - phase '1' state: normal, current : 1 A, power : 219 W, voltage : 217.8 V | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;
... 12 --critical-phase-status='\\\%{display} =~ /^overload/i' OK: Device 'ATS011' bank '1' current : 1 A - phase '1' state: normal, current : 1 A, power : 219 W, voltage : 217.8 V | 'ATS011~1#bank.current.ampere'=1A;;;0; 'ATS011~1#phase.current.ampere'=1A;;;0; 'ATS011~1#phase.power.watt'=219W;;;0; 'ATS011~1#phase.voltage.volt'=217.8V;;;0;

View File

@ -0,0 +1,42 @@
***Settings***
Documentation Hardware Camera Avigilon memory
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s
*** Variables ***
${CMD} ${CENTREON_PLUGINS}
... --plugin=hardware::pdu::cyberpower::snmp::plugin
*** Test Cases ***
outlets ${tc}
[Documentation] Hardware Camera Avigilon Memory
[Tags] hardware cyberpower outlets
${command} Catenate
... ${CMD}
... --mode=outlets
... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT}
... --snmp-community=hardware/pdu/cyberpower/snmp/CyberPower
... ${extraoptions}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc extraoptions expected_result --
... 1 --unknown-status='\\\%{state} =~ /on/' UNKNOWN: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]
... 2 --unknown-status OK: Device 'ATS011' outlets are ok
... 3 --warning-status='\\\%{state} =~ /on/' WARNING: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]
... 4 --critical-status='\\\%{state} =~ /on/' CRITICAL: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]
... 5 --warning-current='' OK: Device 'ATS011' outlets are ok
... 6 --critical-current='' OK: Device 'ATS011' outlets are ok
... 7 --unknown-status='\\\%{phase} =~ /-/' UNKNOWN: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]
... 8 --unknown-status='\\\%{bank} =~ /1/' UNKNOWN: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]
... 9 --critical-status='\\\%{phase} =~ /-/' CRITICAL: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]
... 10 --critical-status='\\\%{bank} =~ /1/' CRITICAL: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]
... 11 --critical-status='\\\%{display} =~ /off/' OK: Device 'ATS011' outlets are ok
... 12 --warning-status='\\\%{bank} =~ /1/' WARNING: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]
... 13 --warning-status='\\\%{display} =~ /off/' OK: Device 'ATS011' outlets are ok
... 14 --warning-status='\\\%{phase} =~ /-/' WARNING: Device 'ATS011' outlet 'Outlet1 bank 1' state: 'on' [phase: -] - outlet 'Outlet10 bank 1' state: 'on' [phase: -] - outlet 'Outlet2 bank 1' state: 'on' [phase: -] - outlet 'Outlet3 bank 1' state: 'on' [phase: -] - outlet 'Outlet4 bank 1' state: 'on' [phase: -] - outlet 'Outlet5 bank 1' state: 'on' [phase: -] - outlet 'Outlet6 bank 1' state: 'on' [phase: -] - outlet 'Outlet7 bank 1' state: 'on' [phase: -] - outlet 'Outlet8 bank 1' state: 'on' [phase: -] - outlet 'Outlet9 bank 1' state: 'on' [phase: -]