Fix for number in sensor string (#14185)

* Fix for extracting sensor value from string in poller

* Remove duplicate code

* Update microsemitime.json

Co-authored-by: Maikel de Boer <mdb@tampnet.com>
Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Janno Schouwenburg
2022-08-07 21:49:38 +02:00
committed by GitHub
parent c807e409d9
commit ebe16a79d1
2 changed files with 6 additions and 356 deletions

View File

@@ -80,12 +80,14 @@ function poll_sensor($device, $class)
require 'includes/polling/sensors/' . $class . '/' . $device['os_group'] . '.inc.php';
}
if ($class == 'temperature') {
preg_match('/[\d\.\-]+/', $sensor_value, $temp_response);
if (! is_numeric($sensor_value)) {
preg_match('/-?\d*\.?\d+/', $sensor_value, $temp_response);
if (! empty($temp_response[0])) {
$sensor_value = $temp_response[0];
}
} elseif ($class == 'state') {
}
if ($class == 'state') {
if (! is_numeric($sensor_value)) {
$state_value = dbFetchCell(
'SELECT `state_value`

View File

@@ -1950,359 +1950,7 @@
}
]
},
"poller": {
"sensors": [
{
"sensor_deleted": 0,
"sensor_class": "count",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.9070.1.2.3.1.5.1.3.2.0",
"sensor_index": "0",
"sensor_type": "microsemitime",
"sensor_descr": "GPS UTC Offset",
"group": null,
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": 18,
"sensor_limit": null,
"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": "state",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.9070.1.2.3.1.5.1.3.3.0",
"sensor_index": "0",
"sensor_type": "gpsHealth",
"sensor_descr": "GPS Receiver Health",
"group": null,
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": 0,
"sensor_limit": null,
"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": 8,
"user_func": null,
"state_name": "gpsHealth"
},
{
"sensor_deleted": 0,
"sensor_class": "state",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.9070.1.2.3.1.5.1.3.5.0",
"sensor_index": "0",
"sensor_type": "gpsMode",
"sensor_descr": "GPS Receiver Mode",
"group": null,
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": 2,
"sensor_limit": null,
"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": "gpsMode"
},
{
"sensor_deleted": 0,
"sensor_class": "state",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.9070.1.2.3.1.5.1.1.18.0",
"sensor_index": "0",
"sensor_type": "ntpSysMode",
"sensor_descr": "NTP Mode",
"group": null,
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": 3,
"sensor_limit": null,
"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": "ntpSysMode"
},
{
"sensor_deleted": 0,
"sensor_class": "state",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.9070.1.2.3.1.5.1.2.2.0",
"sensor_index": "0",
"sensor_type": "tymingSource",
"sensor_descr": "Hardware Clock Source",
"group": null,
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": 4,
"sensor_limit": null,
"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": "tymingSource"
},
{
"sensor_deleted": 0,
"sensor_class": "state",
"poller_type": "snmp",
"sensor_oid": ".1.3.6.1.4.1.9070.1.2.3.1.5.1.2.1.0",
"sensor_index": "0",
"sensor_type": "tymingStatus",
"sensor_descr": "Hardware Clock State",
"group": null,
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": 1,
"sensor_limit": null,
"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": "tymingStatus"
}
],
"state_indexes": [
{
"state_name": "gpsHealth",
"state_descr": "Receiver Down",
"state_draw_graph": 1,
"state_value": 0,
"state_generic_value": 2
},
{
"state_name": "gpsHealth",
"state_descr": "Unknown Mode",
"state_draw_graph": 1,
"state_value": 1,
"state_generic_value": 2
},
{
"state_name": "gpsHealth",
"state_descr": "Acquiring Signal",
"state_draw_graph": 1,
"state_value": 2,
"state_generic_value": 1
},
{
"state_name": "gpsHealth",
"state_descr": "Bad Geometry",
"state_draw_graph": 1,
"state_value": 3,
"state_generic_value": 1
},
{
"state_name": "gpsHealth",
"state_descr": "Propagate Mode",
"state_draw_graph": 1,
"state_value": 4,
"state_generic_value": 0
},
{
"state_name": "gpsHealth",
"state_descr": "2D Solution",
"state_draw_graph": 1,
"state_value": 5,
"state_generic_value": 0
},
{
"state_name": "gpsHealth",
"state_descr": "3D Solution",
"state_draw_graph": 1,
"state_value": 6,
"state_generic_value": 0
},
{
"state_name": "gpsHealth",
"state_descr": "Position Hold",
"state_draw_graph": 1,
"state_value": 7,
"state_generic_value": 0
},
{
"state_name": "gpsHealth",
"state_descr": "Time Valid",
"state_draw_graph": 1,
"state_value": 8,
"state_generic_value": 0
},
{
"state_name": "gpsMode",
"state_descr": "Receiver Mode: Survey",
"state_draw_graph": 1,
"state_value": 0,
"state_generic_value": 0
},
{
"state_name": "gpsMode",
"state_descr": "Receiver Mode: Dynamic",
"state_draw_graph": 1,
"state_value": 1,
"state_generic_value": 0
},
{
"state_name": "gpsMode",
"state_descr": "Receiver Mode: Hold",
"state_draw_graph": 1,
"state_value": 2,
"state_generic_value": 0
},
{
"state_name": "ntpSysMode",
"state_descr": "unspecified",
"state_draw_graph": 1,
"state_value": 0,
"state_generic_value": 3
},
{
"state_name": "ntpSysMode",
"state_descr": "symmetric active",
"state_draw_graph": 1,
"state_value": 1,
"state_generic_value": 0
},
{
"state_name": "ntpSysMode",
"state_descr": "symmetric passive",
"state_draw_graph": 1,
"state_value": 2,
"state_generic_value": 0
},
{
"state_name": "ntpSysMode",
"state_descr": "client",
"state_draw_graph": 1,
"state_value": 3,
"state_generic_value": 1
},
{
"state_name": "ntpSysMode",
"state_descr": "server",
"state_draw_graph": 1,
"state_value": 4,
"state_generic_value": 0
},
{
"state_name": "ntpSysMode",
"state_descr": "broadcast",
"state_draw_graph": 1,
"state_value": 5,
"state_generic_value": 0
},
{
"state_name": "ntpSysMode",
"state_descr": "reserved for NTP control messages",
"state_draw_graph": 1,
"state_value": 6,
"state_generic_value": 3
},
{
"state_name": "ntpSysMode",
"state_descr": "reserved for private use",
"state_draw_graph": 1,
"state_value": 7,
"state_generic_value": 3
},
{
"state_name": "tymingSource",
"state_descr": "None",
"state_draw_graph": 1,
"state_value": 0,
"state_generic_value": 2
},
{
"state_name": "tymingSource",
"state_descr": "GPS",
"state_draw_graph": 1,
"state_value": 1,
"state_generic_value": 0
},
{
"state_name": "tymingSource",
"state_descr": "GPS",
"state_draw_graph": 1,
"state_value": 4,
"state_generic_value": 0
},
{
"state_name": "tymingSource",
"state_descr": "IRIG",
"state_draw_graph": 1,
"state_value": 8,
"state_generic_value": 0
},
{
"state_name": "tymingSource",
"state_descr": "External 1PPS",
"state_draw_graph": 1,
"state_value": 16,
"state_generic_value": 0
},
{
"state_name": "tymingSource",
"state_descr": "External 10MHz",
"state_draw_graph": 1,
"state_value": 24,
"state_generic_value": 0
},
{
"state_name": "tymingSource",
"state_descr": "Free-run",
"state_draw_graph": 1,
"state_value": 31,
"state_generic_value": 1
},
{
"state_name": "tymingStatus",
"state_descr": "Good",
"state_draw_graph": 1,
"state_value": 0,
"state_generic_value": 0
},
{
"state_name": "tymingStatus",
"state_descr": "Bad",
"state_draw_graph": 1,
"state_value": 1,
"state_generic_value": 2
}
]
}
"poller": "matches discovery"
},
"storage": {
"discovery": {