Fix sentry3 voltage sensors (#9649)

* Fix sentry3 voltage sensors

* don't need check, fix array to string conversion
This commit is contained in:
Tony Murray
2019-01-11 10:54:24 -06:00
committed by GitHub
parent d277dee14d
commit 1b29acc275
2 changed files with 234 additions and 22 deletions

View File

@@ -1,25 +1,26 @@
<?php
$oids = snmp_walk($device, 'infeedVoltage', '-OsqnU', 'Sentry3-MIB');
d_echo($oids."\n");
$oids = snmpwalk_group($device, 'infeedVoltage', 'Sentry3-MIB', 2);
d_echo($oids);
if ($oids) {
echo 'Sentry3-MIB ';
$divisor = 10;
$type = 'sentry3';
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$descr) = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$descr = 'Tower '.$index;
$index = $split_oid[(count($split_oid) - 1)];
$oid = '.1.3.6.1.4.1.1718.3.2.2.1.11.1.'.$index;
$current = (snmp_get($device, $oid, '-Oqv') / $divisor);
discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
}
foreach ($oids as $index => $first) {
foreach ($first as $end => $data) {
$divisor = 10;
discover_sensor(
$valid['sensor'],
'voltage',
$device,
".1.3.6.1.4.1.1718.3.2.2.1.11.1.$index.$end",
$index,
'sentry3',
'Tower ' . $index,
$divisor,
1,
null,
null,
null,
null,
empty($data['infeedVoltage']) ? 0 : ($data['infeedVoltage'] / $divisor)
);
}
}

View File

@@ -612,7 +612,7 @@
"sensor_deleted": 0,
"sensor_class": "voltage",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.2.1.11.1.1",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.2.1.11.1.1.1",
"sensor_index": "1",
"sensor_type": "sentry3",
"sensor_descr": "Tower 1",
@@ -630,10 +630,221 @@
"sensor_prev": null,
"user_func": null,
"state_name": null
},
{
"sensor_deleted": 0,
"sensor_class": "voltage",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.2.1.11.1.2.1",
"sensor_index": "2",
"sensor_type": "sentry3",
"sensor_descr": "Tower 2",
"sensor_divisor": 10,
"sensor_multiplier": 1,
"sensor_current": 205.9,
"sensor_limit": 236.785,
"sensor_limit_warn": null,
"sensor_limit_low": 175.015,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": null,
"user_func": null,
"state_name": null
}
],
"state_indexes": []
},
"poller": "matches discovery"
"poller": {
"sensors": [
{
"sensor_deleted": 0,
"sensor_class": "current",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.2.1.7.1.1",
"sensor_index": "infeedID.1.1",
"sensor_type": "sentry3",
"sensor_descr": "Infeed AA",
"sensor_divisor": 100,
"sensor_multiplier": 1,
"sensor_current": 3.62,
"sensor_limit": 5.43,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": null,
"user_func": null,
"state_name": null
},
{
"sensor_deleted": 0,
"sensor_class": "current",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.2.1.7.2.1",
"sensor_index": "infeedID.2.1",
"sensor_type": "sentry3",
"sensor_descr": "Infeed BA",
"sensor_divisor": 100,
"sensor_multiplier": 1,
"sensor_current": 5.02,
"sensor_limit": 7.53,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": null,
"user_func": null,
"state_name": null
},
{
"sensor_deleted": 0,
"sensor_class": "humidity",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.5.1.10.1.1",
"sensor_index": "tempHumidSensorHumidValue1.1",
"sensor_type": "sentry3",
"sensor_descr": "Removable Sensor A1",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": 52,
"sensor_limit": 90,
"sensor_limit_warn": null,
"sensor_limit_low": 10,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": null,
"user_func": null,
"state_name": null
},
{
"sensor_deleted": 0,
"sensor_class": "humidity",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.5.1.10.1.2",
"sensor_index": "tempHumidSensorHumidValue1.2",
"sensor_type": "sentry3",
"sensor_descr": "Removable Sensor A2",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": 43,
"sensor_limit": 90,
"sensor_limit_warn": null,
"sensor_limit_low": 10,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": null,
"user_func": null,
"state_name": null
},
{
"sensor_deleted": 0,
"sensor_class": "temperature",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.5.1.6.1.1",
"sensor_index": "tempHumidSensorTempValue1.1",
"sensor_type": "sentry3",
"sensor_descr": "Removable Sensor A1",
"sensor_divisor": 10,
"sensor_multiplier": 1,
"sensor_current": 20,
"sensor_limit": 45,
"sensor_limit_warn": null,
"sensor_limit_low": 5,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": null,
"user_func": "fahrenheit_to_celsius",
"state_name": null
},
{
"sensor_deleted": 0,
"sensor_class": "temperature",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.5.1.6.1.2",
"sensor_index": "tempHumidSensorTempValue1.2",
"sensor_type": "sentry3",
"sensor_descr": "Removable Sensor A2",
"sensor_divisor": 10,
"sensor_multiplier": 1,
"sensor_current": 23.61,
"sensor_limit": 45,
"sensor_limit_warn": null,
"sensor_limit_low": 5,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": null,
"user_func": "fahrenheit_to_celsius",
"state_name": null
},
{
"sensor_deleted": 0,
"sensor_class": "voltage",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.2.1.11.1.1.1",
"sensor_index": "1",
"sensor_type": "sentry3",
"sensor_descr": "Tower 1",
"sensor_divisor": 10,
"sensor_multiplier": 1,
"sensor_current": 0,
"sensor_limit": 240.695,
"sensor_limit_warn": null,
"sensor_limit_low": 177.905,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": 209.3,
"user_func": null,
"state_name": null
},
{
"sensor_deleted": 0,
"sensor_class": "voltage",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.1718.3.2.2.1.11.1.2.1",
"sensor_index": "2",
"sensor_type": "sentry3",
"sensor_descr": "Tower 2",
"sensor_divisor": 10,
"sensor_multiplier": 1,
"sensor_current": 0,
"sensor_limit": 236.785,
"sensor_limit_warn": null,
"sensor_limit_low": 175.015,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_prev": 205.9,
"user_func": null,
"state_name": null
}
],
"state_indexes": []
}
}
}