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


PHP discover_new_device函数代码示例

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


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

示例1: foreach

//end elseif
echo ' OSPF Discovery: ';
if ($config['autodiscovery']['ospf'] === true) {
    echo "enabled\n";
    foreach (dbFetchRows('SELECT DISTINCT(`ospfNbrIpAddr`),`device_id` FROM `ospf_nbrs` WHERE `device_id`=?', array($device['device_id'])) as $nbr) {
        $ip = $nbr['ospfNbrIpAddr'];
        if (match_network($config['autodiscovery']['nets-exclude'], $ip)) {
            echo 'x';
            continue;
        }
        if (!match_network($config['nets'], $ip)) {
            echo 'i';
            continue;
        }
        $name = gethostbyaddr($ip);
        $remote_device_id = discover_new_device($name, $device, 'OSPF');
    }
} else {
    echo "disabled\n";
}
d_echo($link_exists);
$sql = "SELECT * FROM `links` AS L, `ports` AS I WHERE L.local_port_id = I.port_id AND I.device_id = '" . $device['device_id'] . "'";
foreach (dbFetchRows($sql) as $test) {
    $local_port_id = $test['local_port_id'];
    $remote_hostname = $test['remote_hostname'];
    $remote_port = $test['remote_port'];
    d_echo("{$local_port_id} -> {$remote_hostname} -> {$remote_port} \n");
    if (!$link_exists[$local_port_id][$remote_hostname][$remote_port]) {
        echo '-';
        $rows = dbDelete('links', '`id` = ?', array($test['id']));
        d_echo("{$rows} deleted ");
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:discovery-protocols.inc.php

示例2: zeropad

 $entry['mtxrNeighborMacAddress'] = zeropad($a) . ':' . zeropad($b) . ':' . zeropad($c) . ':' . zeropad($d) . ':' . zeropad($e) . ':' . zeropad($f);
 $ifIndex = $entry['mtxrNeighborInterfaceID'];
 // Get the port using BRIDGE-MIB
 $port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ? AND `ifDescr` NOT LIKE 'Vlan%'", array($device['device_id'], $ifIndex));
 $remote_device_id = FALSE;
 $remote_port_id = 0;
 if (is_valid_hostname($entry['mtxrNeighborIdentity'])) {
     if (isset($GLOBALS['cache']['discovery-protocols'][$entry['mtxrNeighborIdentity']])) {
         // This hostname already checked, skip discover
         $remote_device_id = $GLOBALS['cache']['discovery-protocols'][$entry['mtxrNeighborIdentity']];
     } else {
         $remote_device = dbFetchRow("SELECT `device_id`, `hostname` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?", array($entry['mtxrNeighborIdentity'], $entry['mtxrNeighborIdentity']));
         $remote_device_id = $remote_device['device_id'];
         // If we don't know this device, try to discover it, as long as it's not matching our exclusion filters
         if (!$remote_device_id && !is_bad_xdp($entry['mtxrNeighborIdentity'], $entry['mtxrNeighborPlatform'])) {
             $remote_device_id = discover_new_device($entry['mtxrNeighborIdentity'], 'xdp', 'MNDP', $device, $port);
         }
         // Cache remote device ID for other protocols
         $GLOBALS['cache']['discovery-protocols'][$entry['mtxrNeighborIdentity']] = $remote_device_id;
     }
 } else {
     // Try to find remote host by remote chassis mac address from DB
     $remote_mac = str_replace(':', '', strtolower($entry['mtxrNeighborMacAddress']));
     $remote_device_id = dbFetchCell("SELECT `device_id` FROM `ports` WHERE `deleted` = '0' AND `ifPhysAddress` = ? LIMIT 1;", array($remote_mac));
     if (!$remote_device_id) {
         // We can also use IP address from mtxrNeighborIpAddress to find remote device.
         $remote_device_id = dbFetchCell("SELECT `device_id` FROM `ports` LEFT JOIN `ipv4_addresses` on `ports`.`port_id`=`ipv4_addresses`.`port_id` WHERE `deleted` = '0' AND `ipv4_address` = ? LIMIT 1;", array($entry['mtxrNeighborIpAddress']));
     }
 }
 if ($remote_device_id) {
     $remote_device_hostname = device_by_id_cache($remote_device_id);
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:mikrotik-mib.inc.php

示例3: dbUpdate

 } else {
     echo 'No BGP on host';
     if ($device['bgpLocalAs']) {
         dbUpdate(array('bgpLocalAs' => 'NULL'), 'devices', 'device_id=?', array($device['device_id']));
         echo ' (Removed ASN) ';
     }
 }
 // Process disovered peers
 if (isset($peerlist)) {
     foreach ($peerlist as $peer) {
         $astext = get_astext($peer['as']);
         if (dbFetchCell('SELECT COUNT(*) from `bgpPeers` WHERE device_id = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['ip'])) < '1') {
             $add = dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'bgpPeerRemoteAs' => $peer['as']), 'bgpPeers');
             if ($config['autodiscovery']['bgp'] === true) {
                 $name = gethostbyaddr($peer['ip']);
                 $remote_device_id = discover_new_device($name, $device, 'BGP');
             }
             echo '+';
         } else {
             $update = dbUpdate(array('bgpPeerRemoteAs' => $peer['as'], 'astext' => mres($astext)), 'bgpPeers', 'device_id=? AND bgpPeerIdentifier=?', array($device['device_id'], $peer['ip']));
             echo '.';
         }
         if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') {
             if ($device['os_group'] == 'cisco') {
                 // Get afi/safi and populate cbgp on cisco ios (xe/xr)
                 unset($af_list);
                 if ($peer2 === true) {
                     $af_data = snmpwalk_cache_oid($device, 'cbgpPeer2AddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
                 } else {
                     $af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
                 }
开发者ID:rasssta,项目名称:librenms,代码行数:31,代码来源:bgp-peers.inc.php

示例4: dbFetchRow

 $remote_device_id = FALSE;
 $remote_port_id = 0;
 if (is_valid_hostname($lldp['lldpRemSysName'])) {
     if (isset($GLOBALS['cache']['discovery-protocols'][$lldp['lldpRemSysName']])) {
         // This hostname already checked, skip discover
         $remote_device_id = $GLOBALS['cache']['discovery-protocols'][$lldp['lldpRemSysName']];
     } else {
         $remote_device = dbFetchRow("SELECT `device_id`, `hostname` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?", array($lldp['lldpRemSysName'], $lldp['lldpRemSysName']));
         $remote_device_id = $remote_device['device_id'];
         // Overwrite remote hostname with the one we know, for devices that we identify by sysName
         if ($remote_device['hostname']) {
             $lldp['lldpRemSysName'] = $remote_device['hostname'];
         }
         // If we don't know this device, try to discover it, as long as it's not matching our exclusion filters
         if (!$remote_device_id && !is_bad_xdp($lldp['lldpRemSysName'], $lldp['lldpRemSysDesc'])) {
             $remote_device_id = discover_new_device($lldp['lldpRemSysName'], 'xdp', 'LLDP', $device, $port);
         }
         // Cache remote device ID for other protocols
         $GLOBALS['cache']['discovery-protocols'][$lldp['lldpRemSysName']] = $remote_device_id;
     }
 } else {
     // Try to find remote host by remote chassis mac address from DB
     if (empty($lldp['lldpRemSysName']) && $lldp['lldpRemChassisIdSubtype'] == 'macAddress') {
         $remote_mac = str_replace(array(' ', '-', ':'), '', strtolower($lldp['lldpRemChassisId']));
         $remote_device_id = dbFetchCell("SELECT `device_id` FROM `ports` WHERE `deleted` = '0' AND `ifPhysAddress` = ? LIMIT 1;", array($remote_mac));
         if ($remote_device_id) {
             $remote_device_hostname = device_by_id_cache($remote_device_id);
             if ($remote_device_hostname['hostname']) {
                 $lldp['lldpRemSysName'] = $remote_device_hostname['hostname'];
             }
         }
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:lldp-mib.inc.php

示例5: dbInsert

             if (isset($update_array['reverse_dns']) && count($update_array) == 1) {
                 // Do not count updates if changed only reverse DNS
                 $GLOBALS['module_stats'][$module]['unchanged']++;
             } else {
                 $GLOBALS['module_stats'][$module]['updated']++;
             }
         } else {
             $GLOBALS['module_stats'][$module]['unchanged']++;
         }
     } else {
         dbInsert($params, 'bgpPeers');
         $GLOBALS['module_stats'][$module]['added']++;
     }
     // Autodiscovery for ibgp neighbours
     if ($config['autodiscovery']['bgp'] && $peer['as'] == $device['bgpLocalAs']) {
         discover_new_device($peer['ip'], 'bgp', 'BGP', $device);
     }
 }
 # Foreach
 // AFI/SAFI for specific vendors
 if ($cisco_version || $vendor_mib) {
     unset($af_list);
     if ($cisco_version) {
         // Get afi/safi and populate cbgp on cisco ios (xe/xr)
         if ($cisco_version === 2) {
             $af_data = snmpwalk_cache_oid($device, 'cbgpPeer2AddrFamilyName', $cbgp, 'CISCO-BGP4-MIB');
         } else {
             $af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyName', $cbgp, 'CISCO-BGP4-MIB');
         }
         foreach ($af_data as $af => $entry) {
             if ($cisco_version === 2) {
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:bgp-peers.inc.php

示例6: foreach

 foreach ($isdp_array as $ifIndex => $port_neighbours) {
     $port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex));
     foreach ($port_neighbours as $entry_id => $isdp_entry) {
         list($isdp_entry['agentIsdpCacheDeviceId']) = explode('(', $isdp_entry['agentIsdpCacheDeviceId']);
         // Fix for Nexus ISDP neighbors: <hostname>(serial number)
         $remote_device_id = FALSE;
         if (is_valid_hostname($isdp_entry['agentIsdpCacheDeviceId'])) {
             if (isset($GLOBALS['cache']['discovery-protocols'][$isdp_entry['agentIsdpCacheDeviceId']])) {
                 // This hostname already checked, skip discover
                 $remote_device_id = $GLOBALS['cache']['discovery-protocols'][$isdp_entry['agentIsdpCacheDeviceId']];
             } else {
                 $remote_device_id = dbFetchCell("SELECT `device_id` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?", array($isdp_entry['agentIsdpCacheDeviceId'], $isdp_entry['agentIsdpCacheDeviceId']));
                 // FIXME do LLDP-code-style hostname overwrite here as well? (see below)
                 if (!$remote_device_id && is_valid_hostname($isdp_entry['agentIsdpCacheDeviceId']) && !is_bad_xdp($isdp_entry['agentIsdpCacheDeviceId'], $isdp_entry['agentIsdpCachePlatform'])) {
                     // For now it's a Cisco so CDP discovery is ok
                     $remote_device_id = discover_new_device($isdp_entry['agentIsdpCacheDeviceId'], 'xdp', 'ISDP', $device, $port);
                 }
                 // Cache remote device ID for other protocols
                 $GLOBALS['cache']['discovery-protocols'][$isdp_entry['agentIsdpCacheDeviceId']] = $remote_device_id;
             }
             if ($remote_device_id) {
                 $if = $isdp_entry['agentIsdpCacheDevicePort'];
                 $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifDescr` = ? OR `ifName` = ?) AND `device_id` = ?", array($if, $if, $remote_device_id));
             } else {
                 $remote_port_id = "0";
             }
             if (!is_bad_xdp($isdp_entry['agentIsdpCacheDeviceId']) && $port['port_id'] && $isdp_entry['agentIsdpCacheDeviceId'] && $isdp_entry['agentIsdpCacheDevicePort']) {
                 $remote_address = $isdp_entry['agentIsdpCacheAddress'];
                 if (!get_ip_version($remote_address)) {
                     $remote_address = NULL;
                 }
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:netgear-isdp-mib.inc.php

示例7: discover_virtual_machine

/**
 * Discover a new virtual machine on a device
 *
 * This function adds a virtual machine to a device, if it does not already exist.
 * Data on the VM is updated if it has changed, and an event is logged with regards to the changes.
 * If the VM has a valid hostname, Observium attempts to discover this as a new device (calling discover_new_device).
 *
 * Valid array keys for the $options array: type, id, name, os, memory (in bytes), cpucount, status, source (= snmp, agent, etc)
 *
 * @param array &$valid
 * @param array $device
 * @param array $options
*/
function discover_virtual_machine(&$valid, $device, $options = array())
{
    print_debug('Discover VM: ' . $options['type'] . '/' . $options['source'] . ' (' . $options['id'] . ') ' . $options['name'] . ' CPU: ' . $options['cpucount'] . ' RAM: ' . $options['memory'] . ' Status: ' . $options['status']);
    if (dbFetchCell("SELECT COUNT(`vm_id`) FROM `vminfo` WHERE `device_id` = ? AND `vm_name` = ? AND `vm_type` = ? AND `vm_source` = ?", array($device['device_id'], $options['name'], $options['type'], $options['source'])) == '0') {
        $vm_insert = array('device_id' => $device['device_id'], 'vm_type' => $options['type'], 'vm_uuid' => $options['id'], 'vm_name' => $options['name'], 'vm_guestos' => $options['os'], 'vm_memory' => $options['memory'] / 1024 / 1024, 'vm_cpucount' => $options['cpucount'], 'vm_state' => $options['status'], 'vm_source' => $options['source']);
        $vm_id = dbInsert($vm_insert, 'vminfo');
        echo '+';
        log_event("Virtual Machine added: " . $options['name'] . ' (' . format_bi($options['memory']) . 'B RAM, ' . $options['cpucount'] . ' CPU)', $device, $options['type'], $vm_id);
        if (is_valid_hostname($options['name']) && in_array($options['status'], array('running', 'powered on', 'poweredOn'))) {
            // Try to discover this VM as a new device, if it's actually running. discover_new_device() will check for valid hostname, duplicates, etc.
            // Libvirt, Proxmox (= QEMU-powered) return "running"; VMWare returns "powered on" (or "poweredOn" in older versions).
            discover_new_device($options['name'], $options['type']);
        }
    } else {
        $vm = dbFetchRow("SELECT * FROM `vminfo` WHERE `device_id` = ? AND `vm_uuid` = ? AND `vm_type` = ?", array($device['device_id'], $options['id'], $options['type']));
        if ($vm['vm_state'] != $options['status'] || $vm['vm_name'] != $options['name'] || $vm['vm_cpucount'] != $options['cpucount'] || $vm['vm_guestos'] != $options['os'] || $vm['vm_memory'] != $options['memory'] / 1024 / 1024) {
            $update = array('vm_state' => $options['status'], 'vm_guestos' => $options['os'], 'vm_name' => $options['name'], 'vm_memory' => $options['memory'] / 1024 / 1024, 'vm_cpucount' => $options['cpucount']);
            dbUpdate($update, 'vminfo', "device_id = ? AND vm_type = ? AND vm_uuid = ? AND vm_source = ?", array($device['device_id'], $options['type'], $options['id'], $options['source']));
            echo 'U"';
            /// FIXME eventlog changed fields
        } else {
            echo '.';
        }
    }
    $valid['vm'][$options['type']][(string) $options['id']] = 1;
}
开发者ID:Natolumin,项目名称:observium,代码行数:39,代码来源:functions.inc.php

示例8: foreach

}
echo "OSPF Discovery: ";
if ($config['autodiscovery']['ospf'] === TRUE) {
    echo "enabled\n";
    foreach (dbFetchRows("SELECT DISTINCT(`ospfNbrIpAddr`),`device_id` FROM `ospf_nbrs` WHERE `device_id`=?", array($device['device_id'])) as $nbr) {
        $ip = $nbr['ospfNbrIpAddr'];
        if (match_network($config['autodiscovery']['nets-exclude'], $ip)) {
            echo "x";
            continue;
        }
        if (!match_network($config['nets'], $ip)) {
            echo "i";
            continue;
        }
        $name = gethostbyaddr($ip);
        $remote_device_id = discover_new_device($name);
        if (isset($remote_device_id) && $remote_device_id > 0) {
            log_event("Device {$name} ({$ip}) autodiscovered through OSPF", $remote_device_id, 'system');
        } else {
            log_event("OSPF discovery of {$name} ({$ip}) failed - check ping and SNMP access", $device['device_id'], 'system');
        }
    }
} else {
    echo "disabled\n";
}
if ($debug) {
    print_r($link_exists);
}
$sql = "SELECT * FROM `links` AS L, `ports` AS I WHERE L.local_port_id = I.port_id AND I.device_id = '" . $device['device_id'] . "'";
foreach (dbFetchRows($sql) as $test) {
    $local_port_id = $test['local_port_id'];
开发者ID:REAP720801,项目名称:librenms,代码行数:31,代码来源:discovery-protocols.inc.php

示例9: snmpwalk_cache_threepart_oid

 */
$amap_array = snmpwalk_cache_threepart_oid($device, "aipAMAPportConnectionTable", array(), "ALCATEL-IND1-INTERSWITCH-PROTOCOL-MIB", NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
if ($amap_array) {
    foreach (array_keys($amap_array) as $key) {
        $amap = array_shift(array_shift($amap_array[$key]));
        $port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $amap['aipAMAPLocalIfindex']));
        $remote_device_id = FALSE;
        if (is_valid_hostname($amap['aipAMAPRemHostname'])) {
            if (isset($GLOBALS['cache']['discovery-protocols'][$amap['aipAMAPRemHostname']])) {
                // This hostname already checked, skip discover
                $remote_device_id = $GLOBALS['cache']['discovery-protocols'][$amap['aipAMAPRemHostname']];
            } else {
                $remote_device = dbFetchRow("SELECT `device_id`, `hostname` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?", array($amap['aipAMAPRemHostname'], $amap['aipAMAPRemHostname']));
                $remote_device_id = $remote_device['device_id'];
                if (!$remote_device_id && !is_bad_xdp($amap['aipAMAPRemHostname'], $amap['aipAMAPRemDeviceType'])) {
                    $remote_device_id = discover_new_device($amap['aipAMAPRemHostname'], 'xdp', 'AMAP', $device, $port);
                }
                // Cache remote device ID for other protocols
                $GLOBALS['cache']['discovery-protocols'][$amap['aipAMAPRemHostname']] = $remote_device_id;
            }
        }
        if ($remote_device_id) {
            $if = $amap['aipAMAPRemSlot'] . "/" . $amap['aipAMAPRemPort'];
            $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifDescr` = ? OR `ifName` = ?) AND `device_id` = ?", array($if, $if, $remote_device_id));
        } else {
            $remote_port_id = "0";
        }
        if (!is_bad_xdp($amap['aipAMAPRemHostname']) && is_numeric($port['port_id']) && isset($amap['aipAMAPRemHostname'])) {
            discover_link($valid_link, $port['port_id'], 'amap', $remote_port_id, $amap['aipAMAPRemHostname'], $amap['aipAMAPRemSlot'] . "/" . $amap['aipAMAPRemPort'], $amap['aipAMAPRemDeviceType'], $amap['aipAMAPRemDevModelName']);
        }
    }
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:alcatel-ind1-interswitch-protocol-mib.inc.php

示例10: unset

if ($fdp_array) {
    unset($fdp_links);
    foreach (array_keys($fdp_array) as $key) {
        $port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $key));
        $fdp_if_array = $fdp_array[$key];
        foreach (array_keys($fdp_if_array) as $entry_key) {
            $fdp = $fdp_if_array[$entry_key];
            $remote_device_id = FALSE;
            if (is_valid_hostname($fdp['snFdpCacheDeviceId'])) {
                if (isset($GLOBALS['cache']['discovery-protocols'][$fdp['snFdpCacheDeviceId']])) {
                    // This hostname already checked, skip discover
                    $remote_device_id = $GLOBALS['cache']['discovery-protocols'][$fdp['snFdpCacheDeviceId']];
                } else {
                    $remote_device_id = dbFetchCell("SELECT `device_id` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?", array($fdp['snFdpCacheDeviceId'], $fdp['snFdpCacheDeviceId']));
                    if (!$remote_device_id && !is_bad_xdp($fdp['snFdpCacheDeviceId'], $fdp['snFdpCachePlatform'])) {
                        $remote_device_id = discover_new_device($fdp['snFdpCacheDeviceId'], 'xdp', 'FDP', $device, $port);
                    }
                    // Cache remote device ID for other protocols
                    $GLOBALS['cache']['discovery-protocols'][$fdp['snFdpCacheDeviceId']] = $remote_device_id;
                }
            }
            // FIXME do LLDP-code-style hostname overwrite here as well? (see below)
            if ($remote_device_id) {
                $if = $fdp['snFdpCacheDevicePort'];
                $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifDescr` = ? OR `ifName` = ?) AND `device_id` = ?", array($if, $if, $remote_device_id));
            } else {
                $remote_port_id = "0";
            }
            if (!is_bad_xdp($fdp['snFdpCacheDeviceId'])) {
                discover_link($valid_link, $port['port_id'], $fdp['snFdpCacheVendorId'], $remote_port_id, $fdp['snFdpCacheDeviceId'], $fdp['snFdpCacheDevicePort'], $fdp['snFdpCachePlatform'], $fdp['snFdpCacheVersion']);
            }
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:foundry-sn-switch-group-mib.inc.php

示例11: foreach

if ($cdp_array) {
    foreach ($cdp_array as $ifIndex => $port_neighbours) {
        $port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex));
        foreach ($port_neighbours as $entry_id => $cdp_entry) {
            list($cdp_entry['cdpCacheDeviceId']) = explode('(', $cdp_entry['cdpCacheDeviceId']);
            // Fix for Nexus CDP neighbors: <hostname>(serial number)
            $remote_device_id = FALSE;
            if (is_valid_hostname($cdp_entry['cdpCacheDeviceId'])) {
                if (isset($GLOBALS['cache']['discovery-protocols'][$cdp_entry['cdpCacheDeviceId']])) {
                    // This hostname already checked, skip discover
                    $remote_device_id = $GLOBALS['cache']['discovery-protocols'][$cdp_entry['cdpCacheDeviceId']];
                } else {
                    $remote_device_id = dbFetchCell("SELECT `device_id` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?", array($cdp_entry['cdpCacheDeviceId'], $cdp_entry['cdpCacheDeviceId']));
                    // FIXME do LLDP-code-style hostname overwrite here as well? (see below)
                    if (!$remote_device_id && is_valid_hostname($cdp_entry['cdpCacheDeviceId']) && !is_bad_xdp($cdp_entry['cdpCacheDeviceId'], $cdp_entry['cdpCachePlatform'])) {
                        $remote_device_id = discover_new_device($cdp_entry['cdpCacheDeviceId'], 'xdp', 'CDP', $device, $port);
                    }
                    // Cache remote device ID for other protocols
                    $GLOBALS['cache']['discovery-protocols'][$cdp_entry['cdpCacheDeviceId']] = $remote_device_id;
                }
                if ($remote_device_id) {
                    $if = $cdp_entry['cdpCacheDevicePort'];
                    $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifDescr` = ? OR `ifName` = ?) AND `device_id` = ?", array($if, $if, $remote_device_id));
                } else {
                    $remote_port_id = "0";
                }
                if (!is_bad_xdp($cdp_entry['cdpCacheDeviceId']) && $port['port_id'] && $cdp_entry['cdpCacheDeviceId'] && $cdp_entry['cdpCacheDevicePort']) {
                    discover_link($valid_link, $port['port_id'], 'cdp', $remote_port_id, $cdp_entry['cdpCacheDeviceId'], $cdp_entry['cdpCacheDevicePort'], $cdp_entry['cdpCachePlatform'], $cdp_entry['cdpCacheVersion']);
                }
            } else {
                echo "X";
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:cisco-cdp-mib.inc.php

示例12: snmpwalk_values

<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
## OSPF-MIB::ospfNbrIpAddr.172.22.203.98.0
if ($config['autodiscovery']['ospf'] != FALSE) {
    echo "OSPF Neighbours: \n";
    $ips = snmpwalk_values($device, "ospfNbrIpAddr", array(), "OSPF-MIB", mib_dirs());
    foreach ($ips as $ip) {
        discover_new_device($ip, 'ospf', 'OSPF', $device);
    }
}
// EOF
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:21,代码来源:ospf-autodiscovery.inc.php

示例13: print_vars

     if ($debug) {
         print_vars($xml);
     }
     $vmwVmGuestOS = '';
     // libvirt does not supply this
     $vmwVmMemSize = $xml->currentMemory / 1024;
     $vmwVmState = ucfirst($vmwVmState);
     $vmwVmCpus = $xml->vcpu;
     // Check whether the Virtual Machine is already known for this host.
     if (dbFetchCell("SELECT COUNT(`id`) FROM `vminfo` WHERE `device_id` = ? AND `vmwVmDisplayName` = ? AND `vm_type` = 'libvirt'", array($device['device_id'], $vmwVmDisplayName)) == '0') {
         $libvirt_insert = array('device_id' => $device['device_id'], 'vm_type' => 'libvirt', 'vmwVmVMID' => $dom_id, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus, 'vmwVmState' => $vmwVmState);
         $inserted = dbInsert($libvirt_insert, 'vminfo');
         echo "+";
         log_event("Virtual Machine added: {$vmwVmDisplayName} ({$vmwVmMemSize} MB)", $device, 'vm', $inserted);
         if (is_valid_hostname($vmwVmDisplayName) && $vmwVmState == 'Running') {
             discover_new_device($vmwVmDisplayName, 'libvirt');
         }
     } else {
         $libvirt = dbFetchRow("SELECT * FROM `vminfo` WHERE `device_id` = ? AND `vmwVmVMID` = ? AND `vm_type` = 'libvirt'", array($device['device_id'], $dom_id));
         if ($libvirt['vmwVmState'] != $vmwVmState || $libvirt['vmwVmDisplayName'] != $vmwVmDisplayName || $libvirt['vmwVmCpus'] != $vmwVmCpus || $libvirt['vmwVmGuestOS'] != $vmwVmGuestOS || $libvirt['vmwVmMemSize'] != $vmwVmMemSize) {
             $update = array('vmwVmState' => $vmwVmState, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus);
             dbUpdate($update, 'vminfo', "device_id = ? AND vm_type = 'libvirt' AND vmwVmVMID = ?", array($device['device_id'], $dom_id));
             echo "U";
             /// FIXME eventlog changed fields
         } else {
             echo ".";
         }
     }
     // Save the discovered Virtual Machine.
     $libvirt_vmlist[] = $vmwVmDisplayName;
 }
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:libvirt-vminfo.inc.php

示例14: foreach

 foreach (array_keys($lldp_if_array) as $entry_key) {
     if (is_numeric($dot1d_array[$entry_key]['dot1dBasePortIfIndex'])) {
         $ifIndex = $dot1d_array[$entry_key]['dot1dBasePortIfIndex'];
     } else {
         $ifIndex = $entry_key;
     }
     $port = dbFetchRow("SELECT * FROM `ports` WHERE device_id = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex));
     $lldp_instance = $lldp_if_array[$entry_key];
     foreach (array_keys($lldp_instance) as $entry_instance) {
         $lldp = $lldp_instance[$entry_instance];
         $remote_device = dbFetchRow("SELECT `device_id`, `hostname` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?", array($lldp['lldpRemSysName'], $lldp['lldpRemSysName']));
         $remote_device_id = $remote_device['device_id'];
         // Overwrite remote hostname with the one we know, for devices that we identify by sysName
         $lldp['lldpRemSysName'] = $remote_device['hostname'];
         if (!$remote_device_id && is_valid_hostname($lldp['lldpRemSysName'])) {
             $remote_device_id = discover_new_device($lldp['lldpRemSysName']);
             if ($remote_device_id) {
                 humanize_port($port);
                 log_event("Device autodiscovered through LLDP on " . $device['hostname'] . " (port " . $port['label'] . ")", $remote_device_id, 'interface', $port['port_id']);
             }
         }
         if ($remote_device_id) {
             $if = $lldp['lldpRemPortDesc'];
             $id = $lldp['lldpRemPortId'];
             $remote_port_id = dbFetchCell("SELECT port_id FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?", array($id, $remote_device_id));
             if (!$remote_port_id) {
                 $remote_port_id = dbFetchCell("SELECT port_id FROM `ports` WHERE (`ifDescr`= ? OR `ifName`= ?) AND `device_id` = ?", array($id, $id, $remote_device_id));
                 if (!$remote_port_id) {
                     $remote_port_id = dbFetchCell("SELECT port_id FROM `ports` WHERE (`ifDescr`= ? OR `ifName`= ?) AND `device_id` = ?", array($if, $if, $remote_device_id));
                     if (!$remote_port_id) {
                         if ($lldp['lldpRemChassisIdSubtype'] == 'macAddress') {
开发者ID:RomanBogachev,项目名称:observium,代码行数:31,代码来源:discovery-protocols.inc.php

示例15: discover_new_device_ip

function discover_new_device_ip($host, $source = 'xdp', $protocol = NULL, $device = NULL, $port = NULL)
{
    print_error("Function discover_new_device_ip() is deprecated, use discover_new_device().");
    discover_new_device($host, $source, $protocol, $device, $port);
}
开发者ID:skive,项目名称:observium,代码行数:5,代码来源:functions.inc.php


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