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


PHP is_valid_hostname函数代码示例

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


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

示例1: snmpwalk_cache_oid

$mtxr_array = snmpwalk_cache_oid($device, "mtxrNeighbor", array(), "MIKROTIK-MIB", NULL, OBS_SNMP_ALL | OBS_SNMP_CONCAT);
if ($mtxr_array) {
    if (OBS_DEBUG > 1) {
        print_vars($mtxr_array);
    }
    foreach ($mtxr_array as $key => $entry) {
        // Need to straighten out the MAC first for use later. Mikrotik does not pad the numbers! (i.e. 0:12:23:3:5c:6b)
        // FIXME move this to a smarter function?
        list($a, $b, $c, $d, $e, $f) = explode(':', $entry['mtxrNeighborMacAddress'], 6);
        $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
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:mikrotik-mib.inc.php

示例2: foreach

 foreach (array_keys($lldp_array) as $key) {
     $lldp_if_array = $lldp_array[$key];
     d_echo($lldp_if_array);
     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;
         }
         $interface = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $ifIndex));
         $lldp_instance = $lldp_if_array[$entry_key];
         d_echo($lldp_instance);
         foreach (array_keys($lldp_instance) as $entry_instance) {
             $lldp = $lldp_instance[$entry_instance];
             $remote_device_id = dbFetchCell('SELECT `device_id` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?', array($lldp['lldpRemSysName'], $lldp['lldpRemSysName']));
             if (!$remote_device_id && is_valid_hostname($lldp['lldpRemSysName'])) {
                 $skip_discovery = false;
                 if ($skip_discovery === false) {
                     $skip_discovery = can_skip_discovery($config['autodiscovery']['xdp_exclude']['sysname_regexp'], $lldp['lldpRemSysName'], $lldp['lldpRemSysName']);
                 }
                 if ($skip_discovery === false) {
                     $skip_discovery = can_skip_discovery($config['autodiscovery']['xdp_exclude']['sysdesc_regexp'], $lldp['lldpRemSysDesc'], $lldp['lldpRemSysName']);
                 }
                 if ($skip_discovery === false) {
                     $remote_device_id = discover_new_device($lldp['lldpRemSysName'], $device, 'LLDP', $interface);
                 }
             }
             // normalize MAC address if present
             $remote_port_mac_address = '';
             if ($lldp['lldpRemPortIdSubtype'] == 'macAddress') {
                 $remote_port_mac_address = str_replace(array(' ', ':', '-'), '', strtolower($lldp['lldpRemPortId']));
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:discovery-protocols.inc.php

示例3: dbFetchRow

 if (is_numeric($dot1d_array[$entry_key]['dot1dBasePortIfIndex']) && $device['os'] != "junos") {
     $ifIndex = $dot1d_array[$entry_key]['dot1dBasePortIfIndex'];
 } else {
     $ifIndex = $entry_key;
 }
 // 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));
 // If BRIDGE-MIB failed, get the port using pure LLDP-MIB
 if (!$port) {
     $ifName = $lldp_local_array[$entry_key]['lldpLocPortDesc'];
     $port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifDescr` = ?", array($device['device_id'], $ifName));
 }
 foreach ($lldp_instance as $entry_instance => $lldp) {
     $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
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:lldp-mib.inc.php

示例4: testIsValidHostname

 /**
  * @dataProvider providerIsValidHostname
  */
 public function testIsValidHostname($value, $result)
 {
     $this->assertSame($result, is_valid_hostname($value));
 }
开发者ID:skive,项目名称:observium,代码行数:7,代码来源:IncludesCommonTest.php

示例5: foreach

// FIXME, make this code generic for all *-ISDP-MIB
if ($isdp_array) {
    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)) {
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:netgear-isdp-mib.inc.php

示例6: 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

示例7: snmpwalk_cache_twopart_oid

 * @subpackage discovery
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2015 Adam Armstrong
 *
 */
echo " FOUNDRY-SN-SWITCH-GROUP-MIB ";
$fdp_array = snmpwalk_cache_twopart_oid($device, "snFdpCacheEntry", array(), "FOUNDRY-SN-SWITCH-GROUP-MIB", mib_dirs('foundry'));
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'];
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:foundry-sn-switch-group-mib.inc.php

示例8: snmpwalk_cache_threepart_oid

 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @author     Adam Armstrong <adama@observium.org>
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$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'];
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:alcatel-ind1-interswitch-protocol-mib.inc.php

示例9: snmpwalk_cache_threepart_oid

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
echo " ALCATEL-IND1-INTERSWITCH-PROTOCOL-MIB ";
$amap_array = snmpwalk_cache_threepart_oid($device, "aipAMAPportConnectionTable", array(), "ALCATEL-IND1-INTERSWITCH-PROTOCOL-MIB", mib_dirs('aos'), TRUE);
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 = 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_valid_hostname($amap['aipAMAPRemHostname']) && !is_bad_xdp($amap['aipAMAPRemHostname'])) {
            $remote_device_id = discover_new_device($amap['aipAMAPRemHostname'], 'xdp', 'AMAP', $device, $port);
        }
        if ($remote_device_id) {
            $remote_port_id = $amap['aipAMAPRemSlot'] * 1000 + $amap['aipAMAPRemPort'];
        }
        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']);
        }
    }
}
// EOF
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:alcatel-ind1-interswitch-protocol-mib.inc.php

示例10: die

// Check if primary or secondary
// folder specified
//////////////////////////////////
$lookin = null;
if (isset($_REQUEST['lookin']) && in_array($_REQUEST['lookin'], array('standard', 'custom'))) {
    $lookin = $_REQUEST['lookin'];
}
//////////////////////////////////
// Find file and display
//////////////////////////////////
$hostname = false;
if (is_valid_hostname($_REQUEST['url'])) {
    $hostname = $_REQUEST['url'];
} else {
    if ($_host = parse_url($_REQUEST['url'], PHP_URL_HOST)) {
        if (is_valid_hostname($_host)) {
            $hostname = $_host;
        }
    }
}
if (!$hostname) {
    die('Invalid URL');
}
$hostname_base = ltrim($hostname, '.');
if (strtolower(substr($hostname, 0, 4)) == 'www.') {
    $hostname = substr($hostname, 4);
    $hostname_base = $hostname;
}
$check = array('../site_config/standard/' . $hostname_base . '.txt', '../site_config/standard/.' . $hostname_base . '.txt', '../site_config/custom/' . $hostname_base . '.txt', '../site_config/custom/.' . $hostname_base . '.txt');
$related = array();
$matched = array();
开发者ID:yangchenghu,项目名称:full-text-rss,代码行数:31,代码来源:edit-pattern.php

示例11: simplexml_load_string

 $xml = simplexml_load_string('<?xml version="1.0"?> ' . $vm_info_xml);
 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

示例12: snmpwalk_cache_twopart_oid

 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
echo " FOUNDRY-SN-SWITCH-GROUP-MIB ";
$fdp_array = snmpwalk_cache_twopart_oid($device, "snFdpCacheEntry", array(), "FOUNDRY-SN-SWITCH-GROUP-MIB", mib_dirs('foundry'));
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 = dbFetchCell("SELECT `device_id` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?", array($fdp['snFdpCacheDeviceId'], $fdp['snFdpCacheDeviceId']));
            // FIXME do LLDP-code-style hostname overwrite here as well? (see below)
            if (!$remote_device_id && is_valid_hostname($fdp['snFdpCacheDeviceId']) && !is_bad_xdp($fdp['snFdpCacheDeviceId'])) {
                $remote_device_id = discover_new_device($fdp['snFdpCacheDeviceId'], 'xdp', 'FDP', $device, $port);
            }
            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']);
            }
        }
    }
}
// EOF
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:foundry-sn-switch-group-mib.inc.php

示例13: print_r

     print_r($xml);
 }
 $vmwVmDisplayName = $xml->name;
 $vmwVmGuestOS = '';
 # libvirt does not supply this
 $vmwVmMemSize = $xml->currentMemory / 1024;
 exec($config['virsh'] . ' -c ' . $uri . ' domstate ' . $dom_id, $vm_state);
 $vmwVmState = ucfirst($vm_state[0]);
 $vmwVmCpus = $xml->vcpu;
 # Check whether the Virtual Machine is already known for this host.
 $result = mysql_query("SELECT * FROM vminfo WHERE device_id = '" . $device["device_id"] . "' AND vmwVmVMID = '" . $dom_id . "' AND vm_type='libvirt'");
 if (mysql_num_rows($result) == 0) {
     mysql_query("INSERT INTO vminfo (device_id, vm_type, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState) VALUES (" . $device["device_id"] . ", 'libvirt',\n                '" . $dom_id . "', '" . mres($vmwVmDisplayName) . "', '" . mres($vmwVmGuestOS) . "', '" . $vmwVmMemSize . "', '" . $vmwVmCpus . "', '" . mres($vmwVmState) . "')");
     echo "+";
     log_event("Virtual Machine added: {$vmwVmDisplayName} ({$vmwVmMemSize} MB)", $device, 'vm', mysql_insert_id());
     if (is_valid_hostname($vmwVmDisplayName)) {
         discover_new_device($vmwVmDisplayName, 'libvirt');
     }
 } else {
     $row = mysql_fetch_assoc($result);
     if ($row['vmwVmState'] != $vmwVmState || $row['vmwVmDisplayName'] != $vmwVmDisplayName || $row['vmwVmCpus'] != $vmwVmCpus || $row['vmwVmGuestOS'] != $vmwVmGuestOS || $row['vmwVmMemSize'] != $vmwVmMemSize) {
         /// FIXME dbFacile
         mysql_query("UPDATE vminfo SET vmwVmState='" . mres($vmwVmState) . "', vmwVmGuestOS='" . mres($vmwVmGuestOS) . "', vmwVmDisplayName='" . mres($vmwVmDisplayName) . "',\n                  vmwVmMemSize='" . mres($vmwVmMemSize) . "', vmwVmCpus='" . mres($vmwVmCpus) . "' WHERE device_id='" . $device["device_id"] . "' AND vm_type='libvirt' AND vmwVmVMID='" . $dom_id . "'");
         echo "U";
         /// FIXME eventlog changed fields
     } else {
         echo ".";
     }
 }
 # Save the discovered Virtual Machine.
 $libvirt_vmlist[] = $dom_id;
开发者ID:RomanBogachev,项目名称:observium,代码行数:31,代码来源:libvirt-vminfo.inc.php


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