Skip to content

Commit

Permalink
newdevice: Added additional sensor support for PowerWalker librenms#5080
Browse files Browse the repository at this point in the history
  • Loading branch information
laf committed Dec 26, 2016
1 parent d121e43 commit 477cbc2
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1,197 deletions.
34 changes: 34 additions & 0 deletions includes/discovery/sensors/pre-cache/powerwalker.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* powerwalker.inc.php
*
* LibreNMS pre-cache sensor discovery module for PowerWalker
*
* 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 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/

if ($device['os'] === 'powerwalker') {
echo 'Pre-cache PowerWalker: ';

$pw_oids = array();
echo 'Caching OIDs:';

$pw_oids = snmpwalk_cache_multi_oid($device, '.1.3.6.1.2.1.33.1.3.3.1', array(), 'UPS-MIB');
$pw_oids = snmpwalk_cache_index($device, '.1.3.6.1.2.1.33.1.4.4.1', $pw_oids, 'UPS-MIB');
}
37 changes: 37 additions & 0 deletions includes/discovery/sensors/temperatures/powerwalker.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* powerwalker.inc.php
*
* LibreNMS temperature sensor discovery module for PowerWalker
*
* 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 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/

if ($device['os'] === 'powerwalker') {
echo("PowerWalker ");

$descr = 'Ambient Temperature';
$oid = '.1.3.6.1.2.1.33.1.2.7.0';
$value = snmp_get($device, 'upsBatteryTemperature.0', '-Oqv', 'UPS-MIB');
$value = preg_replace('/\D/', '', $value);

if (is_numeric($value) && $value > 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 1, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
}
}
49 changes: 49 additions & 0 deletions includes/discovery/sensors/voltages/powerwalker.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* powerwalker.inc.php
*
* LibreNMS voltages sensor discovery module for PowerWalker
*
* 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 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/

if ($device['os'] === 'powerwalker') {
echo("PowerWalker ");

$descr = 'Battery Voltage';
$oid = '.1.3.6.1.2.1.33.1.2.5.0';
$value = snmp_get($device, 'upsBatteryVoltage.0', '-Oqv', 'UPS-MIB');
$value = preg_replace('/\D/', '', $value);

if (is_numeric($value) && $value > 0) {
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 1, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
}

if (is_numeric($pw_oids['upsInputVoltage'])) {
$descr = 'Input Voltage';
$oid = '.1.3.6.1.2.1.33.1.3.3.1.3';
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 2, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
}

if (is_numeric($pw_oids['upsOutputVoltage'])) {
$descr = 'Output Voltage';
$oid = '.1.3.6.1.2.1.33.1.4.4.1.2';
discover_sensor($valid['sensor'], 'voltage', $device, $oid, 3, 'powerwalker', $descr, '1', '1', null, null, null, null, $value);
}
}
Loading

0 comments on commit 477cbc2

Please sign in to comment.