当前位置: 首页>>代码示例>>PHP>>正文


PHP snmp_walk函数代码示例

本文整理汇总了PHP中snmp_walk函数的典型用法代码示例。如果您正苦于以下问题:PHP snmp_walk函数的具体用法?PHP snmp_walk怎么用?PHP snmp_walk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了snmp_walk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: snmp_walk

<?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);
        }
    }
}
开发者ID:rasssta,项目名称:librenms,代码行数:25,代码来源:mikrotik.inc.php

示例2: snmp_walk

<?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);
            }
        }
    }
}
开发者ID:REAP720801,项目名称:librenms,代码行数:26,代码来源:junos.inc.php

示例3: trim

<?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 '!';
开发者ID:samyscoub,项目名称:librenms,代码行数:31,代码来源:ipv4-addresses.inc.php

示例4: snmp_walk

<?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':
开发者ID:Tatermen,项目名称:librenms,代码行数:31,代码来源:cisco-sla.inc.php

示例5: snmp_walk

// 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}";
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:dell.inc.php

示例6: snmp_get

     $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';
开发者ID:sfromm,项目名称:librenms,代码行数:31,代码来源:mgeups.inc.php

示例7: unset

<?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;
开发者ID:samyscoub,项目名称:librenms,代码行数:31,代码来源:arp-table.inc.php

示例8: snmp_get

             // 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
开发者ID:samyscoub,项目名称:librenms,代码行数:31,代码来源:apc.inc.php

示例9: snmp_walk

<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @author     Adam Armstrong <adama@memetic.org>
 * @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];
开发者ID:rasssta,项目名称:librenms,代码行数:31,代码来源:drac.inc.php

示例10: list

     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']));
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:route.inc.php

示例11: snmp_walk

<?php

/*
 * LibreNMS module for Brocade NOS fanspeed sensor
 *
 * Copyright (c) 2016 Maxence POULAIN <maxence.poulain@bsonetwork.com>
 *
 * 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);
            }
        }
    }
}
开发者ID:Tatermen,项目名称:librenms,代码行数:31,代码来源:nos.inc.php

示例12: array

<?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}";
开发者ID:RomanBogachev,项目名称:observium,代码行数:31,代码来源:toner.inc.php

示例13: trim

         $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);
         }
     }
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:calix.inc.php

示例14: foreach

     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) {
开发者ID:samyscoub,项目名称:librenms,代码行数:31,代码来源:apc.inc.php

示例15: preg_replace

             $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';
开发者ID:rasssta,项目名称:librenms,代码行数:31,代码来源:bgp-peers.inc.php


注:本文中的snmp_walk函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。