Skip to content

Commit

Permalink
Fix uninitialized value (#4811)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-P-PF3DNAR1>
  • Loading branch information
omercier and Lucie Dubrunfaut committed Jan 16, 2024
1 parent 6a5fb84 commit 95c6bc2
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/network/aruba/instant/snmp/mode/apusage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ sub manage_selection {
my $ap_ipaddress = $snmp_result->{$oid_aiClientAPIPAddress}->{$oid};
if (defined($link_ap->{$ap_ipaddress})) {
$link_ap->{$ap_ipaddress}->{clients}++;
} else {
} elsif (defined($self->{ap}->{default})) { # default "AP" is only handled when no AP is identified (see above)
$self->{ap}->{default}->{clients}++;
}
}
Expand Down
79 changes: 79 additions & 0 deletions tests/functional/snmp/network-aruba-instant-ap-usage.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
*** Settings ***
Documentation Network Aruba Instant SNMP plugin - AP Usage
Library OperatingSystem
Library String

Test Timeout 120s


*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl

${CMD} perl ${CENTREON_PLUGINS} --plugin=network::aruba::instant::snmp::plugin --mode=ap-usage --hostname=127.0.0.1 --snmp-version=2c --snmp-port=2024

&{ap_usage_test_1}
... documentation=Test AP usage without filters
... snmpcommunity=network-aruba-instant/ap-usage
... filtercounters=
... filtername=
... warningclients=
... criticalclients=
... result=OK: total access points: 5 - All access points are ok | 'accesspoints.total.count'=5;;;0; 'AP Piso 1#clients.current.count'=4;;;0; 'AP Piso 1#cpu.utilization.percentage'=3.00%;;;0;100 'AP Piso 1#memory.usage.bytes'=215711744B;;;0;527028224 'AP Piso 1#memory.free.bytes'=311316480B;;;0;527028224 'AP Piso 1#memory.usage.percentage'=40.93%;;;0;100 'AP Piso 2#clients.current.count'=17;;;0; 'AP Piso 2#cpu.utilization.percentage'=18.00%;;;0;100 'AP Piso 2#memory.usage.bytes'=219455488B;;;0;527028224 'AP Piso 2#memory.free.bytes'=307572736B;;;0;527028224 'AP Piso 2#memory.usage.percentage'=41.64%;;;0;100 'AP Piso 3#clients.current.count'=14;;;0; 'AP Piso 3#cpu.utilization.percentage'=18.00%;;;0;100 'AP Piso 3#memory.usage.bytes'=219185152B;;;0;527028224 'AP Piso 3#memory.free.bytes'=307843072B;;;0;527028224 'AP Piso 3#memory.usage.percentage'=41.59%;;;0;100 'AP Piso 4#clients.current.count'=11;;;0; 'AP Piso 4#cpu.utilization.percentage'=11.00%;;;0;100 'AP Piso 4#memory.usage.bytes'=221700096B;;;0;527028224 'AP Piso 4#memory.free.bytes'=305328128B;;;0;527028224 'AP Piso 4#memory.usage.percentage'=42.07%;;;0;100 'AP Sotano#clients.current.count'=4;;;0; 'AP Sotano#cpu.utilization.percentage'=4.00%;;;0;100 'AP Sotano#memory.usage.bytes'=217473024B;;;0;527028224 'AP Sotano#memory.free.bytes'=309555200B;;;0;527028224 'AP Sotano#memory.usage.percentage'=41.26%;;;0;100

&{ap_usage_test_2}
... documentation=Test AP usage with filter on clients
... snmpcommunity=network-aruba-instant/ap-usage
... filtercounters=clients
... filtername=
... warningclients=
... criticalclients=
... result=OK: All access points are ok | 'AP Piso 1#clients.current.count'=4;;;0; 'AP Piso 2#clients.current.count'=17;;;0; 'AP Piso 3#clients.current.count'=14;;;0; 'AP Piso 4#clients.current.count'=11;;;0; 'AP Sotano#clients.current.count'=4;;;0;

&{ap_usage_test_3}
... documentation=Test AP usage with filter on clients and filter on name
... snmpcommunity=network-aruba-instant/ap-usage
... filtercounters=clients
... filtername=Piso 4
... warningclients=
... criticalclients=
... result=OK: Access Point 'AP Piso 4' Current Clients: 11 | 'AP Piso 4#clients.current.count'=11;;;0;

&{ap_usage_test_4}
... documentation=Test AP usage without filters with warning when less than 20 clients
... snmpcommunity=network-aruba-instant/ap-usage
... filtercounters=
... filtername=
... warningclients=20:
... criticalclients=
... result=WARNING: Access Point 'AP Piso 1' Current Clients: 4 - Access Point 'AP Piso 2' Current Clients: 17 - Access Point 'AP Piso 3' Current Clients: 14 - Access Point 'AP Piso 4' Current Clients: 11 - Access Point 'AP Sotano' Current Clients: 4 | 'accesspoints.total.count'=5;;;0; 'AP Piso 1#clients.current.count'=4;20:;;0; 'AP Piso 1#cpu.utilization.percentage'=3.00%;;;0;100 'AP Piso 1#memory.usage.bytes'=215711744B;;;0;527028224 'AP Piso 1#memory.free.bytes'=311316480B;;;0;527028224 'AP Piso 1#memory.usage.percentage'=40.93%;;;0;100 'AP Piso 2#clients.current.count'=17;20:;;0; 'AP Piso 2#cpu.utilization.percentage'=18.00%;;;0;100 'AP Piso 2#memory.usage.bytes'=219455488B;;;0;527028224 'AP Piso 2#memory.free.bytes'=307572736B;;;0;527028224 'AP Piso 2#memory.usage.percentage'=41.64%;;;0;100 'AP Piso 3#clients.current.count'=14;20:;;0; 'AP Piso 3#cpu.utilization.percentage'=18.00%;;;0;100 'AP Piso 3#memory.usage.bytes'=219185152B;;;0;527028224 'AP Piso 3#memory.free.bytes'=307843072B;;;0;527028224 'AP Piso 3#memory.usage.percentage'=41.59%;;;0;100 'AP Piso 4#clients.current.count'=11;20:;;0; 'AP Piso 4#cpu.utilization.percentage'=11.00%;;;0;100 'AP Piso 4#memory.usage.bytes'=221700096B;;;0;527028224 'AP Piso 4#memory.free.bytes'=305328128B;;;0;527028224 'AP Piso 4#memory.usage.percentage'=42.07%;;;0;100 'AP Sotano#clients.current.count'=4;20:;;0; 'AP Sotano#cpu.utilization.percentage'=4.00%;;;0;100 'AP Sotano#memory.usage.bytes'=217473024B;;;0;527028224 'AP Sotano#memory.free.bytes'=309555200B;;;0;527028224 'AP Sotano#memory.usage.percentage'=41.26%;;;0;100

@{ap_usage_tests}
... &{ap_usage_test_1}
... &{ap_usage_test_2}
... &{ap_usage_test_3}
... &{ap_usage_test_4}


*** Test Cases ***
Network Aruba Instant SNMP plugin
[Documentation] AP Usage
[Tags] network aruba snmp
FOR ${ap_usage_tc} IN @{ap_usage_tests}
${command} Catenate
... ${CMD}
... --filter-counters='${ap_usage_tc.filtercounters}'
... --filter-name='${ap_usage_tc.filtername}'
... --warning-clients='${ap_usage_tc.warningclients}'
... --critical-clients='${ap_usage_tc.criticalclients}'
... --snmp-community=${ap_usage_tc.snmpcommunity}

Log To Console ${ap_usage_tc.documentation}
${output} Run ${command}
${output} Strip String ${output}
Should Be Equal As Strings
... ${output}
... ${ap_usage_tc.result}
... Wrong output result for compliance of ${ap_usage_tc.result}{\n}Command output:{\n}${output}{\n}{\n}{\n}
END

100 changes: 100 additions & 0 deletions tests/resources/snmp/network-aruba-instant/ap-usage.snmpwalk
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.2.112.58.14.202.173.210 = STRING: AP Piso 1
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.2.112.58.14.202.175.120 = STRING: AP Piso 2
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.2.112.58.14.203.129.170 = STRING: AP Sotano
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.2.112.58.14.203.129.172 = STRING: AP Piso 4
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.2.112.58.14.203.130.124 = STRING: AP Piso 3
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.3.112.58.14.202.173.210 = STRING: 192.168.0.242
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.3.112.58.14.202.175.120 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.3.112.58.14.203.129.170 = STRING: 192.168.0.237
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.3.112.58.14.203.129.172 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.3.112.58.14.203.130.124 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.4.112.58.14.202.173.210 = STRING: CXXXXXV51G
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.4.112.58.14.202.175.120 = STRING: CXXXXXV588
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.4.112.58.14.203.129.170 = STRING: CXXXXXV1Y6
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.4.112.58.14.203.129.172 = STRING: CXXXXXV1Y7
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.4.112.58.14.203.130.124 = STRING: CXXXXXV21L
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.5.112.58.14.202.173.210 = STRING: .1.3.6.1.4.1.14823.1.2.59
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.5.112.58.14.202.175.120 = STRING: .1.3.6.1.4.1.14823.1.2.59
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.5.112.58.14.203.129.170 = STRING: .1.3.6.1.4.1.14823.1.2.59
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.5.112.58.14.203.129.172 = STRING: .1.3.6.1.4.1.14823.1.2.59
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.5.112.58.14.203.130.124 = STRING: .1.3.6.1.4.1.14823.1.2.59
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.6.112.58.14.202.173.210 = 225
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.6.112.58.14.202.175.120 = 225
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.6.112.58.14.203.129.170 = 225
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.6.112.58.14.203.129.172 = 225
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.6.112.58.14.203.130.124 = 225
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.7.112.58.14.202.173.210 = 3
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.7.112.58.14.202.175.120 = 18
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.7.112.58.14.203.129.170 = 4
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.7.112.58.14.203.129.172 = 11
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.7.112.58.14.203.130.124 = 18
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.8.112.58.14.202.173.210 = 311316480
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.8.112.58.14.202.175.120 = 307572736
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.8.112.58.14.203.129.170 = 309555200
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.8.112.58.14.203.129.172 = 305328128
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.8.112.58.14.203.130.124 = 307843072
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.9.112.58.14.202.173.210 = 1570716300
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.9.112.58.14.202.175.120 = 1595908000
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.9.112.58.14.203.129.170 = 1597074100
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.9.112.58.14.203.129.172 = 1596571900
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.9.112.58.14.203.130.124 = 1596534300
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.10.112.58.14.202.173.210 = 527028224
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.10.112.58.14.202.175.120 = 527028224
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.10.112.58.14.203.129.170 = 527028224
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.10.112.58.14.203.129.172 = 527028224
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.10.112.58.14.203.130.124 = 527028224
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.11.112.58.14.202.173.210 = 1
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.11.112.58.14.202.175.120 = 1
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.11.112.58.14.203.129.170 = 1
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.11.112.58.14.203.129.172 = 1
.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.11.112.58.14.203.130.124 = 1
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.0.145.158.234.114.37 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.4.229.152.224.53.169 = STRING: 192.168.0.242
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.16.81.7.176.5.174 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.30.63.236.117.207.223 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.40.36.255.214.15.147 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.46.15.242.8.164.80 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.50.22.145.81.97.83 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.52.46.183.70.11.124 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.52.46.183.221.30.84 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.60.33.156.223.106.221 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.70.155.69.122.199.46 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.78.8.226.31.141.40 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.78.143.165.222.161.99 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.82.172.165.68.121.186 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.84.141.90.181.16.123 = STRING: 192.168.0.242
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.86.66.20.39.209.29 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.96.165.226.9.33.133 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.96.227.43.121.175.174 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.96.227.43.124.21.200 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.102.89.253.243.33.77 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.116.151.121.3.223.205 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.128.56.251.132.10.48 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.130.90.58.66.254.161 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.130.149.171.102.123.164 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.134.68.105.106.252.193 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.140.122.61.222.227.173 = STRING: 192.168.0.237
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.140.141.40.46.226.198 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.140.141.40.67.165.48 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.140.200.75.74.178.97 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.146.41.79.160.128.182 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.152.141.70.158.56.11 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.152.141.70.158.58.249 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.164.48.122.232.152.104 = STRING: 192.168.0.242
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.164.52.217.15.238.32 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.166.202.58.48.78.95 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.168.100.241.110.171.34 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.202.181.74.221.105.239 = STRING: 192.168.0.242
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.204.217.172.175.157.118 = STRING: 192.168.0.237
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.210.110.215.242.4.25 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.214.9.12.120.46.26 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.218.135.18.246.213.114 = STRING: 192.168.0.237
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.218.152.170.55.73.204 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.220.169.4.146.112.229 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.224.204.248.59.20.91 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.228.179.24.50.2.98 = STRING: 192.168.0.245
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.236.240.14.86.117.226 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.242.143.242.6.82.50 = STRING: 192.168.0.239
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.242.215.0.49.149.20 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.244.179.1.147.100.228 = STRING: 192.168.0.238
.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4.248.89.113.128.32.190 = STRING: 192.168.0.237

0 comments on commit 95c6bc2

Please sign in to comment.