mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
parent
a71e4e5c63
commit
a38259a52d
@ -277,6 +277,7 @@ sub display {
|
|||||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||||
# Skipping short msg when no components
|
# Skipping short msg when no components
|
||||||
next if (!defined($self->{option_results}->{no_component_count}) && $self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
next if (!defined($self->{option_results}->{no_component_count}) && $self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||||
|
next if (defined($self->{option_results}->{component}) && $comp !~ /$self->{option_results}->{component}/ );
|
||||||
|
|
||||||
if ($self->{count} == 1) {
|
if ($self->{count} == 1) {
|
||||||
($exit, $warn, $crit) = $self->get_severity_count(label => $comp, value => $self->{components}->{$comp}->{total});
|
($exit, $warn, $crit) = $self->get_severity_count(label => $comp, value => $self->{components}->{$comp}->{total});
|
||||||
@ -488,24 +489,24 @@ Default template for hardware. Should be extended.
|
|||||||
|
|
||||||
=item B<--component>
|
=item B<--component>
|
||||||
|
|
||||||
Which component to check (default: '.*').
|
Define which component should be monitored based on their names.
|
||||||
Can be: 'xxx', 'yyy'.
|
This option will be treated as a regular expression.
|
||||||
|
All components are included by default ('.*').
|
||||||
|
|
||||||
=item B<--filter>
|
=item B<--filter>
|
||||||
|
|
||||||
Exclude the items given as a comma-separated list (example: --filter=xxx --filter=yyyy).
|
Exclude some components. This option can be called several times (example: --filter=component1 --filter=component2).
|
||||||
You can also exclude items from specific instances: --filter=xxxxx,instancevalue
|
You can also exclude components from a specific instance (example: --filter=component_name,instance_value).
|
||||||
|
|
||||||
=item B<--absent-problem>
|
=item B<--absent-problem>
|
||||||
|
|
||||||
Return an error if an entity is not 'present' (default is skipping) (comma separated list)
|
Return an error if a component is not 'present' (default is skipping).
|
||||||
Can be specific or global: --absent-problem=xxxx,instancevalue
|
It can be set globally or for a specific instance: --absent-problem='component_name' or --absent-problem='component_name,instance_value'.
|
||||||
|
|
||||||
=item B<--no-component>
|
=item B<--no-component>
|
||||||
|
|
||||||
Define the expected status if no components are found (default: critical).
|
Define the expected status if no components are found (default: critical).
|
||||||
|
|
||||||
|
|
||||||
=item B<--threshold-overload>
|
=item B<--threshold-overload>
|
||||||
|
|
||||||
Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
|
Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
|
||||||
@ -513,21 +514,21 @@ Example: --threshold-overload='xxxxx,CRITICAL,^(?!(normal)$)'
|
|||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning>
|
||||||
|
|
||||||
Set warning threshold for temperatures (syntax: type,instance,threshold)
|
Define the warning threshold for temperatures (syntax: type,instance,threshold)
|
||||||
Example: --warning='xxxxx,.*,30'
|
Example: --warning='temperature,.*,30'
|
||||||
|
|
||||||
=item B<--critical>
|
=item B<--critical>
|
||||||
|
|
||||||
Set critical threshold for temperatures (syntax: type,instance,threshold)
|
Define the critical threshold for temperatures (syntax: type,instance,threshold)
|
||||||
Example: --critical='xxxxx,.*,40'
|
Example: --critical='temperature,.*,40'
|
||||||
|
|
||||||
=item B<--warning-count-xxxx>
|
=item B<--warning-count-*>
|
||||||
|
|
||||||
Set warning threshold for component count.
|
Define the warning threshold for the number of components of one type (replace '*' with the component type).
|
||||||
|
|
||||||
=item B<--critical-count-xxxx>
|
=item B<--critical-count-*>
|
||||||
|
|
||||||
Set critical threshold for component count.
|
Define the critical threshold for the number of components of one type (replace '*' with the component type).
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
53
tests/functional/snmp/hardware-sensors-apc-snmp.robot
Normal file
53
tests/functional/snmp/hardware-sensors-apc-snmp.robot
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
*** Settings ***
|
||||||
|
Documentation Hardware Sensors APC SNMP plugin
|
||||||
|
|
||||||
|
Library OperatingSystem
|
||||||
|
Library String
|
||||||
|
Library Examples
|
||||||
|
|
||||||
|
Test Timeout 120s
|
||||||
|
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl
|
||||||
|
|
||||||
|
${CMD} perl ${CENTREON_PLUGINS} --plugin=hardware::sensors::apc::snmp::plugin --mode=sensors --hostname=127.0.0.1 --snmp-version=2c --snmp-port=2024
|
||||||
|
|
||||||
|
*** Test Cases ***
|
||||||
|
APC Sensors ${tc}/9
|
||||||
|
[Tags] hardware Sensors snmp
|
||||||
|
${command} Catenate
|
||||||
|
... ${CMD}
|
||||||
|
... --snmp-community=hardware/sensors/apc/sensors
|
||||||
|
|
||||||
|
# Append options to command
|
||||||
|
${command} Append Option To Command ${command} --warning ${warning}
|
||||||
|
${command} Append Option To Command ${command} --critical ${critical}
|
||||||
|
${command} Append Option To Command ${command} --component ${component}
|
||||||
|
|
||||||
|
${output} Run ${command}
|
||||||
|
${output} Strip String ${output}
|
||||||
|
Should Be Equal As Strings
|
||||||
|
... ${output}
|
||||||
|
... ${expected_result}
|
||||||
|
... Wrong output result for compliance of ${expected_result}{\n}Command output:{\n}${output}{\n}{\n}{\n}
|
||||||
|
#--component 'temperature' --warning='humidity,.,45:65' --critical='humidity,.,35:70'
|
||||||
|
Examples: tc component warning critical expected_result --
|
||||||
|
... 1 _empty_ _empty_ _empty_ OK: All 2 components are ok [2/2 temperatures]. | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;;;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;;;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
... 2 _empty_ humidity,.,45:65 _empty_ WARNING: Humidity 'Main Module:Sonde de temperature' is 35 % | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;;;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;45:65;;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
... 3 _empty_ humidity,.,45:65 humidity,.,35:70 WARNING: Humidity 'Main Module:Sonde de temperature' is 35 % | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;;;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;45:65;35:70;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
... 4 _empty_ _empty_ _empty_ OK: All 2 components are ok [2/2 temperatures]. | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;;;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;;;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
... 5 _empty_ humidity,.,45:65 _empty_ WARNING: Humidity 'Main Module:Sonde de temperature' is 35 % | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;;;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;45:65;;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
... 6 _empty_ humidity,.,45:65 humidity,.,35:70 WARNING: Humidity 'Main Module:Sonde de temperature' is 35 % | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;;;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;45:65;35:70;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
... 7 .* _empty_ _empty_ OK: All 2 components are ok [2/2 temperatures]. | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;;;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;;;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
... 8 _empty_ temperature,.,22:25 temperature,.,22:25 OK: All 2 components are ok [2/2 temperatures]. | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;22:25;22:25;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;;;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
... 9 _empty_ _empty_ _empty_ OK: All 2 components are ok [2/2 temperatures]. | 'Main Module:Sonde de temperature#hardware.sensor.temperature.celsius'=23C;;;; 'Main Module:Sonde de temperature#hardware.sensor.humidity.percentage'=35%;;;0;100 'hardware.temperature.count'=2;;;;
|
||||||
|
|
||||||
|
*** Keywords ***
|
||||||
|
|
||||||
|
Append Option To Command
|
||||||
|
[Documentation] Concatenates the first argument (option) with the second (value) after having replaced the value with "" if its content is '_empty_'
|
||||||
|
[Arguments] ${cmd} ${option} ${value}
|
||||||
|
${value} Set Variable If '${value}' == '_empty_' '' ${value}
|
||||||
|
[return] ${cmd} ${option}=${value}
|
||||||
|
|
10
tests/resources/snmp/hardware/sensors/apc/sensors.snmpwalk
Normal file
10
tests/resources/snmp/hardware/sensors/apc/sensors.snmpwalk
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.1.3.6.1.4.1.318.1.1.10.3.12.11.0 = INTEGER: 1
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.1.2.1.2.0 = STRING: Main Module
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.2.3.1.1.0.1 = INTEGER: 0
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.2.3.1.2.0.1 = INTEGER: 1
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.2.3.1.3.0.1 = STRING: Sonde de temperature
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.2.3.1.4.0.1 = STRING: salle serveur 1
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.2.3.1.5.0.1 = INTEGER: 23
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.2.3.1.6.0.1 = INTEGER: 35
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.2.3.1.7.0.1 = INTEGER: 2
|
||||||
|
.1.3.6.1.4.1.318.1.1.10.4.2.3.1.8.0.1 = INTEGER: 1
|
Loading…
x
Reference in New Issue
Block a user