mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* fixing sentry3 temperature sensor issues: read all sensors not just first two, fix reading limit and current values, fixing snmp get options * fixing sentry4 temperature sensor issues: read all sensors not just first two, fix reading limit and current values, fixing snmp get options * fixing code style issues * addressing review items from murrant, removing individual snmp_gets, fixing fahrenheit to celcius code back * addressing review items, putting back the celcius fahrenheit conversion logic back * using snmpwalk_cache_oid instead of reinventing in sentry3 code * using pre-cache for sentry4 temp sensors, addressing review items * checking all sentry3 humidity sensors instead of first two, bulk reading instead of individual gets * addressing style issues * pre-caching sentry4 humidity warning table removing duplicate temp sensor event config table * adding two more sentry snmprec files after temperature and humidity sensor updates * making sensor index values for sentry3/4 unique * adding sentry3 and 4 test data files after temperature and humidity sensors update
45 lines
2.0 KiB
PHP
45 lines
2.0 KiB
PHP
<?php
|
|
/*
|
|
* Copyright (c) 2016 Dropbox, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
|
|
$divisor = '10';
|
|
$multiplier = '1';
|
|
|
|
d_echo($pre_cache['sentry4_temp']);
|
|
$sentry_temp_scale = snmp_get($device, 'st4TempSensorScale.0', '-Ovq', 'Sentry4-MIB');
|
|
foreach ($pre_cache['sentry4_temp'] as $index => $data) {
|
|
$descr = $data['st4TempSensorName'];
|
|
$oid = ".1.3.6.1.4.1.1718.4.1.9.3.1.1.$index";
|
|
$low_limit = $data['st4TempSensorLowAlarm'];
|
|
$low_warn_limit = $data['st4TempSensorLowWarning'];
|
|
$high_limit = $data['st4TempSensorHighAlarm'];
|
|
$high_warn_limit = $data['st4TempSensorHighWarning'];
|
|
$current = ($data['st4TempSensorValue'] / $divisor);
|
|
$user_func = null;
|
|
if ($sentry_temp_scale == 'fahrenheit') {
|
|
$low_warn_limit = fahrenheit_to_celsius($low_warn_limit, $sentry_temp_scale);
|
|
$low_limit = fahrenheit_to_celsius($low_limit, $sentry_temp_scale);
|
|
$high_warn_limit = fahrenheit_to_celsius($high_warn_limit, $sentry_temp_scale);
|
|
$high_limit = fahrenheit_to_celsius($high_limit, $sentry_temp_scale);
|
|
$current = fahrenheit_to_celsius($current, $sentry_temp_scale);
|
|
$user_func = 'fahrenheit_to_celsius';
|
|
}
|
|
if (is_numeric($current) && $current >= 0) {
|
|
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'st4TempSensorValue'.$index, 'sentry4', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current, 'snmp', null, null, $user_func);
|
|
}
|
|
}
|