mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: qnap temperature sensors #4586
This commit is contained in:
@@ -1,33 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS QNAP NAS temperature information module
|
||||
*
|
||||
* Copyright (c) 2016 Cercel Valentin <crc@nuamchefazi.ro>
|
||||
* 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: ';
|
||||
|
||||
// Turbo NAS Temperature
|
||||
$turbonas_temperature_oid = '.1.3.6.1.4.1.24681.1.3.6.0';
|
||||
// Turbo NAS Disk Temperature
|
||||
$disk_temperature_oid = '.1.3.6.1.4.1.24681.1.2.11.1.3.';
|
||||
$system_temperature_oid = '.1.3.6.1.4.1.24681.1.3.6.0';
|
||||
$system_temperature = snmp_get($device, $system_temperature_oid, '-Oqv');
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $system_temperature_oid, '99', 'snmp', 'System Temperature', '1', '1', null, null, null, null, $system_temperature);
|
||||
|
||||
$temps_oid = '24681.1.2.11.1.3.';
|
||||
$serials_oid = '24681.1.2.11.1.5.';
|
||||
|
||||
// Get Turbo NAS temperature
|
||||
$turbonas_temperature = snmp_get($device, $turbonas_temperature_oid, '-Oqv');
|
||||
// Save the Turbo NAS temperature
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $turbonas_temperature_oid, '99', 'snmp', 'System Temperature', '1', '1', null, null, null, null, $turbonas_temperature);
|
||||
$disk_temperature_oid = '.1.3.6.1.4.1.24681.1.2.11.1.3';
|
||||
$disk_serial_oid = '1.3.6.1.4.1.24681.1.2.11.1.5';
|
||||
|
||||
$hdd_temps = snmpwalk_cache_multi_oid($device, $disk_temperature_oid, array());
|
||||
$hdd_serials = snmpwalk_cache_multi_oid($device, $disk_serial_oid, array());
|
||||
|
||||
// Get all disks in the device
|
||||
$disks = snmpwalk_cache_multi_oid($device, 'SystemHdTable', array(), 'NAS-MIB');
|
||||
// Parse all disks in the device to get the temperatures
|
||||
if (is_array($disks)) {
|
||||
foreach ($disks as $disk_number => $entry) {
|
||||
// Get the disk temperature full oid
|
||||
$disk_oid = $disk_temperature_oid.$disk_number;
|
||||
// Get the temperature for the disk
|
||||
$disk_temperature = $entry['HdTemperature'];
|
||||
// Getting the disk information (Number and model)
|
||||
$disk_information = $entry['HdDescr'].' '.$entry['HdModel'];
|
||||
// Save the temperature for the disk
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $disk_oid, $disk_number, 'snmp', $disk_information, '1', '1', null, null, null, null, $disk_temperature);
|
||||
if (is_array($hdd_temps) && !empty($hdd_temps)) {
|
||||
foreach ($hdd_temps as $index => $entry) {
|
||||
$index = str_replace($temps_oid, '', $index);
|
||||
$disk_temperature = $entry['enterprises'];
|
||||
$disk_serial = str_replace('"', '', $hdd_serials[$serials_oid . $index]['enterprises']);
|
||||
|
||||
if ($disk_serial == '--') {
|
||||
$disk_descr = "HDD $index empty bay";
|
||||
} else {
|
||||
$disk_descr = "HDD $index $disk_serial";
|
||||
}
|
||||
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $disk_temperature_oid . '.' . $index, $index, 'snmp', $disk_descr, '1', '1', null, null, null, null, $disk_temperature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user