mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Rewrite for qnap fanspeeds (#4590)
This commit is contained in:
@@ -1,24 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* LibreNMS QNAP NAS Fanspeeds information module
|
||||
*
|
||||
* Copyright (c) 2016 Cercel Valentin <[email protected]>
|
||||
* 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. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if ($device['os'] == 'qnap') {
|
||||
echo 'QNAP: ';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'SystemFanTable', array(), 'NAS-MIB');
|
||||
|
||||
// Turbo NAS Fanspeed
|
||||
$fan_speed_oid = '.1.3.6.1.4.1.24681.1.2.15.1.3.';
|
||||
$fan_descr_oid = '.1.3.6.1.4.1.24681.1.2.15.1.2';
|
||||
$fan_speed_oid = '.1.3.6.1.4.1.24681.1.2.15.1.3';
|
||||
$descr_oid = '24681.1.2.15.1.2.';
|
||||
$speed_oid = '24681.1.2.15.1.3.';
|
||||
|
||||
// Parse all fans in the device to get the speed
|
||||
if (is_array($oids)) {
|
||||
foreach ($oids as $fan_number => $entry) {
|
||||
// Get the fan speed full oid
|
||||
$fan_oid = $fan_speed_oid.$fan_number;
|
||||
// Get the fan speed
|
||||
$fan_speed = $entry['SysFanSpeed'];
|
||||
// Getting the fan information
|
||||
$fan_information = $entry['SysFanDescr'];
|
||||
// Save the temperature for the disk
|
||||
discover_sensor($valid['sensor'], 'fanspeed', $device, $fan_oid, $fan_number, 'snmp', $fan_information, '1', '1', null, null, null, null, $fan_speed);
|
||||
|
||||
$fans_descr = snmpwalk_cache_multi_oid($device, $fan_descr_oid, array());
|
||||
$fans_speed = snmpwalk_cache_multi_oid($device, $fan_speed_oid, array());
|
||||
|
||||
if (is_array($fans_speed) && !empty($fans_speed)) {
|
||||
foreach ($fans_speed as $index => $entry) {
|
||||
$index = str_replace($speed_oid, '', $index);
|
||||
$fan_speed = $entry['enterprises'];
|
||||
$fan_serial = str_replace('"', '', $fans_descr[$descr_oid . $index]['enterprises']);
|
||||
discover_sensor($valid['sensor'], 'fanspeed', $device, $fan_speed_oid.$index, $index, 'snmp', $fan_serial, '1', '1', null, null, null, null, $fan_speed);
|
||||
}
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user