1<?php
2
3echo 'Sub10 temperature ';
4
5// Get Current Value
6$temp_oid = 'sub10UnitLclMWUTemperature.0';
7[$oid, $current] = explode(' ', snmp_get($device, $temp_oid, '-OsqnU', 'SUB10SYSTEMS-MIB'));
8
9// Get Alarm Ranges
10$alarm_oid = 'sub10UnitMgmtAlarmName';
11$alarms = snmp_walk($device, $alarm_oid, '-OsqU', 'SUB10SYSTEMS-MIB');
12$indexes = [];
13foreach (explode("\n", $alarms) as $alarm) {
14    if (preg_match('/^\w+\.(\d) MWU Temperature (.*)$/', $alarm, $matches)) {
15        $indexes[strtolower($matches[2])] = $matches[1];
16    }
17}
18
19$thresh_oid = 'sub10UnitMgmtAlarmRaiseThresh';
20$threshes = snmp_walk($device, $thresh_oid, '-OsqU', 'SUB10SYSTEMS-MIB');
21$thresholds = [];
22foreach (explode("\n", $threshes) as $thresh) {
23    preg_match('/^\w+\.(\d) (.*)$/', $thresh, $matches);
24    $thresholds[$matches[1]] = $matches[2];
25}
26
27// Create Sensor
28discover_sensor($valid['sensor'], 'temperature', $device, $oid, $oid, 'sub10', 'Modem', '1', '1', $thresholds[$indexes['low']], null, null, $thresholds[$indexes['high']], $current);
29