fix: qnap temperature sensors #4586

This commit is contained in:
crcro
2016-10-11 09:34:16 +03:00
committed by Neil Lathwood
parent 7d3cafddba
commit a7489e2645

View File

@@ -1,33 +1,44 @@
<?php <?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') { if ($device['os'] == 'qnap') {
echo 'QNAP: '; echo 'QNAP: ';
// Turbo NAS Temperature $system_temperature_oid = '.1.3.6.1.4.1.24681.1.3.6.0';
$turbonas_temperature_oid = '.1.3.6.1.4.1.24681.1.3.6.0'; $system_temperature = snmp_get($device, $system_temperature_oid, '-Oqv');
// Turbo NAS Disk Temperature discover_sensor($valid['sensor'], 'temperature', $device, $system_temperature_oid, '99', 'snmp', 'System Temperature', '1', '1', null, null, null, null, $system_temperature);
$disk_temperature_oid = '.1.3.6.1.4.1.24681.1.2.11.1.3.';
$temps_oid = '24681.1.2.11.1.3.';
$serials_oid = '24681.1.2.11.1.5.';
// Get Turbo NAS temperature $disk_temperature_oid = '.1.3.6.1.4.1.24681.1.2.11.1.3';
$turbonas_temperature = snmp_get($device, $turbonas_temperature_oid, '-Oqv'); $disk_serial_oid = '1.3.6.1.4.1.24681.1.2.11.1.5';
// 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);
$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 if (is_array($hdd_temps) && !empty($hdd_temps)) {
$disks = snmpwalk_cache_multi_oid($device, 'SystemHdTable', array(), 'NAS-MIB'); foreach ($hdd_temps as $index => $entry) {
// Parse all disks in the device to get the temperatures $index = str_replace($temps_oid, '', $index);
if (is_array($disks)) { $disk_temperature = $entry['enterprises'];
foreach ($disks as $disk_number => $entry) { $disk_serial = str_replace('"', '', $hdd_serials[$serials_oid . $index]['enterprises']);
// Get the disk temperature full oid
$disk_oid = $disk_temperature_oid.$disk_number; if ($disk_serial == '--') {
// Get the temperature for the disk $disk_descr = "HDD $index empty bay";
$disk_temperature = $entry['HdTemperature']; } else {
// Getting the disk information (Number and model) $disk_descr = "HDD $index $disk_serial";
$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); discover_sensor($valid['sensor'], 'temperature', $device, $disk_temperature_oid . '.' . $index, $index, 'snmp', $disk_descr, '1', '1', null, null, null, null, $disk_temperature);
} }
} }
} }