1 | <?php |
||
2 | /* |
||
3 | * Copyright (c) 2016 Dropbox, Inc. |
||
4 | * |
||
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
6 | * you may not use this file except in compliance with the License. |
||
7 | * You may obtain a copy of the License at |
||
8 | |||
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
10 | |||
11 | * Unless required by applicable law or agreed to in writing, software |
||
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
14 | * See the License for the specific language governing permissions and |
||
15 | * limitations under the License. |
||
16 | */ |
||
17 | |||
18 | $divisor = '10'; |
||
19 | $multiplier = '1'; |
||
20 | |||
21 | d_echo($pre_cache['sentry4_temp']); |
||
22 | $sentry_temp_scale = snmp_get($device, 'st4TempSensorScale.0', '-Ovq', 'Sentry4-MIB'); |
||
23 | foreach ($pre_cache['sentry4_temp'] as $index => $data) { |
||
24 | $descr = $data['st4TempSensorName']; |
||
25 | $oid = ".1.3.6.1.4.1.1718.4.1.9.3.1.1.$index"; |
||
26 | $low_limit = $data['st4TempSensorLowAlarm']; |
||
27 | $low_warn_limit = $data['st4TempSensorLowWarning']; |
||
28 | $high_limit = $data['st4TempSensorHighAlarm']; |
||
29 | $high_warn_limit = $data['st4TempSensorHighWarning']; |
||
30 | $current = ($data['st4TempSensorValue'] / $divisor); |
||
31 | $user_func = null; |
||
32 | if ($sentry_temp_scale == 'fahrenheit') { |
||
33 | $low_warn_limit = fahrenheit_to_celsius($low_warn_limit, $sentry_temp_scale); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
34 | $low_limit = fahrenheit_to_celsius($low_limit, $sentry_temp_scale); |
||
35 | $high_warn_limit = fahrenheit_to_celsius($high_warn_limit, $sentry_temp_scale); |
||
36 | $high_limit = fahrenheit_to_celsius($high_limit, $sentry_temp_scale); |
||
37 | $current = fahrenheit_to_celsius($current, $sentry_temp_scale); |
||
38 | $user_func = 'fahrenheit_to_celsius'; |
||
39 | } |
||
40 | if (is_numeric($current) && $current >= 0) { |
||
41 | 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); |
||
42 | } |
||
43 | } |
||
44 |