fix(status): fixing wrong state + attempt to add tests (#4750)

This commit is contained in:
omercier 2023-12-04 15:38:16 +01:00 committed by GitHub
parent 0347bb2cf4
commit f0269d42c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 124 additions and 3 deletions

View File

@ -47,7 +47,7 @@ sub set_system {
['warning', 'WARNING'],
['critical', 'CRITICAL'],
['failing', 'failing']
['failing', 'CRITICAL']
],
raid => [
['Normal', 'OK'],
@ -114,8 +114,8 @@ Check hardware.
=item B<--component>
Which component to check (Default: '.*').
Can be: 'psu', 'fan', 'disk', 'raid', 'system'.
Filter the components to monitor with a regular expression (default: '.*').
Available components: psu, fan, disk, raid, system.
=item B<--filter>

View File

@ -0,0 +1,57 @@
*** Settings ***
Documentation Storage Synology SNMP
Library OperatingSystem
Library XML
Test Timeout 120s
*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl
${CMD} perl ${CENTREON_PLUGINS} --plugin=storage::synology::snmp::plugin
&{check_components_test1}
... description=Checking disk components when all disks are ok
... snmpcommunity=synology_component_disk_ok
... expected_output=OK: All 8 components are ok [2/2 disk, 2/2 fan, 1/1 psu, 2/2 raid, 1/1 system]. | 'Disk 1#hardware.disk.bad_sectors.count'=0;;;0; 'Disk 2#hardware.disk.bad_sectors.count'=0;;;0; 'hardware.disk.count'=2;;;; 'hardware.fan.count'=2;;;; 'hardware.psu.count'=1;;;; 'hardware.raid.count'=2;;;; 'hardware.system.count'=1;;;;
&{check_components_test2}
... description=Checking disk components when one disks is warning
... snmpcommunity=synology_component_disk_warning
... expected_output=WARNING: Disk 'Disk 2' health is warning | 'Disk 1#hardware.disk.bad_sectors.count'=0;;;0; 'Disk 2#hardware.disk.bad_sectors.count'=0;;;0; 'hardware.disk.count'=2;;;; 'hardware.fan.count'=2;;;; 'hardware.psu.count'=1;;;; 'hardware.raid.count'=2;;;; 'hardware.system.count'=1;;;;
&{check_components_test3}
... description=Checking disk components when one disks is critical
... snmpcommunity=synology_component_disk_critical
... expected_output=CRITICAL: Disk 'Disk 2' health is critical | 'Disk 1#hardware.disk.bad_sectors.count'=0;;;0; 'Disk 2#hardware.disk.bad_sectors.count'=0;;;0; 'hardware.disk.count'=2;;;; 'hardware.fan.count'=2;;;; 'hardware.psu.count'=1;;;; 'hardware.raid.count'=2;;;; 'hardware.system.count'=1;;;;
&{check_components_test4}
... description=Checking disk components when one disks is failing
... snmpcommunity=synology_component_disk_failing
... expected_output=CRITICAL: Disk 'Disk 2' health is failing | 'Disk 1#hardware.disk.bad_sectors.count'=0;;;0; 'Disk 2#hardware.disk.bad_sectors.count'=0;;;0; 'hardware.disk.count'=2;;;; 'hardware.fan.count'=2;;;; 'hardware.psu.count'=1;;;; 'hardware.raid.count'=2;;;; 'hardware.system.count'=1;;;;
@{check_components_tests}
... &{check_components_test1}
... &{check_components_test2}
... &{check_components_test3}
... &{check_components_test4}
*** Test Cases ***
Synology SNMP: Checking disk components
[Documentation] Monitor the different states of disk health
[Tags] storage synology snmp
Log To Console Synology SNMP: Checking disk components
FOR ${check_components_test} IN @{check_components_tests}
${command} Catenate
... ${CMD}
... --mode=components
... --hostname=127.0.0.1
... --snmp-version=2
... --snmp-port=2024
... --snmp-community=${check_components_test.snmpcommunity}
${output} Run ${command}
Log To Console ${check_components_test.description}
Should Be Equal As Strings
... ${check_components_test.expected_output}
... ${output}
... Wrong output for components mode: ${check_components_test}.{\n}Command output:{\n}${output}
END

View File

@ -0,0 +1,16 @@
.1.3.6.1.4.1.6574.1.1.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.3.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.4.1.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.4.2.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.2.0 = STRING: Disk 1
.1.3.6.1.4.1.6574.2.1.1.2.1 = STRING: Disk 2
.1.3.6.1.4.1.6574.2.1.1.5.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.5.1 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.9.0 = INTEGER: 0
.1.3.6.1.4.1.6574.2.1.1.9.1 = INTEGER: 0
.1.3.6.1.4.1.6574.2.1.1.13.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.13.1 = INTEGER: 3
.1.3.6.1.4.1.6574.3.1.1.2.0 = STRING: Volume 1
.1.3.6.1.4.1.6574.3.1.1.2.1 = STRING: Storage Pool 1
.1.3.6.1.4.1.6574.3.1.1.3.0 = INTEGER: 1
.1.3.6.1.4.1.6574.3.1.1.3.1 = INTEGER: 1

View File

@ -0,0 +1,16 @@
.1.3.6.1.4.1.6574.1.1.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.3.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.4.1.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.4.2.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.2.0 = STRING: Disk 1
.1.3.6.1.4.1.6574.2.1.1.2.1 = STRING: Disk 2
.1.3.6.1.4.1.6574.2.1.1.5.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.5.1 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.9.0 = INTEGER: 0
.1.3.6.1.4.1.6574.2.1.1.9.1 = INTEGER: 0
.1.3.6.1.4.1.6574.2.1.1.13.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.13.1 = INTEGER: 4
.1.3.6.1.4.1.6574.3.1.1.2.0 = STRING: Volume 1
.1.3.6.1.4.1.6574.3.1.1.2.1 = STRING: Storage Pool 1
.1.3.6.1.4.1.6574.3.1.1.3.0 = INTEGER: 1
.1.3.6.1.4.1.6574.3.1.1.3.1 = INTEGER: 1

View File

@ -0,0 +1,16 @@
.1.3.6.1.4.1.6574.1.1.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.3.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.4.1.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.4.2.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.2.0 = STRING: Disk 1
.1.3.6.1.4.1.6574.2.1.1.2.1 = STRING: Disk 2
.1.3.6.1.4.1.6574.2.1.1.5.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.5.1 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.9.0 = INTEGER: 0
.1.3.6.1.4.1.6574.2.1.1.9.1 = INTEGER: 0
.1.3.6.1.4.1.6574.2.1.1.13.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.13.1 = INTEGER: 1
.1.3.6.1.4.1.6574.3.1.1.2.0 = STRING: Volume 1
.1.3.6.1.4.1.6574.3.1.1.2.1 = STRING: Storage Pool 1
.1.3.6.1.4.1.6574.3.1.1.3.0 = INTEGER: 1
.1.3.6.1.4.1.6574.3.1.1.3.1 = INTEGER: 1

View File

@ -0,0 +1,16 @@
.1.3.6.1.4.1.6574.1.1.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.3.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.4.1.0 = INTEGER: 1
.1.3.6.1.4.1.6574.1.4.2.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.2.0 = STRING: Disk 1
.1.3.6.1.4.1.6574.2.1.1.2.1 = STRING: Disk 2
.1.3.6.1.4.1.6574.2.1.1.5.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.5.1 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.9.0 = INTEGER: 0
.1.3.6.1.4.1.6574.2.1.1.9.1 = INTEGER: 0
.1.3.6.1.4.1.6574.2.1.1.13.0 = INTEGER: 1
.1.3.6.1.4.1.6574.2.1.1.13.1 = INTEGER: 2
.1.3.6.1.4.1.6574.3.1.1.2.0 = STRING: Volume 1
.1.3.6.1.4.1.6574.3.1.1.2.1 = STRING: Storage Pool 1
.1.3.6.1.4.1.6574.3.1.1.3.0 = INTEGER: 1
.1.3.6.1.4.1.6574.3.1.1.3.1 = INTEGER: 1