mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added discovery of serverscheck flooding sensor (#8923)
Added discovery for state of serverscheck flooding sensors. DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
committed by
Neil Lathwood
parent
b844dd44c8
commit
60a1a02f88
65
includes/discovery/sensors/state/serverscheck.inc.php
Normal file
65
includes/discovery/sensors/state/serverscheck.inc.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* serverscheck.inc.php
|
||||
*
|
||||
* LibreNMS state discover module for serverscheck flooding sensor
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 Marcus Pink
|
||||
* @author Marcus Pink <mpink@avantgarde-labs.de>
|
||||
*/
|
||||
|
||||
$serverscheck_oids = [
|
||||
'sensor1Value.0' => '.1.3.6.1.4.1.17095.3.2.0',
|
||||
'sensor2Value.0' => '.1.3.6.1.4.1.17095.3.6.0',
|
||||
'sensor3Value.0' => '.1.3.6.1.4.1.17095.3.10.0',
|
||||
'sensor4Value.0' => '.1.3.6.1.4.1.17095.3.14.0',
|
||||
'sensor5Value.0' => '.1.3.6.1.4.1.17095.3.18.0',
|
||||
];
|
||||
|
||||
foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) {
|
||||
if ((str_contains($oid_name, 'name')) && (str_contains($oid_value, array('Flooding', 'Leckage')))) {
|
||||
preg_match("/(\d+)/", $oid_name, $temp_x);
|
||||
$tmp_oid = 'sensor' . $temp_x[0] . 'Value.0';
|
||||
$current = $pre_cache['serverscheck_control'][$tmp_oid];
|
||||
$state = 'Serverscheck_FloodSensor';
|
||||
if ($current) {
|
||||
$index = str_replace('.0', '', $oid_name);
|
||||
$descr = $oid_value;
|
||||
$state_index_id = create_state_index($state);
|
||||
if ($state_index_id) {
|
||||
$states = [
|
||||
[$state_index_id, '-', 1, 1, 1],
|
||||
[$state_index_id, 'DRY', 1, 2, 0],
|
||||
[$state_index_id, 'WET', 1, 4, 2],
|
||||
];
|
||||
foreach ($states as $value) {
|
||||
$insert = [
|
||||
'state_index_id' => $value[0],
|
||||
'state_descr' => $value[1],
|
||||
'state_draw_graph' => $value[2],
|
||||
'state_value' => $value[3],
|
||||
'state_generic_value' => $value[4]
|
||||
];
|
||||
dbInsert($insert, 'state_translations');
|
||||
}
|
||||
}
|
||||
discover_sensor($valid['sensor'], 'state', $device, $serverscheck_oids[$tmp_oid], $index, $state, $descr, 1, 1, null, null, null, null, 1);
|
||||
create_sensor_to_state_index($device, $state, $index);
|
||||
}
|
||||
}
|
||||
}
|
200
tests/data/serverscheck.json
Normal file
200
tests/data/serverscheck.json
Normal file
@@ -0,0 +1,200 @@
|
||||
{
|
||||
"os": {
|
||||
"discovery": {
|
||||
"devices": [
|
||||
{
|
||||
"sysName": "<private>",
|
||||
"sysObjectID": ".1.3.6.1.4.1.17095",
|
||||
"sysDescr": "Temperature & Sensor Gateway",
|
||||
"sysContact": null,
|
||||
"version": null,
|
||||
"hardware": "",
|
||||
"features": null,
|
||||
"location": null,
|
||||
"os": "serverscheck",
|
||||
"type": "network",
|
||||
"serial": null,
|
||||
"icon": "generic.svg"
|
||||
}
|
||||
]
|
||||
},
|
||||
"poller": {
|
||||
"devices": [
|
||||
{
|
||||
"sysName": "<private>",
|
||||
"sysObjectID": ".1.3.6.1.4.1.17095",
|
||||
"sysDescr": "Temperature & Sensor Gateway",
|
||||
"sysContact": "<private>",
|
||||
"version": null,
|
||||
"hardware": "",
|
||||
"features": null,
|
||||
"location": "<private>",
|
||||
"os": "serverscheck",
|
||||
"type": "network",
|
||||
"serial": null,
|
||||
"icon": "generic.svg"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"sensors": {
|
||||
"discovery": {
|
||||
"sensors": [
|
||||
{
|
||||
"sensor_deleted": "0",
|
||||
"sensor_class": "state",
|
||||
"poller_type": "snmp",
|
||||
"sensor_oid": ".1.3.6.1.4.1.17095.3.10.0",
|
||||
"sensor_index": "sensor3name",
|
||||
"sensor_type": "Serverscheck_FloodSensor",
|
||||
"sensor_descr": "Flooding",
|
||||
"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": "Serverscheck_FloodSensor"
|
||||
},
|
||||
{
|
||||
"sensor_deleted": "0",
|
||||
"sensor_class": "temperature",
|
||||
"poller_type": "snmp",
|
||||
"sensor_oid": ".1.3.6.1.4.1.17095.3.2.0",
|
||||
"sensor_index": "sensor1name",
|
||||
"sensor_type": "serverscheck",
|
||||
"sensor_descr": "Temperature",
|
||||
"sensor_divisor": "1",
|
||||
"sensor_multiplier": "1",
|
||||
"sensor_current": "27.53",
|
||||
"sensor_limit": "47.53",
|
||||
"sensor_limit_warn": null,
|
||||
"sensor_limit_low": "17.53",
|
||||
"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": [
|
||||
{
|
||||
"state_name": "Serverscheck_FloodSensor",
|
||||
"state_descr": "-",
|
||||
"state_draw_graph": "1",
|
||||
"state_value": "1",
|
||||
"state_generic_value": "1"
|
||||
},
|
||||
{
|
||||
"state_name": "Serverscheck_FloodSensor",
|
||||
"state_descr": "DRY",
|
||||
"state_draw_graph": "1",
|
||||
"state_value": "2",
|
||||
"state_generic_value": "0"
|
||||
},
|
||||
{
|
||||
"state_name": "Serverscheck_FloodSensor",
|
||||
"state_descr": "WET",
|
||||
"state_draw_graph": "1",
|
||||
"state_value": "4",
|
||||
"state_generic_value": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"poller": {
|
||||
"sensors": [
|
||||
{
|
||||
"sensor_deleted": "0",
|
||||
"sensor_class": "state",
|
||||
"poller_type": "snmp",
|
||||
"sensor_oid": ".1.3.6.1.4.1.17095.3.10.0",
|
||||
"sensor_index": "sensor3name",
|
||||
"sensor_type": "Serverscheck_FloodSensor",
|
||||
"sensor_descr": "Flooding",
|
||||
"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": "1",
|
||||
"user_func": null,
|
||||
"state_name": "Serverscheck_FloodSensor"
|
||||
},
|
||||
{
|
||||
"sensor_deleted": "0",
|
||||
"sensor_class": "temperature",
|
||||
"poller_type": "snmp",
|
||||
"sensor_oid": ".1.3.6.1.4.1.17095.3.2.0",
|
||||
"sensor_index": "sensor1name",
|
||||
"sensor_type": "serverscheck",
|
||||
"sensor_descr": "Temperature",
|
||||
"sensor_divisor": "1",
|
||||
"sensor_multiplier": "1",
|
||||
"sensor_current": "27.53",
|
||||
"sensor_limit": "47.53",
|
||||
"sensor_limit_warn": null,
|
||||
"sensor_limit_low": "17.53",
|
||||
"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": [
|
||||
{
|
||||
"state_name": "Serverscheck_FloodSensor",
|
||||
"state_descr": "-",
|
||||
"state_draw_graph": "1",
|
||||
"state_value": "1",
|
||||
"state_generic_value": "1"
|
||||
},
|
||||
{
|
||||
"state_name": "Serverscheck_FloodSensor",
|
||||
"state_descr": "DRY",
|
||||
"state_draw_graph": "1",
|
||||
"state_value": "2",
|
||||
"state_generic_value": "0"
|
||||
},
|
||||
{
|
||||
"state_name": "Serverscheck_FloodSensor",
|
||||
"state_descr": "WET",
|
||||
"state_draw_graph": "1",
|
||||
"state_value": "4",
|
||||
"state_generic_value": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"bgp-peers": {
|
||||
"discovery": {
|
||||
"devices": [
|
||||
{
|
||||
"bgpLocalAs": null
|
||||
}
|
||||
],
|
||||
"bgpPeers": [],
|
||||
"bgpPeers_cbgp": []
|
||||
},
|
||||
"poller": "matches discovery"
|
||||
}
|
||||
}
|
@@ -1,2 +1,25 @@
|
||||
1.3.6.1.2.1.1.1.0|4|Temperature & Sensor Gateway
|
||||
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.17095
|
||||
1.3.6.1.2.1.1.3.0|67|5933472
|
||||
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.4.1.17095.3.1.0|4|Temperature
|
||||
1.3.6.1.4.1.17095.3.2.0|4|27.53
|
||||
1.3.6.1.4.1.17095.3.3.0|4|-
|
||||
1.3.6.1.4.1.17095.3.4.0|4|-
|
||||
1.3.6.1.4.1.17095.3.5.0|4|Ping GW
|
||||
1.3.6.1.4.1.17095.3.6.0|4|1.00
|
||||
1.3.6.1.4.1.17095.3.7.0|4|-
|
||||
1.3.6.1.4.1.17095.3.8.0|4|-
|
||||
1.3.6.1.4.1.17095.3.9.0|4|Flooding
|
||||
1.3.6.1.4.1.17095.3.10.0|4|DRY
|
||||
1.3.6.1.4.1.17095.3.11.0|4|DOWN
|
||||
1.3.6.1.4.1.17095.3.12.0|4|20 July 2018,08:10:35
|
||||
1.3.6.1.4.1.17095.3.13.0|4|-
|
||||
1.3.6.1.4.1.17095.3.14.0|4|-
|
||||
1.3.6.1.4.1.17095.3.15.0|4|-
|
||||
1.3.6.1.4.1.17095.3.16.0|4|-
|
||||
1.3.6.1.4.1.17095.3.17.0|4|-
|
||||
1.3.6.1.4.1.17095.3.18.0|4|-
|
||||
1.3.6.1.4.1.17095.3.19.0|4|-
|
||||
|
Reference in New Issue
Block a user