<?php if ($device['os'] == 'routeros') { $oids = snmp_walk($device, 'mtxrHlTemperature', '-OsqnU', 'MIKROTIK-MIB'); if ($debug) { echo $oids . "\n"; } if ($oids !== false) { echo 'MIKROTIK-MIB '; } $divisor = 10.0; $type = 'mikrotik'; foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $descr) = explode(' ', $data, 2); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; $descr = 'Temperature ' . $index; $oid = '.1.3.6.1.4.1.14988.1.1.3.10.' . $index; $temperature = snmp_get($device, $oid, '-Oqv') / $divisor; discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $temperature); } } }
<?php if ($device['os'] == "junos" || $device['os_group'] == "junos") { echo "JunOS "; $oids = snmp_walk($device, "1.3.6.1.4.1.2636.3.1.13.1.7", "-Osqn", "JUNIPER-MIB", $config['install_dir'] . "/mibs/junos"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { $data = trim($data); $data = substr($data, 29); if ($data) { list($oid) = explode(" ", $data); $temperature_oid = "1.3.6.1.4.1.2636.3.1.13.1.7.{$oid}"; $descr_oid = "1.3.6.1.4.1.2636.3.1.13.1.5.{$oid}"; $descr = snmp_get($device, $descr_oid, "-Oqv", "JUNIPER-MIB", '+' . $config['install_dir'] . "/mibs/junos"); $temperature = snmp_get($device, $temperature_oid, "-Oqv", "JUNIPER-MIB", '+' . $config['install_dir'] . "/mibs/junos"); if (!strstr($descr, "No") && !strstr($temperature, "No") && $descr != "" && $temperature != "0") { $descr = str_replace("\"", "", $descr); $descr = str_replace("temperature", "", $descr); $descr = str_replace("temperature", "", $descr); $descr = str_replace("sensor", "", $descr); $descr = trim($descr); discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $oid, 'junos', $descr, '1', '1', NULL, NULL, NULL, NULL, $temperature); } } } }
<?php echo 'IPv4 Addresses : '; $oids = trim(snmp_walk($device, 'ipAdEntIfIndex', '-Osq', 'IP-MIB')); $oids = str_replace('ipAdEntIfIndex.', '', $oids); foreach (explode("\n", $oids) as $data) { $data = trim($data); list($oid, $ifIndex) = explode(' ', $data); $mask = trim(snmp_get($device, "ipAdEntNetMask.{$oid}", '-Oqv', 'IP-MIB')); $addr = Net_IPv4::parseAddress("{$oid}/{$mask}"); $network = $addr->network . '/' . $addr->bitmask; $cidr = $addr->bitmask; if (dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifIndex` = ?', array($device['device_id'], $ifIndex)) != '0' && $oid != '0.0.0.0' && $oid != 'ipAdEntIfIndex') { $port_id = dbFetchCell('SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $ifIndex)); if (dbFetchCell('SELECT COUNT(*) FROM `ipv4_networks` WHERE `ipv4_network` = ?', array($network)) < '1') { dbInsert(array('ipv4_network' => $network), 'ipv4_networks'); // echo("Create Subnet $network\n"); echo 'S'; } $ipv4_network_id = dbFetchCell('SELECT `ipv4_network_id` FROM `ipv4_networks` WHERE `ipv4_network` = ?', array($network)); if (dbFetchCell('SELECT COUNT(*) FROM `ipv4_addresses` WHERE `ipv4_address` = ? AND `ipv4_prefixlen` = ? AND `port_id` = ?', array($oid, $cidr, $port_id)) == '0') { dbInsert(array('ipv4_address' => $oid, 'ipv4_prefixlen' => $cidr, 'ipv4_network_id' => $ipv4_network_id, 'port_id' => $port_id), 'ipv4_addresses'); // echo("Added $oid/$cidr to $port_id ( $hostname $ifIndex )\n $i_query\n"); echo '+'; } else { echo '.'; } $full_address = "{$oid}/{$cidr}|{$ifIndex}"; $valid_v4[$full_address] = 1; } else { echo '!';
<?php if ($config['enable_sla'] && $device['os_group'] == 'cisco') { $slas = snmp_walk($device, 'ciscoRttMonMIB.ciscoRttMonObjects.rttMonCtrl', '-Osq', '+CISCO-RTTMON-MIB'); $sla_table = array(); foreach (explode("\n", $slas) as $sla) { $key_val = explode(' ', $sla, 2); if (count($key_val) != 2) { $key_val[] = ''; } $key = $key_val[0]; $value = $key_val[1]; $prop_id = explode('.', $key); if (count($prop_id) != 2 || !ctype_digit($prop_id[1])) { continue; } $property = $prop_id[0]; $id = intval($prop_id[1]); $sla_table[$id][$property] = trim($value); } // var_dump($sla_table); // Get existing SLAs $existing_slas = dbFetchColumn('SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `deleted` = 0', array('device_id' => $device['device_id'])); foreach ($sla_table as $sla_nr => $sla_config) { $query_data = array('device_id' => $device['device_id'], 'sla_nr' => $sla_nr); $sla_id = dbFetchCell('SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `sla_nr` = :sla_nr', $query_data); $data = array('device_id' => $device['device_id'], 'sla_nr' => $sla_nr, 'owner' => $sla_config['rttMonCtrlAdminOwner'], 'tag' => $sla_config['rttMonCtrlAdminTag'], 'rtt_type' => $sla_config['rttMonCtrlAdminRttType'], 'status' => $sla_config['rttMonCtrlAdminStatus'] == 'active' ? 1 : 0, 'opstatus' => $sla_config['rttMonLatestRttOperSense'] == 'ok' ? 0 : 2, 'deleted' => 0); // Some fallbacks for when the tag is empty if (!$data['tag']) { switch ($data['rtt_type']) { case 'http':
// MIB-Dell-10892::temperatureProbechassisIndex.1.1 = INTEGER: 1 // MIB-Dell-10892::temperatureProbeIndex.1.1 = INTEGER: 1 // MIB-Dell-10892::temperatureProbeStateCapabilities.1.1 = INTEGER: 0 // MIB-Dell-10892::temperatureProbeStateSettings.1.1 = INTEGER: enabled(2) // MIB-Dell-10892::temperatureProbeStatus.1.1 = INTEGER: ok(3) // MIB-Dell-10892::temperatureProbeReading.1.1 = INTEGER: 320 // MIB-Dell-10892::temperatureProbeType.1.1 = INTEGER: temperatureProbeTypeIsAmbientESM(3) // MIB-Dell-10892::temperatureProbeLocationName.1.1 = STRING: "BMC Planar Temp" // MIB-Dell-10892::temperatureProbeUpperCriticalThreshold.1.1 = INTEGER: 530 // MIB-Dell-10892::temperatureProbeUpperNonCriticalThreshold.1.1 = INTEGER: 480 // MIB-Dell-10892::temperatureProbeLowerNonCriticalThreshold.1.1 = INTEGER: 70 // MIB-Dell-10892::temperatureProbeLowerCriticalThreshold.1.1 = INTEGER: 30 // MIB-Dell-10892::temperatureProbeProbeCapabilities.1.1 = INTEGER: 0 if (strstr($device['hardware'], 'Dell')) { // stuff partially copied from akcp sensor $oids = snmp_walk($device, 'temperatureProbeStatus', '-Osqn', 'MIB-Dell-10892'); d_echo($oids . "\n"); $oids = trim($oids); if ($oids) { echo 'Dell OMSA '; } foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $status) = explode(' ', $data, 2); d_echo('status : ' . $status . "\n"); if ($status == 'ok') { // 2 = normal, 0 = not connected $split_oid = explode('.', $oid); $temperature_id = $split_oid[count($split_oid) - 2] . '.' . $split_oid[count($split_oid) - 1]; $descr_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.8.{$temperature_id}";
$descr = 'Output'; if ($numPhase > 1) { $descr .= " Phase {$i}"; } $current = snmp_get($device, $freq_oid, '-Oqv'); if (!$current) { $freq_oid .= '.0'; $current = snmp_get($device, $freq_oid, '-Oqv'); } $current /= 10; $type = 'mge-ups'; $divisor = 10; $index = $i; discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.6.1', '-OsqnU')); d_echo($oids . "\n"); $numPhase = count(explode("\n", $oids)); for ($i = 1; $i <= $numPhase; $i++) { $freq_oid = ".1.3.6.1.4.1.705.1.6.2.1.3.{$i}"; $descr = 'Input'; if ($numPhase > 1) { $descr .= " Phase {$i}"; } $current = snmp_get($device, $freq_oid, '-Oqv'); if (!$current) { $freq_oid .= '.0'; $current = snmp_get($device, $freq_oid, '-Oqv'); } $current /= 10; $type = 'mge-ups';
<?php unset($mac_table); echo 'ARP Table : '; $ipNetToMedia_data = snmp_walk($device, 'ipNetToMediaPhysAddress', '-Oq', 'IP-MIB'); $ipNetToMedia_data = str_replace('ipNetToMediaPhysAddress.', '', trim($ipNetToMedia_data)); $ipNetToMedia_data = str_replace('IP-MIB::', '', trim($ipNetToMedia_data)); foreach (explode("\n", $ipNetToMedia_data) as $data) { list($oid, $mac) = explode(' ', $data); list($if, $first, $second, $third, $fourth) = explode('.', $oid); $ip = $first . '.' . $second . '.' . $third . '.' . $fourth; if ($ip != '...') { $interface = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $if)); list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(':', $mac); $m_a = zeropad($m_a); $m_b = zeropad($m_b); $m_c = zeropad($m_c); $m_d = zeropad($m_d); $m_e = zeropad($m_e); $m_f = zeropad($m_f); $md_a = hexdec($m_a); $md_b = hexdec($m_b); $md_c = hexdec($m_c); $md_d = hexdec($m_d); $md_e = hexdec($m_e); $md_f = hexdec($m_f); $mac = "{$m_a}:{$m_b}:{$m_c}:{$m_d}:{$m_e}:{$m_f}"; $mac_table[$if][$mac]['ip'] = $ip; $mac_table[$if][$mac]['ciscomac'] = "{$m_a}{$m_b}.{$m_c}{$m_d}.{$m_e}{$m_f}"; $clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f; $mac_table[$if][$mac]['cleanmac'] = $clean_mac;
// rPDU2OutletMeteredConfigNearOverloadCurrentThreshold $name_oid = '1.3.6.1.4.1.318.1.1.26.9.4.3.1.3.' . $index; // rPDU2OutletMeteredStatusName $voltage = snmp_get($device, $voltage_oid, '-Oqv', ''); $current = snmp_get($device, $current_oid, '-Oqv', '') / $precision; $limit = snmp_get($device, $limit_oid, '-Oqv', '') / $voltage; $lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', '') / $voltage; $warnlimit = snmp_get($device, $warnlimit_oid, '-Oqv', '') / $voltage; $descr = 'Outlet ' . $index . ' - ' . snmp_get($device, $name_oid, '-Oqv', ''); discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, null, $warnlimit, $limit, $current); } } } unset($oids); // ATS $oids = snmp_walk($device, 'atsConfigPhaseTableIndex', '-OsqnU', 'PowerNet-MIB'); if ($oids) { $type = 'apc'; d_echo($oids . "\n"); $oids = trim($oids); if ($oids) { echo 'APC PowerNet-MIB ATS '; } $current_oid = '1.3.6.1.4.1.318.1.1.8.5.4.3.1.4.1.1.1'; // atsOutputCurrent $limit_oid = '1.3.6.1.4.1.318.1.1.8.4.16.1.5.1'; // atsConfigPhaseOverLoadThreshold $lowlimit_oid = '1.3.6.1.4.1.318.1.1.8.4.16.1.3.1'; // atsConfigPhaseLowLoadThreshold $warnlimit_oid = '1.3.6.1.4.1.318.1.1.8.4.16.1.4.1'; // atsConfigPhaseNearOverLoadThreshold
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage discovery * @author Adam Armstrong <*****@*****.**> * @copyright (C) 2006 - 2012 Adam Armstrong */ if (strstr($device['os'], 'drac')) { $oids = snmp_walk($device, 'temperatureProbeStatus', '-Osqn', 'IDRAC-MIB-SMIv2'); if ($debug) { echo $oids . "\n"; } $oids = trim($oids); if ($oids) { echo 'Dell iDRAC'; } foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $status) = explode(' ', $data, 2); if ($debug) { echo 'status : ' . $status . "\n"; } if ($status == 'ok') { $split_oid = explode('.', $oid); $temperature_id = $split_oid[count($split_oid) - 2] . '.' . $split_oid[count($split_oid) - 1];
list($ip, $value) = explode(" ", $ipRouteProto); $tableRoute[$ip]['ipRouteProto'] = $value; } /* ///////////ipRouteAge////////////////////// $oid = '.1.3.6.1.2.1.4.21.1.10'; $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); $resultHelp = str_replace("$oid.", "", $resultHelp); foreach (explode("\n", $resultHelp) as $ipRouteAge) { list($ip,$value)=explode(" ",$ipRouteAge); $tableRoute[$ip]['ipRouteAge']=$value; } */ ///////////ipRouteMask////////////////////// $oid = '.1.3.6.1.2.1.4.21.1.11'; $resultHelp = snmp_walk($device, $oid, "-Osqn -Ln", $mib, NULL); $resultHelp = trim($resultHelp); $resultHelp = str_replace("{$oid}.", "", $resultHelp); foreach (explode("\n", $resultHelp) as $ipRouteMask) { list($ip, $value) = explode(" ", $ipRouteMask); $tableRoute[$ip]['ipRouteMask'] = $value; } if ($debug) { echo 'Table routage'; var_dump($tableRoute); } foreach ($tableRoute as $ipRoute) { if (empty($ipRoute['ipRouteDest']) || $ipRoute['ipRouteDest'] == '') { continue; } $oldRouteRow = dbFetchRow('select * from route where device_id = ? AND ipRouteDest = ? AND context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name']));
<?php /* * LibreNMS module for Brocade NOS fanspeed sensor * * Copyright (c) 2016 Maxence POULAIN <*****@*****.**> * * 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'] == "nos") { $oids = snmp_walk($device, '1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', '-Osqn'); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data and $data[37] == "2") { $value_oid = ".1.3.6.1.4.1.1588.2.1.1.1.1.22.1.4." . $data[35]; $descr_oid = ".1.3.6.1.4.1.1588.2.1.1.1.1.22.1.5." . $data[35]; $value = snmp_get($device, $value_oid, '-Oqv'); $descr = snmp_get($device, $descr_oid, '-Oqv'); if (!strstr($descr, 'No') and !strstr($value, 'No')) { $descr = str_replace('"', '', $descr); $descr = trim($descr); discover_sensor($valid['sensor'], 'temperature', $device, $value_oid, $data[35], 'nos', $descr, '1', '1', null, null, '80', '100', $value); } } } }
<?php global $debug; if ($config['enable_printers']) { $valid_toner = array(); echo "Toner : "; if ($device['os_group'] == 'printer') { $oids = trim(snmp_walk($device, "1.3.6.1.2.1.43.11.1.1.3", "-OsqnU")); /* Not parsed below, so let's not walk this for now*/ /* if (!$oids) { $oids = trim(snmp_walk($device, "1.3.6.1.2.1.43.12.1.1.2.1", "-OsqnU")); } */ if ($debug) { echo $oids . "\n"; } if ($oids) { echo "Jetdirect "; } foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $role) = explode(" ", $data); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; if (is_numeric($role)) { $toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.1.{$index}"; $descr_oid = ".1.3.6.1.2.1.43.11.1.1.6.1.{$index}"; $capacity_oid = ".1.3.6.1.2.1.43.11.1.1.8.1.{$index}";
$data = trim($data); if ($data != '') { list($oid) = explode(' ', $data); $temperature_oid = ".1.3.6.1.4.1.6321.1.2.3.2.98.2.3.1.2.{$oid}"; $descr_oid = ".1.3.6.1.4.1.6321.1.2.3.2.98.2.3.1.6.{$oid}"; $descr = snmp_get($device, $descr_oid, '-Oqv', ''); $temperature = snmp_get($device, $temperature_oid, '-Oqv', ''); $descr = str_replace('"', '', $descr); $current = $temperature; discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $oid, 'calix', $descr, '1', '1', null, null, null, null, $current); } } } if (strpos($device['sysObjectID'], 'enterprises.6321.1.2.3.1') !== false) { // E5-110 $oids = snmp_walk($device, 'iesSysTempCurValue', '-Osqn', 'E5-110-IESCOMMON-MIB', 'calix'); $oids = trim($oids); $oids = str_replace('.1.3.6.1.4.1.6321.1.2.3.1.98.2.3.1.2.', '', $oids); foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data != '') { list($oid) = explode(' ', $data); $temperature_oid = ".1.3.6.1.4.1.6321.1.2.3.1.98.2.3.1.2.{$oid}"; $descr_oid = ".1.3.6.1.4.1.6321.1.2.3.1.98.2.3.1.6.{$oid}"; $descr = snmp_get($device, $descr_oid, '-Oqv', ''); $temperature = snmp_get($device, $temperature_oid, '-Oqv', ''); $descr = str_replace('"', '', $descr); $current = $temperature; discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $oid, 'calix', $descr, '1', '1', null, null, null, null, $current); } }
echo 'APC In '; } $divisor = 1; $type = 'apc'; foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $current) = explode(' ', $data, 2); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; $oid = '1.3.6.1.4.1.318.1.1.8.5.3.2.1.4.' . $index; $descr = 'Input Feed ' . chr(64 + $index); discover_sensor($valid['sensor'], 'frequency', $device, $oid, "3.2.1.4.{$index}", $type, $descr, $divisor, '1', null, null, null, null, $current); } } $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.8.5.4.2.1.4', '-OsqnU', ''); d_echo($oids . "\n"); if ($oids) { echo ' APC Out '; } $divisor = 1; $type = 'apc'; foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $current) = explode(' ', $data, 2); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 3]; $oid = '1.3.6.1.4.1.318.1.1.8.5.4.2.1.4.' . $index; $descr = 'Output Feed'; if (count(explode("\n", $oids)) > 1) {
$peer_ip_snmp = preg_replace('/:/', ' ', $peer_ip); $peer_ip = preg_replace('/(\\S+\\s+\\S+)\\s/', '$1:', $peer_ip_snmp); $peer_ip = str_replace('"', '', str_replace(' ', '', $peer_ip)); } if ($peer && $peer_ip != '0.0.0.0') { if ($debug) { echo "Found peer {$peer_ip} (AS{$peer_as})\n"; } $peerlist[] = array('ip' => $peer_ip, 'as' => $peer_as, 'ver' => $ver); } } if ($device['os'] == 'junos') { // Juniper BGP4-V2 MIB // FIXME: needs a big cleanup! also see below. // FIXME: is .0.ipv6 the only possible value here? $result = snmp_walk($device, 'jnxBgpM2PeerRemoteAs.0.ipv6', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'] . '/mibs/junos'); $peers = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.', '', $result)); foreach (explode("\n", $peers) as $peer) { list($peer_ip_snmp, $peer_as) = explode(' ', $peer); // Magic! Basically, takes SNMP form and finds peer IPs from the walk OIDs. $peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), count(explode('.', $peer_ip_snmp)) - 16)))); if ($peer) { if ($debug) { echo "Found peer {$peer_ip} (AS{$peer_as})\n"; } $peerlist[] = array('ip' => $peer_ip, 'as' => $peer_as); } } } } else { echo 'No BGP on host';
<?php if ($device['os'] == "cometsystem-p85xx") { $regexp = '/ \\.1\\.3\\.6\\.1\\.4\\.1\\.22626\\.1\\.5\\.2\\. (?P<id>\\d+) \\. (?: 1\\.0 (?P<name>.*)| 3\\.0 (?P<temp_intval>.*)| 5\\.0 (?P<limit_high>.*)| 6\\.0 (?P<limit_low>.*)| ) /x'; $oids = snmp_walk($device, ".1.3.6.1.4.1.22626.1.5.2", "-OsqnU", ""); #if ($debug) { echo($oids."\n"); } if ($oids) { $out = array(); foreach (explode("\n", $oids) as $line) { preg_match($regexp, $line, $match); if ($match['name']) { $out[$match['id']]['name'] = $match['name']; } if ($match['temp_intval']) { $out[$match['id']]['temp_intval'] = $match['temp_intval']; } if ($match['limit_high']) { $out[$match['id']]['limit_high'] = $match['limit_high']; } if ($match['limit_low']) { $out[$match['id']]['limit_low'] = $match['limit_low'];
<?php // Supermicro Fanspeeds if ($device['os'] == 'linux') { $oids = snmp_walk($device, '1.3.6.1.4.1.10876.2.1.1.1.1.3', '-OsqnU', 'SUPERMICRO-HEALTH-MIB'); if ($debug) { echo $oids . "\n"; } $oids = trim($oids); if ($oids) { echo 'Supermicro '; } foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $kind) = explode(' ', $data); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; if ($kind == 0) { $fan_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.4.{$index}"; $descr_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.2.{$index}"; $limit_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.6.{$index}"; $divisor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.9.{$index}"; $monitor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.10.{$index}"; $descr = snmp_get($device, $descr_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); $current = snmp_get($device, $fan_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); $low_limit = snmp_get($device, $limit_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); // $divisor = snmp_get($device, $divisor_oid, "-Oqv", "SUPERMICRO-HEALTH-MIB"); // ^ This returns an incorrect precision. At least using the raw value... I think. -TL $divisor = '1'; $monitor = snmp_get($device, $monitor_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB');
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage discovery * @copyright (C) 2006-2014 Adam Armstrong * */ // This could do with a decent rewrite using SNMP multi functions, instead of trim() and str_replace() voodoo. echo " FOUNDRY-SN-AGENT-MIB "; $oids = trim(snmp_walk($device, "snAgentTempSensorDescr", "-Osqn", "FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB", mib_dirs('foundry'))); $oids = str_replace(".1.3.6.1.4.1.1991.1.1.2.13.1.1.3.", "", $oids); foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data != "") { list($oid) = explode(" ", $data); $temperature_oid = ".1.3.6.1.4.1.1991.1.1.2.13.1.1.4.{$oid}"; $descr_oid = ".1.3.6.1.4.1.1991.1.1.2.13.1.1.3.{$oid}"; $descr = snmp_get($device, $descr_oid, "-Oqv", ""); $temperature = snmp_get($device, $temperature_oid, "-Oqv", ""); if (!strstr($descr, "No") && !strstr($temperature, "No") && $descr != "" && $temperature != "0") { $descr = str_replace("\"", "", $descr); $descr = str_replace("temperature", "", $descr); $descr = str_replace("temperature", "", $descr); $descr = str_replace("sensor", "Sensor", $descr); $descr = str_replace("Line module", "Slot", $descr); $descr = str_replace("Switch Fabric module", "Fabric", $descr);
<?php $name = 'dhcp-stats'; $app_id = $app['app_id']; $options = '-O qv'; $mib = 'NET-SNMP-EXTEND-MIB'; $oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.100.104.99.112.115.116.97.116.115'; $dhcpstats = snmp_walk($device, $oid, $options, $mib); list($dhcp_total, $dhcp_active, $dhcp_expired, $dhcp_released, $dhcp_abandoned, $dhcp_reset, $dhcp_bootp, $dhcp_backup, $dhcp_free) = explode("\n", $dhcpstats); $rrd_name = array('app', $name, $app_id); $rrd_def = array('DS:dhcp_total:GAUGE:600:0:U', 'DS:dhcp_active:GAUGE:600:0:U', 'DS:dhcp_expired:GAUGE:600:0:U', 'DS:dhcp_released:GAUGE:600:0:U', 'DS:dhcp_abandoned:GAUGE:600:0:U', 'DS:dhcp_reset:GAUGE:600:0:U', 'DS:dhcp_bootp:GAUGE:600:0:U', 'DS:dhcp_backup:GAUGE:600:0:U', 'DS:dhcp_free:GAUGE:600:0:U'); $fields = array('dhcp_total' => $dhcp_total, 'dhcp_active' => $dhcp_active, 'dhcp_expired' => $dhcp_expired, 'dhcp_released' => $dhcp_released, 'dhcp_abandoned' => $dhcp_abandoned, 'dhcp_reset' => $dhcp_reset, 'dhcp_bootp' => $dhcp_bootp, 'dhcp_backup' => $dhcp_backup, 'dhcp_free' => $dhcp_free); $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); data_update($device, 'app', $tags, $fields);
if ($config['enable_bgp'] && is_device_mib($device, 'BGP4-MIB')) { // Get Local ASN $bgpLocalAs = snmp_get($device, 'bgpLocalAs.0', '-OUQvn', 'BGP4-MIB'); $vendor_oids = array('BGP4-V2-MIB-JUNIPER' => array('vendor_use_index' => array('jnxBgpM2PeerRemoteAddr' => 1, 'jnxBgpM2PeerRemoteAddrType' => 1, 'jnxBgpM2PeerLocalAddr' => 1), 'vendor_PeerTable' => 'jnxBgpM2PeerTable', 'vendor_PeerAdminStatus' => 'jnxBgpM2PeerStatus', 'vendor_PeerRemoteAs' => 'jnxBgpM2PeerRemoteAs', 'vendor_PeerRemoteAddr' => 'jnxBgpM2PeerRemoteAddr', 'vendor_PeerLocalAddr' => 'jnxBgpM2PeerLocalAddr', 'vendor_PeerIdentifier' => 'jnxBgpM2PeerIdentifier', 'vendor_PeerIndex' => 'jnxBgpM2PeerIndex', 'vendor_PeerRemoteAddrType' => 'jnxBgpM2PeerRemoteAddrType', 'vendor_PrefixCountersSafi' => 'jnxBgpM2PrefixCountersSafi'), 'FORCE10-BGP4-V2-MIB' => array('vendor_PeerTable' => 'f10BgpM2PeerTable', 'vendor_PeerAdminStatus' => 'f10BgpM2PeerStatus', 'vendor_PeerRemoteAs' => 'f10BgpM2PeerRemoteAs', 'vendor_PeerRemoteAddr' => 'f10BgpM2PeerRemoteAddr', 'vendor_PeerLocalAddr' => 'f10BgpM2PeerLocalAddr', 'vendor_PeerIdentifier' => 'f10BgpM2PeerIdentifier', 'vendor_PeerIndex' => 'f10BgpM2PeerIndex', 'vendor_PeerRemoteAddrType' => 'f10BgpM2PeerRemoteAddrType', 'vendor_PrefixCountersSafi' => 'f10BgpM2PrefixCountersSafi'), 'ARISTA-BGP4V2-MIB' => array('vendor_use_index' => array('aristaBgp4V2PeerRemoteAddr' => 1, 'aristaBgp4V2PeerRemoteAddrType' => 1), 'vendor_PeerTable' => 'aristaBgp4V2PeerTable', 'vendor_PeerAdminStatus' => 'aristaBgp4V2PeerAdminStatus', 'vendor_PeerRemoteAs' => 'aristaBgp4V2PeerRemoteAs', 'vendor_PeerRemoteAddr' => 'aristaBgp4V2PeerRemoteAddr', 'vendor_PeerLocalAddr' => 'aristaBgp4V2PeerLocalAddr', 'vendor_PeerIdentifier' => 'aristaBgp4V2PeerRemoteIdentifier', 'vendor_PeerIndex' => '', 'vendor_PeerRemoteAddrType' => 'aristaBgp4V2PeerRemoteAddrType', 'vendor_PrefixCountersSafi' => 'aristaBgp4V2PrefixInPrefixes')); $vendor_mib = FALSE; foreach ($vendor_oids as $v_mib => $v_array) { if (is_device_mib($device, $v_mib)) { $vendor_mib = $v_mib; // Set to current vendor mib //echo(" $v_mib "); foreach ($v_array as $v => $val) { ${$v} = $val; } if ($v_mib === 'BGP4-V2-MIB-JUNIPER' && $bgpLocalAs === '0') { // On JunOS BGP4-MIB::bgpLocalAs.0 is always '0'. $v_bgpLocalAs = trim(snmp_walk($device, 'jnxBgpM2PeerLocalAs', '-OUQvn', 'BGP4-V2-MIB-JUNIPER')); list($bgpLocalAs) = explode("\n", $v_bgpLocalAs); } break; } } // Some Old IOS-XR (ie 4.3.2) also return BGP4-MIB::bgpLocalAs.0 as '0'. if ($vendor_mib === FALSE && $bgpLocalAs === '0' && is_device_mib($device, 'CISCO-BGP4-MIB')) { $v_bgpLocalAs = snmp_get($device, 'cbgpLocalAs.0', '-OUQvn', 'CISCO-BGP4-MIB'); if (is_numeric($v_bgpLocalAs)) { $bgpLocalAs = $v_bgpLocalAs; } } // Discover BGP peers /// NOTE. PeerIdentifier != PeerRemoteAddr if (is_numeric($bgpLocalAs) && $bgpLocalAs != '0') {
echo "APC In "; } $divisor = 1; $type = "apc"; foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $current) = explode(" ", $data, 2); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; $oid = "1.3.6.1.4.1.318.1.1.8.5.3.2.1.4." . $index; $descr = "Input Feed " . chr(64 + $index); discover_sensor($valid['sensor'], 'frequency', $device, $oid, "3.2.1.4.{$index}", $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); } } $oids = snmp_walk($device, "1.3.6.1.4.1.318.1.1.8.5.4.2.1.4", "-OsqnU", ""); if ($debug) { echo $oids . "\n"; } if ($oids) { echo " APC Out "; } $divisor = 1; $type = "apc"; foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $current) = explode(" ", $data, 2); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 3]; $oid = "1.3.6.1.4.1.318.1.1.8.5.4.2.1.4." . $index;
$oids = snmp_walk($device, "isxModularDistModuleBreakerCurrent", "-OsqnU", "PowerNet-MIB"); if ($oids) { echo " Modular APC Out "; foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $value) = explode(' ', $data); $split_oid = explode('.', $oid); $phase = $split_oid[count($split_oid) - 1]; $breaker = $split_oid[count($split_oid) - 2]; $index = str_pad($breaker, 2, "0", STR_PAD_LEFT) . "-" . $phase; $descr = "Breaker {$breaker} Phase {$phase}"; discover_sensor($valid['sensor'], 'current', $device, $oid, $index, 'apc', $descr, $scale, $value); } } $oids = snmp_walk($device, "isxModularDistSysCurrentAmps", "-OsqnU", "PowerNet-MIB"); foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $value) = explode(' ', $data); $split_oid = explode('.', $oid); $phase = $split_oid[count($split_oid) - 1]; $index = ".{$phase}"; $descr = "Phase {$phase} overall"; discover_sensor($valid['sensor'], 'current', $device, $oid, $index, 'apc', $descr, $scale, $value); } } } #### ENVIRONMENTAL ################################################################################### echo ' '; $cache['apc'] = array();
/** * SNMPWalk_array_num - performs a numeric SNMPWalk and returns an array containing $count indexes * One Index: * From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0 * To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27.18']['655360'] = 0 * Two Indexes: * From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0 * To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27']['18']['655360'] = 0 * And so on... * Think snmpwalk_cache_*_oid but for numeric data. * * Why is this useful? * Some SNMP data contains a single index (eg. ifIndex in IF-MIB) and some is dual indexed * (eg. PolicyIndex/ObjectsIndex in CISCO-CLASS-BASED-QOS-MIB). * The resulting array allows us to easily access the top level index we want and iterate over the data from there. * * @param $device * @param $OID * @param int $indexes * @internal param $string * @return array */ function snmpwalk_array_num($device, $oid, $indexes = 1) { $array = array(); $string = snmp_walk($device, $oid, '-Osqn'); if ($string === false) { // False means: No Such Object. return false; } if ($string == "") { // Empty means SNMP timeout or some such. return null; } // Let's turn the string into something we can work with. foreach (explode("\n", $string) as $line) { if ($line[0] == '.') { // strip the leading . if it exists. $line = substr($line, 1); } list($key, $value) = explode(' ', $line, 2); $prop_id = explode('.', $key); $value = trim($value); // if we have requested more levels that exist, set to the max. if ($indexes > count($prop_id)) { $indexes = count($prop_id) - 1; } for ($i = 0; $i < $indexes; $i++) { // Pop the index off. $index = array_pop($prop_id); $value = array($index => $value); } // Rebuild our key $key = implode('.', $prop_id); // Add the entry to the master array $array = array_replace_recursive($array, array($key => $value)); } return $array; }
<?php $valid_toner = array(); if ($device['os_group'] == 'printer') { $oids = trim(snmp_walk($device, 'SNMPv2-SMI::mib-2.43.12.1.1.2.1 ', '-OsqnU')); if (!$oids) { $oids = trim(snmp_walk($device, 'SNMPv2-SMI::mib-2.43.11.1.1.2.1 ', '-OsqnU')); } d_echo($oids . "\n"); if ($oids) { echo 'Jetdirect '; } foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $role) = explode(' ', $data); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; if (is_numeric($role)) { //ricoh using private oids to expose toner levels if ($os == 'ricoh') { $toner_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.{$index}"; $descr_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.3.{$index}"; } else { $toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.1.{$index}"; $descr_oid = ".1.3.6.1.2.1.43.11.1.1.6.1.{$index}"; $capacity_oid = ".1.3.6.1.2.1.43.11.1.1.8.1.{$index}"; } $descr = trim(str_replace("\n", '', str_replace('"', '', snmp_get($device, $descr_oid, '-Oqv')))); if ($descr != '') { $current = snmp_get($device, $toner_oid, '-Oqv');
function poll_sensor($device, $class, $unit) { global $config, $memcache, $agent_sensors; foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ?', array($class, $device['device_id'])) as $sensor) { echo 'Checking (' . $sensor['poller_type'] . ") {$class} " . $sensor['sensor_descr'] . '... '; $sensor_value = ''; if ($sensor['poller_type'] == 'snmp') { if ($device['os'] == 'siklu') { $mib = ':RADIO-BRIDGE-MIB'; } else { $mib = ''; } if ($class == 'temperature') { if ($device['os'] == 'netapp') { include 'includes/polling/temperatures/netapp.inc.php'; } else { // Try 5 times to get a valid temp reading for ($i = 0; $i < 5; $i++) { d_echo("Attempt {$i} "); $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB{$mib}"))); preg_match('/[\\d\\.]+/', $sensor_value, $temp_response); if (!empty($temp_response[0])) { $sensor_value = $temp_response[0]; } if (is_numeric($sensor_value) && $sensor_value != 9999) { break; // TME sometimes sends 999.9 when it is right in the middle of an update; } sleep(1); // end if } } //end if } else { if ($class == 'state') { $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-Oevq', 'SNMPv2-MIB'))); } else { if ($class == 'dbm') { $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB{$mib}"))); //iosxr does not expose dbm values through SNMP so we convert Watts to dbm to have a nice graph to show if ($device['os'] == "iosxr") { $sensor_value = round(10 * log10($sensor_value / 1000), 3); } } else { if ($sensor['sensor_type'] == 'apc') { $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB:PowerNet-MIB{$mib}"))); } else { $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB{$mib}"))); } } } } //end if unset($mib); } else { if ($sensor['poller_type'] == 'agent') { if (isset($agent_sensors)) { $sensor_value = $agent_sensors[$class][$sensor['sensor_type']][$sensor['sensor_index']]['current']; } else { echo "no agent data!\n"; continue; } } else { if ($sensor['poller_type'] == 'ipmi') { echo " already polled.\n"; // ipmi should probably move here from the ipmi poller file (FIXME) continue; } else { echo "unknown poller type!\n"; continue; } } } //end if if ($sensor_value == -32768) { echo 'Invalid (-32768) '; $sensor_value = 0; } if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; } if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; } $rrd_file = get_sensor_rrd($device, $sensor); if (!is_file($rrd_file)) { rrdtool_create($rrd_file, '--step 300 DS:sensor:GAUGE:600:-20000:20000 ' . $config['rrd_rra']); } echo "{$sensor_value} {$unit}\n"; $fields = array('sensor' => $sensor_value); rrdtool_update($rrd_file, $fields); // FIXME also warn when crossing WARN level!! if ($sensor['sensor_limit_low'] != '' && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $sensor_value <= $sensor['sensor_limit_low'] && $sensor['sensor_alert'] == 1) { echo 'Alerting for ' . $device['hostname'] . ' ' . $sensor['sensor_descr'] . "\n"; log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . ' under threshold: ' . $sensor_value . " {$unit} (< " . $sensor['sensor_limit_low'] . " {$unit})", $device, $class, $sensor['sensor_id']); } else { if ($sensor['sensor_limit'] != '' && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit'] && $sensor['sensor_alert'] == 1) { echo 'Alerting for ' . $device['hostname'] . ' ' . $sensor['sensor_descr'] . "\n"; log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . ' above threshold: ' . $sensor_value . " {$unit} (> " . $sensor['sensor_limit'] . " {$unit})", $device, $class, $sensor['sensor_id']); } } dbUpdate(array('sensor_current' => $sensor_value, 'lastupdate' => array('NOW()')), 'sensors', '`sensor_class` = ? AND `sensor_id` = ?', array($class, $sensor['sensor_id'])); } //end foreach }
*/ $ceragon_type = $poll_device['sysObjectID']; $hardware = rewrite_ceraos_hardware($ceragon_type, $device); // function in ./includes/rewrites.php if (stristr('IP10', $hardware)) { $serial = snmp_get($device, 'genEquipUnitIDUSerialNumber.0', '-Oqv', 'MWRM-UNIT-MIB'); } else { $serial = snmp_get($device, 'genEquipInventorySerialNumber.127', '-Oqv', 'MWRM-UNIT-MIB'); } $multi_get_array = snmp_get_multi($device, 'genEquipMngSwIDUVersionsRunningVersion.1 genEquipUnitLatitude.0 genEquipUnitLongitude.0', '-OQU', 'MWRM-RADIO-MIB'); d_echo($multi_get_array); $version = $multi_get_array[1]['MWRM-UNIT-MIB::genEquipMngSwIDUVersionsRunningVersion']; $latitude = $multi_get_array[0]['MWRM-UNIT-MIB::genEquipUnitLatitude']; $longitude = $multi_get_array[0]['MWRM-UNIT-MIB::genEquipUnitLongitude']; $ifIndex_array = array(); $ifIndex_array = explode("\n", snmp_walk($device, 'ifIndex', '-Oqv', 'IF-MIB')); d_echo($ifIndex_array); $snmp_get_oids = ""; foreach ($ifIndex_array as $ifIndex) { $snmp_get_oids .= "ifDescr.{$ifIndex} ifName.{$ifIndex} "; } $num_radios = 0; $ifDescr_array = array(); $ifDescr_array = snmp_get_multi($device, $snmp_get_oids, '-OQU', 'IF-MIB'); d_echo($ifDescr_array); foreach ($ifIndex_array as $ifIndex) { d_echo("\$ifDescr_array[{$ifIndex}]['IF-MIB::ifDescr'] = " . $ifDescr_array[$ifIndex]['IF-MIB::ifDescr'] . "\n"); if (stristr($ifDescr_array[$ifIndex]['IF-MIB::ifDescr'], "Radio")) { $num_radios = $num_radios + 1; } }
<?php // RFC1628 UPS if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modules_compat']['rfc1628'][$device['os']]) { echo 'RFC1628 '; $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.3.2.0', '-OsqnU')); d_echo($oids . "\n"); list($unused, $numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { $freq_oid = "1.3.6.1.2.1.33.1.3.3.1.2.{$i}"; $descr = 'Input'; if ($numPhase > 1) { $descr .= " Phase {$i}"; } $current = snmp_get($device, $freq_oid, '-Oqv') / 10; $type = 'rfc1628'; $divisor = 10; if ($device['os'] == 'huaweiups') { $divisor = 100; } $index = '3.2.0.' . $i; discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } $freq_oid = '1.3.6.1.2.1.33.1.4.2.0'; $descr = 'Output'; $current = snmp_get($device, $freq_oid, '-Oqv') / 10; $type = 'rfc1628'; $divisor = 10; if ($device['os'] == 'huaweiups') { $divisor = 100; }
<?php if ($device['os'] == "drac") { $oids = snmp_walk($device, "powerSupplyIndex.1", "-OsqnU", "IDRAC-MIB-SMIv2"); d_echo($oids . "\n"); $oids = trim($oids); if ($oids) { echo "Dell iDRAC"; } foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $kind) = explode(" ", $data); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; $voltage_oid = ".1.3.6.1.4.1.674.10892.5.4.600.12.1.16.1.{$index}"; $descr_oid = "powerSupplyLocationName.1.{$index}"; $limit_oid = "powerSupplyMaximumInputVoltage.1.{$index}"; $descr = trim(snmp_get($device, $descr_oid, "-Oqv", "IDRAC-MIB-SMIv2"), '"'); $descr = preg_replace("/(Status)/", "", $descr); $current = snmp_get($device, $voltage_oid, "-Oqv", "IDRAC-MIB-SMIv2"); $high_limit = snmp_get($device, $limit_oid, "-Oqv", "IDRAC-MIB-SMIv2"); $divisor = "1"; discover_sensor($valid['sensor'], 'voltage', $device, $voltage_oid, $index, 'drac', $descr, $divisor, '1', 0, null, null, $high_limit, $current); } } }
$rds = str_replace(".1.3.6.1.3.118.1.2.2.1.3.", "", $rds); $descrs_oid = ".1.3.6.1.3.118.1.2.2.1.2"; $ports_oid = ".1.3.6.1.3.118.1.2.1.1.2"; } else { $vpnmib = "MPLS-L3VPN-STD-MIB"; $rds = str_replace(".1.3.6.1.2.1.10.166.11.1.2.2.1.4.", "", $rds); $descrs_oid = ".1.3.6.1.2.1.10.166.11.1.2.2.1.3"; $ports_oid = ".1.3.6.1.2.1.10.166.11.1.2.1.1.2"; } if ($debug) { echo "\n[DEBUG]\nUsing {$vpnmib}\n[/DEBUG]\n"; echo "\n[DEBUG OIDS]\n{$rds}\n[/DEBUG]\n"; } $rds = trim($rds); $descrs = snmp_walk($device, $descrs_oid, "-Osqn", $vpnmib, NULL); $ports = snmp_walk($device, $ports_oid, "-Osqn", $vpnmib, NULL); $descrs = trim(str_replace("{$descrs_oid}.", "", $descrs)); $ports = trim(str_replace("{$ports_oid}.", "", $ports)); $descr_table = array(); $port_table = array(); foreach (explode("\n", $descrs) as $descr) { $t = explode(" ", $descr, 2); $descr_table[$t[0]] = $t[1]; } foreach (explode("\n", $ports) as $port) { $t = explode(" ", $port); $dotpos = strrpos($t[0], "."); $vrf_oid = substr($t[0], 0, $dotpos); $port_id = substr($t[0], $dotpos + 1); if (empty($port_table[$vrf_oid])) { $port_table[$vrf_oid][0] = $port_id;
if ($oids) { echo "Areca Controller "; } $precision = 1; foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $descr) = explode(" ", $data, 2); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; $oid = "1.3.6.1.4.1.18928.1.2.2.1.10.1.3." . $index; $current = snmp_get($device, $oid, "-Oqv", ""); discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, trim($descr, '"'), 1, 1, NULL, NULL, NULL, NULL, $current); } } $oids = snmp_walk($device, "1.3.6.1.4.1.18928.1.2.2.1.8.1.2", "-OsqnU", ""); if ($debug) { echo $oids . "\n"; } if ($oids) { echo "Areca "; } foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $descr) = explode(" ", $data, 2); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; $oid = "1.3.6.1.4.1.18928.1.2.2.1.8.1.3." . $index; $current = snmp_get($device, $oid, "-Oqv", ""); if (trim($descr, '"') == 'Battery Status') {