Add APC battery operation time polling, including display in WebUI (#14058)

* Fetch and store upsBasicBatteryLastReplaceDate

For APC USV, sensor class is 'runtime'

* Change type string for battery's life time

* Change limits to meaningful values, remove debug output

Limits are 4 (warn) and 5 (critical) years, using our own experience.

* Add time calculation for battery life time during polling

This means that the received date is subtracted from current
time, the difference is stored as minutes, just like with discovery.

* Improve sensor description/label (again)

* Correct label for battery's life time to “operating time”

* Add test data for APC UPS to test new used OID

OID for the last battery exchange date, which is used
for calculation the operation time.

* Changes for styleCI

* Fix more files for styleCI

* Remove a duplicated empty line (styleCI)

* Update test data
This commit is contained in:
Marek Wobst
2022-06-24 01:43:46 +02:00
committed by GitHub
parent 3b12f35b31
commit 654f97c302
4 changed files with 1805 additions and 0 deletions

View File

@@ -16,6 +16,23 @@ if ($oids) {
discover_sensor($valid['sensor'], 'runtime', $device, $oid, $index, $type, $descr, $divisor, '1', $low_limit, $low_limit_warn, $warn_limit, $high_limit, $current);
}
$oids = snmp_get($device, '.1.3.6.1.4.1.318.1.1.1.2.1.3.0', '-OsqnUt', '');
d_echo($oids . "\n");
if ($oids) {
echo ' APC Battery Usage Time ';
[$oid,$currentRAW] = explode(' "', $oids);
$current = (strtotime(date('Y-m-d')) - strtotime($currentRAW)) / 60;
$divisor = 1;
$type = 'apc';
$index = 'upsBasicBatteryLastReplaceDate.0';
$descr = 'Battery Operating Time';
$low_limit = 0;
$low_limit_warn = 0;
$warn_limit = 4 * 365 * 24 * 60; // 4 years
$high_limit = 5 * 365 * 24 * 60; // 5 years
discover_sensor($valid['sensor'], 'runtime', $device, $oid, $index, $type, $descr, $divisor, '1', $low_limit, $low_limit_warn, $warn_limit, $high_limit, $current);
}
// InRow IRRP100
$oids = snmp_get($device, 'airIRRP100GroupSetpointsCoolMetric.0', '-OsqnU', 'PowerNet-MIB');
if ($oids) {

View File

@@ -0,0 +1,5 @@
<?php
if ($sensor['sensor_oid'] === '.1.3.6.1.4.1.318.1.1.1.2.1.3.0') {
$sensor_value = (strtotime(date('Y-m-d')) - strtotime($sensor_value)) / 60;
}

View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,308 @@
1.3.6.1.2.1.1.1.0|4|APC Web/SNMP Management Card (MB:v4.1.0 PF:v6.8.8 PN:apc_hw05_aos_688.bin AF1:v6.8.8 AN1:apc_hw05_sumx_688.bin MN:AP9631 HR:08 SN: ZA1615015104 MD:04/16/2016) (Embedded PowerNet SNMP Agent SW v2.2 compatible)
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.318.1.3.27
1.3.6.1.2.1.1.3.0|67|2738866020
1.3.6.1.2.1.1.4.0|4|<private>
1.3.6.1.2.1.1.5.0|4|<private>
1.3.6.1.2.1.1.6.0|4|<private>
1.3.6.1.2.1.2.2.1.1.1|2|1
1.3.6.1.2.1.2.2.1.1.2|2|2
1.3.6.1.2.1.2.2.1.2.1|4|LOOPBACK
1.3.6.1.2.1.2.2.1.2.2|4|vmac0
1.3.6.1.2.1.2.2.1.3.1|2|24
1.3.6.1.2.1.2.2.1.3.2|2|6
1.3.6.1.2.1.2.2.1.4.1|2|1500
1.3.6.1.2.1.2.2.1.4.2|2|1500
1.3.6.1.2.1.2.2.1.5.1|66|0
1.3.6.1.2.1.2.2.1.5.2|66|100000000
1.3.6.1.2.1.2.2.1.6.1|4|
1.3.6.1.2.1.2.2.1.6.2|4x|00C0B7F31EE1
1.3.6.1.2.1.2.2.1.7.1|2|1
1.3.6.1.2.1.2.2.1.7.2|2|1
1.3.6.1.2.1.2.2.1.8.1|2|1
1.3.6.1.2.1.2.2.1.8.2|2|1
1.3.6.1.2.1.2.2.1.9.1|67|0
1.3.6.1.2.1.2.2.1.9.2|67|25
1.3.6.1.2.1.2.2.1.10.1|65|0
1.3.6.1.2.1.2.2.1.10.2|65|1767410291
1.3.6.1.2.1.2.2.1.11.1|65|0
1.3.6.1.2.1.2.2.1.11.2|65|12596955
1.3.6.1.2.1.2.2.1.12.1|65|0
1.3.6.1.2.1.2.2.1.12.2|65|0
1.3.6.1.2.1.2.2.1.13.1|65|0
1.3.6.1.2.1.2.2.1.13.2|65|0
1.3.6.1.2.1.2.2.1.14.1|65|0
1.3.6.1.2.1.2.2.1.14.2|65|0
1.3.6.1.2.1.2.2.1.15.1|65|0
1.3.6.1.2.1.2.2.1.15.2|65|0
1.3.6.1.2.1.2.2.1.16.1|65|0
1.3.6.1.2.1.2.2.1.16.2|65|2481254299
1.3.6.1.2.1.2.2.1.17.1|65|0
1.3.6.1.2.1.2.2.1.17.2|65|12610565
1.3.6.1.2.1.2.2.1.18.1|65|0
1.3.6.1.2.1.2.2.1.18.2|65|44377
1.3.6.1.2.1.2.2.1.19.1|65|0
1.3.6.1.2.1.2.2.1.19.2|65|0
1.3.6.1.2.1.2.2.1.20.1|65|0
1.3.6.1.2.1.2.2.1.20.2|65|0
1.3.6.1.2.1.2.2.1.21.1|66|0
1.3.6.1.2.1.2.2.1.21.2|66|0
1.3.6.1.2.1.2.2.1.22.1|6|0.0
1.3.6.1.2.1.2.2.1.22.2|6|0.0
1.3.6.1.2.1.4.3.0|65|12497043
1.3.6.1.2.1.4.4.0|65|0
1.3.6.1.2.1.4.5.0|65|0
1.3.6.1.2.1.4.6.0|65|0
1.3.6.1.2.1.4.7.0|65|0
1.3.6.1.2.1.4.8.0|65|0
1.3.6.1.2.1.4.9.0|65|12497041
1.3.6.1.2.1.4.10.0|65|12555010
1.3.6.1.2.1.4.11.0|65|0
1.3.6.1.2.1.4.12.0|65|0
1.3.6.1.2.1.4.14.0|65|0
1.3.6.1.2.1.4.15.0|65|0
1.3.6.1.2.1.4.16.0|65|0
1.3.6.1.2.1.4.17.0|65|0
1.3.6.1.2.1.4.18.0|65|0
1.3.6.1.2.1.4.19.0|65|0
1.3.6.1.2.1.4.20.1.2.127.0.0.1|2|1
1.3.6.1.2.1.4.20.1.2.172.30.122.90|2|2
1.3.6.1.2.1.4.20.1.3.127.0.0.1|64|255.255.255.255
1.3.6.1.2.1.4.20.1.3.172.30.122.90|64|255.255.255.0
1.3.6.1.2.1.4.22.1.2.2.172.30.122.1|4x|00000C9FF3C2
1.3.6.1.2.1.4.22.1.2.2.172.30.122.91|4x|00B8B3BA897A
1.3.6.1.2.1.4.31.1.1.3.1|65|0
1.3.6.1.2.1.4.31.1.1.3.2|65|0
1.3.6.1.2.1.4.31.1.1.4.1|70|0
1.3.6.1.2.1.4.31.1.1.4.2|70|0
1.3.6.1.2.1.4.31.1.1.5.1|65|1767407656
1.3.6.1.2.1.4.31.1.1.5.2|65|0
1.3.6.1.2.1.4.31.1.1.6.1|70|1767407656
1.3.6.1.2.1.4.31.1.1.6.2|70|0
1.3.6.1.2.1.4.31.1.1.7.1|65|0
1.3.6.1.2.1.4.31.1.1.7.2|65|0
1.3.6.1.2.1.4.31.1.1.8.1|65|0
1.3.6.1.2.1.4.31.1.1.8.2|65|0
1.3.6.1.2.1.4.31.1.1.9.1|65|0
1.3.6.1.2.1.4.31.1.1.9.2|65|0
1.3.6.1.2.1.4.31.1.1.10.1|65|0
1.3.6.1.2.1.4.31.1.1.10.2|65|0
1.3.6.1.2.1.4.31.1.1.11.1|65|0
1.3.6.1.2.1.4.31.1.1.11.2|65|0
1.3.6.1.2.1.4.31.1.1.12.1|65|0
1.3.6.1.2.1.4.31.1.1.12.2|65|0
1.3.6.1.2.1.4.31.1.1.13.1|70|0
1.3.6.1.2.1.4.31.1.1.13.2|70|0
1.3.6.1.2.1.4.31.1.1.14.1|65|0
1.3.6.1.2.1.4.31.1.1.14.2|65|0
1.3.6.1.2.1.4.31.1.1.15.1|65|0
1.3.6.1.2.1.4.31.1.1.15.2|65|0
1.3.6.1.2.1.4.31.1.1.16.1|65|0
1.3.6.1.2.1.4.31.1.1.16.2|65|0
1.3.6.1.2.1.4.31.1.1.17.1|65|0
1.3.6.1.2.1.4.31.1.1.17.2|65|0
1.3.6.1.2.1.4.31.1.1.18.1|65|12497177
1.3.6.1.2.1.4.31.1.1.18.2|65|0
1.3.6.1.2.1.4.31.1.1.19.1|70|0
1.3.6.1.2.1.4.31.1.1.19.2|70|0
1.3.6.1.2.1.4.31.1.1.20.1|65|12555142
1.3.6.1.2.1.4.31.1.1.20.2|65|0
1.3.6.1.2.1.4.31.1.1.21.1|70|12555142
1.3.6.1.2.1.4.31.1.1.21.2|70|0
1.3.6.1.2.1.4.31.1.1.22.1|65|0
1.3.6.1.2.1.4.31.1.1.22.2|65|0
1.3.6.1.2.1.4.31.1.1.23.1|65|0
1.3.6.1.2.1.4.31.1.1.23.2|65|0
1.3.6.1.2.1.4.31.1.1.24.1|70|0
1.3.6.1.2.1.4.31.1.1.24.2|70|0
1.3.6.1.2.1.4.31.1.1.25.1|65|0
1.3.6.1.2.1.4.31.1.1.25.2|65|0
1.3.6.1.2.1.4.31.1.1.26.1|65|0
1.3.6.1.2.1.4.31.1.1.26.2|65|0
1.3.6.1.2.1.4.31.1.1.27.1|65|0
1.3.6.1.2.1.4.31.1.1.27.2|65|0
1.3.6.1.2.1.4.31.1.1.28.1|65|0
1.3.6.1.2.1.4.31.1.1.28.2|65|0
1.3.6.1.2.1.4.31.1.1.29.1|65|0
1.3.6.1.2.1.4.31.1.1.29.2|65|0
1.3.6.1.2.1.4.31.1.1.30.1|65|0
1.3.6.1.2.1.4.31.1.1.30.2|65|0
1.3.6.1.2.1.4.31.1.1.31.1|70|0
1.3.6.1.2.1.4.31.1.1.31.2|70|0
1.3.6.1.2.1.4.31.1.1.32.1|65|2481250567
1.3.6.1.2.1.4.31.1.1.32.2|65|0
1.3.6.1.2.1.4.31.1.1.33.1|70|2481250926
1.3.6.1.2.1.4.31.1.1.33.2|70|0
1.3.6.1.2.1.4.31.1.1.34.1|65|0
1.3.6.1.2.1.4.31.1.1.34.2|65|0
1.3.6.1.2.1.4.31.1.1.35.1|70|0
1.3.6.1.2.1.4.31.1.1.35.2|70|0
1.3.6.1.2.1.4.31.1.1.36.1|65|0
1.3.6.1.2.1.4.31.1.1.36.2|65|0
1.3.6.1.2.1.4.31.1.1.37.1|70|0
1.3.6.1.2.1.4.31.1.1.37.2|70|0
1.3.6.1.2.1.4.31.1.1.38.1|65|0
1.3.6.1.2.1.4.31.1.1.38.2|65|0
1.3.6.1.2.1.4.31.1.1.39.1|70|0
1.3.6.1.2.1.4.31.1.1.39.2|70|0
1.3.6.1.2.1.4.31.1.1.40.1|65|0
1.3.6.1.2.1.4.31.1.1.40.2|65|0
1.3.6.1.2.1.4.31.1.1.41.1|70|0
1.3.6.1.2.1.4.31.1.1.41.2|70|0
1.3.6.1.2.1.4.31.1.1.42.1|65|0
1.3.6.1.2.1.4.31.1.1.42.2|65|0
1.3.6.1.2.1.4.31.1.1.43.1|70|0
1.3.6.1.2.1.4.31.1.1.43.2|70|0
1.3.6.1.2.1.4.31.1.1.44.1|65|44377
1.3.6.1.2.1.4.31.1.1.44.2|65|0
1.3.6.1.2.1.4.31.1.1.45.1|70|44377
1.3.6.1.2.1.4.31.1.1.45.2|70|0
1.3.6.1.2.1.4.31.1.1.46.1|67|0
1.3.6.1.2.1.4.31.1.1.46.2|67|0
1.3.6.1.2.1.4.31.1.1.47.1|66|0
1.3.6.1.2.1.4.31.1.1.47.2|66|0
1.3.6.1.2.1.4.35.1.4.2.1.4.172.30.122.1|4x|00000C9FF3C2
1.3.6.1.2.1.4.35.1.4.2.1.4.172.30.122.91|4x|00B8B3BA897A
1.3.6.1.2.1.5.1.0|65|386365
1.3.6.1.2.1.5.2.0|65|0
1.3.6.1.2.1.5.3.0|65|12
1.3.6.1.2.1.5.4.0|65|0
1.3.6.1.2.1.5.5.0|65|0
1.3.6.1.2.1.5.6.0|65|0
1.3.6.1.2.1.5.7.0|65|0
1.3.6.1.2.1.5.8.0|65|345697
1.3.6.1.2.1.5.9.0|65|40656
1.3.6.1.2.1.5.10.0|65|0
1.3.6.1.2.1.5.11.0|65|0
1.3.6.1.2.1.5.12.0|65|0
1.3.6.1.2.1.5.13.0|65|0
1.3.6.1.2.1.5.14.0|65|446135
1.3.6.1.2.1.5.15.0|65|0
1.3.6.1.2.1.5.16.0|65|0
1.3.6.1.2.1.5.17.0|65|0
1.3.6.1.2.1.5.18.0|65|0
1.3.6.1.2.1.5.19.0|65|0
1.3.6.1.2.1.5.20.0|65|0
1.3.6.1.2.1.5.21.0|65|100438
1.3.6.1.2.1.5.22.0|65|345697
1.3.6.1.2.1.5.23.0|65|0
1.3.6.1.2.1.5.24.0|65|0
1.3.6.1.2.1.5.25.0|65|0
1.3.6.1.2.1.5.26.0|65|0
1.3.6.1.2.1.6.5.0|65|0
1.3.6.1.2.1.6.6.0|65|101
1.3.6.1.2.1.6.7.0|65|0
1.3.6.1.2.1.6.8.0|65|89
1.3.6.1.2.1.6.9.0|66|0
1.3.6.1.2.1.6.10.0|65|5551
1.3.6.1.2.1.6.11.0|65|3200
1.3.6.1.2.1.6.12.0|65|0
1.3.6.1.2.1.6.14.0|65|0
1.3.6.1.2.1.6.15.0|65|1
1.3.6.1.2.1.7.1.0|65|12105215
1.3.6.1.2.1.7.2.0|65|0
1.3.6.1.2.1.7.3.0|65|0
1.3.6.1.2.1.7.4.0|65|12105276
1.3.6.1.2.1.11.1.0|65|12103762
1.3.6.1.2.1.11.2.0|65|12103763
1.3.6.1.2.1.11.3.0|65|0
1.3.6.1.2.1.11.4.0|65|0
1.3.6.1.2.1.11.5.0|65|520069
1.3.6.1.2.1.11.6.0|65|0
1.3.6.1.2.1.11.8.0|65|0
1.3.6.1.2.1.11.9.0|65|0
1.3.6.1.2.1.11.10.0|65|0
1.3.6.1.2.1.11.11.0|65|0
1.3.6.1.2.1.11.12.0|65|0
1.3.6.1.2.1.11.13.0|65|11862094
1.3.6.1.2.1.11.14.0|65|0
1.3.6.1.2.1.11.15.0|65|8484260
1.3.6.1.2.1.11.16.0|65|855507
1.3.6.1.2.1.11.17.0|65|0
1.3.6.1.2.1.11.18.0|65|0
1.3.6.1.2.1.11.19.0|65|0
1.3.6.1.2.1.11.20.0|65|0
1.3.6.1.2.1.11.21.0|65|519752
1.3.6.1.2.1.11.22.0|65|0
1.3.6.1.2.1.11.24.0|65|0
1.3.6.1.2.1.11.25.0|65|0
1.3.6.1.2.1.11.26.0|65|0
1.3.6.1.2.1.11.27.0|65|0
1.3.6.1.2.1.11.28.0|65|12103811
1.3.6.1.2.1.11.29.0|65|0
1.3.6.1.2.1.11.31.0|65|0
1.3.6.1.2.1.11.32.0|65|0
1.3.6.1.2.1.33.1.1.1.0|4|APC
1.3.6.1.4.1.318.1.1.1.1.1.1.0|4|Smart-UPS X 2200
1.3.6.1.4.1.318.1.1.1.1.2.1.0|4|UPS 07.4 (ID1003)
1.3.6.1.4.1.318.1.1.1.1.2.3.0|4|AS1613164024
1.3.6.1.4.1.318.1.1.1.2.1.3.0|4|2016-07-15
1.3.6.1.4.1.318.1.1.1.2.2.3.0|67|494900
1.3.6.1.4.1.318.1.1.1.2.2.4.0|2|1
1.3.6.1.4.1.318.1.1.1.2.3.1.0|66|1000
1.3.6.1.4.1.318.1.1.1.2.3.2.0|66|281
1.3.6.1.4.1.318.1.1.1.2.3.4.0|2|1358
1.3.6.1.4.1.318.1.1.1.3.3.1.0|66|2321
1.3.6.1.4.1.318.1.1.1.3.3.4.0|66|500
1.3.6.1.4.1.318.1.1.1.4.1.1.0|2|2
1.3.6.1.4.1.318.1.1.1.4.3.1.0|66|2321
1.3.6.1.4.1.318.1.1.1.4.3.2.0|66|500
1.3.6.1.4.1.318.1.1.1.4.3.3.0|66|557
1.3.6.1.4.1.318.1.1.1.4.3.4.0|66|52
1.3.6.1.4.1.318.1.1.10.2.2.2.1.1.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.2.1|4|Port 1 Temp 1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.3.1|2|40
1.3.6.1.4.1.318.1.1.10.2.2.2.1.4.1|2|10
1.3.6.1.4.1.318.1.1.10.2.2.2.1.5.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.6.1|2|-1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.7.1|2|-1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.8.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.9.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.10.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.11.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.12.1|2|60
1.3.6.1.4.1.318.1.1.10.2.2.2.1.13.1|2|0
1.3.6.1.4.1.318.1.1.10.2.2.2.1.14.1|2|-1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.15.1|2|-1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.16.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.17.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.18.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.19.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.20.1|2|0
1.3.6.1.4.1.318.1.1.10.2.2.2.1.21.1|2|-1
1.3.6.1.4.1.318.1.1.10.2.2.2.1.22.1|4|Port 1
1.3.6.1.4.1.318.1.1.10.2.2.4.1.1.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.4.1.1.2|2|2
1.3.6.1.4.1.318.1.1.10.2.2.4.1.2.1|4|Unknown
1.3.6.1.4.1.318.1.1.10.2.2.4.1.2.2|4|Unknown
1.3.6.1.4.1.318.1.1.10.2.2.4.1.3.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.4.1.3.2|2|1
1.3.6.1.4.1.318.1.1.10.2.2.4.1.4.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.4.1.4.2|2|1
1.3.6.1.4.1.318.1.1.10.2.2.4.1.5.1|2|1
1.3.6.1.4.1.318.1.1.10.2.2.4.1.5.2|2|1
1.3.6.1.4.1.318.1.1.10.2.2.4.1.6.1|4|Unknown
1.3.6.1.4.1.318.1.1.10.2.2.4.1.6.2|4|Unknown
1.3.6.1.4.1.318.1.1.10.2.3.2.1.1.1|2|1
1.3.6.1.4.1.318.1.1.10.2.3.2.1.2.1|4|Port 1 Temp 1
1.3.6.1.4.1.318.1.1.10.2.3.2.1.3.1|2|2
1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1|2|23
1.3.6.1.4.1.318.1.1.10.2.3.2.1.5.1|2|1
1.3.6.1.4.1.318.1.1.10.2.3.2.1.6.1|2|0
1.3.6.1.4.1.318.1.1.10.2.3.2.1.7.1|2|3
1.3.6.1.4.1.318.1.1.10.2.3.2.1.8.1|2|3
1.3.6.1.4.1.318.1.1.10.2.3.2.1.9.1|2|1
1.3.6.1.4.1.318.1.1.10.2.3.2.1.10.1|2|1
1.3.6.1.4.1.318.1.1.10.2.3.2.1.11.1|2|3
1.3.6.1.4.1.318.1.1.10.2.3.2.1.12.1|2|3
1.3.6.1.4.1.318.1.1.10.2.3.2.1.13.1|2|1
1.3.6.1.4.1.318.1.1.10.2.3.2.1.14.1|2|1
1.3.6.1.4.1.318.1.1.10.2.3.2.1.15.1|4|Port 1
1.3.6.1.4.1.318.1.1.10.2.3.4.1.1.1|2|1
1.3.6.1.4.1.318.1.1.10.2.3.4.1.1.2|2|2
1.3.6.1.4.1.318.1.1.10.2.3.4.1.2.1|4|Unknown
1.3.6.1.4.1.318.1.1.10.2.3.4.1.2.2|4|Unknown
1.3.6.1.4.1.318.1.1.10.2.3.4.1.3.1|2|1
1.3.6.1.4.1.318.1.1.10.2.3.4.1.3.2|2|1
1.3.6.1.4.1.318.1.4.2.4.1.4.1|4|v6.8.8
1.3.6.1.4.1.318.1.4.2.4.1.4.2|4|v6.8.8
1.3.6.1.6.3.10.2.1.3.0|2|27388660