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


PHP Net_IPv6::compress方法代码示例

本文整理汇总了PHP中Net_IPv6::compress方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_IPv6::compress方法的具体用法?PHP Net_IPv6::compress怎么用?PHP Net_IPv6::compress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_IPv6的用法示例。


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

示例1: add_device

function add_device($hostname, $snmp_version = array(), $snmp_port = 161, $snmp_transport = 'udp', $options = array(), $flags = OBS_DNS_ALL)
{
    global $config;
    // If $options['break'] set as TRUE, break recursive function execute
    if (isset($options['break']) && $options['break']) {
        return FALSE;
    }
    $return = FALSE;
    // By default return FALSE
    // Reset snmp timeout and retries options for speedup device adding
    unset($config['snmp']['timeout'], $config['snmp']['retries']);
    $snmp_transport = strtolower($snmp_transport);
    $hostname = strtolower(trim($hostname));
    // Try detect if hostname is IP
    switch (get_ip_version($hostname)) {
        case 6:
            $hostname = Net_IPv6::compress($hostname, TRUE);
            // Always use compressed IPv6 name
        // Always use compressed IPv6 name
        case 4:
            if ($config['require_hostname']) {
                print_error("Hostname should be a valid resolvable FQDN name. Or set config option \$config['require_hostname'] as FALSE.");
                return $return;
            }
            $ip = $hostname;
            break;
        default:
            if ($snmp_transport == 'udp6' || $snmp_transport == 'tcp6') {
                $flags = $flags ^ OBS_DNS_A;
                // exclude A
            }
            // Test DNS lookup.
            $ip = gethostbyname6($hostname, $flags);
    }
    // Test if host exists in database
    if (dbFetchCell("SELECT COUNT(*) FROM `devices` WHERE `hostname` = ?", array($hostname)) == '0') {
        if ($ip) {
            $ip_version = get_ip_version($ip);
            // Test reachability
            $options['ping_skip'] = isset($options['ping_skip']) && $options['ping_skip'];
            if ($options['ping_skip']) {
                $flags = $flags | OBS_PING_SKIP;
            }
            if (isPingable($hostname, $flags)) {
                // Test directory exists in /rrd/
                if (!$config['rrd_override'] && file_exists($config['rrd_dir'] . '/' . $hostname)) {
                    print_error("Directory <observium>/rrd/{$hostname} already exists.");
                    return FALSE;
                }
                // Detect snmp transport
                if (stripos($snmp_transport, 'tcp') !== FALSE) {
                    $snmp_transport = $ip_version == 4 ? 'tcp' : 'tcp6';
                } else {
                    $snmp_transport = $ip_version == 4 ? 'udp' : 'udp6';
                }
                // Detect snmp port
                if (!is_numeric($snmp_port) || $snmp_port < 1 || $snmp_port > 65535) {
                    $snmp_port = 161;
                } else {
                    $snmp_port = (int) $snmp_port;
                }
                // Detect snmp version
                if (empty($snmp_version)) {
                    // Here set default snmp version order
                    $i = 1;
                    $snmp_version_order = array();
                    foreach (array('v2c', 'v3', 'v1') as $tmp_version) {
                        if ($config['snmp']['version'] == $tmp_version) {
                            $snmp_version_order[0] = $tmp_version;
                        } else {
                            $snmp_version_order[$i] = $tmp_version;
                        }
                        $i++;
                    }
                    ksort($snmp_version_order);
                    foreach ($snmp_version_order as $tmp_version) {
                        $ret = add_device($hostname, $tmp_version, $snmp_port, $snmp_transport, $options);
                        if ($ret === FALSE) {
                            // Set $options['break'] for break recursive
                            $options['break'] = TRUE;
                        } else {
                            if (is_numeric($ret) && $ret != 0) {
                                return $ret;
                            }
                        }
                    }
                } else {
                    if ($snmp_version === "v3") {
                        // Try each set of parameters from config
                        foreach ($config['snmp']['v3'] as $snmp_v3) {
                            $device = build_initial_device_array($hostname, NULL, $snmp_version, $snmp_port, $snmp_transport, $snmp_v3);
                            print_message("Trying v3 parameters " . $device['snmp_authname'] . "/" . $device['snmp_authlevel'] . " ... ");
                            if (isSNMPable($device)) {
                                if (!check_device_duplicated($device)) {
                                    if (isset($options['test']) && $options['test']) {
                                        print_message('%WDevice "' . $hostname . '" has successfully been tested and available by ' . strtoupper($snmp_transport) . ' transport with SNMP ' . $snmp_version . ' credentials.%n', 'color');
                                        $device_id = -1;
                                    } else {
                                        $device_id = createHost($hostname, NULL, $snmp_version, $snmp_port, $snmp_transport, $snmp_v3);
                                        if ($options['ping_skip']) {
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:functions.inc.php

示例2: get_status_array


//.........这里部分代码省略.........
        $query = 'SELECT * FROM `devices` AS D ';
        $query .= 'WHERE D.`status` = 0' . $query_device_permitted;
        $query .= 'ORDER BY D.`hostname` ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $device) {
            $boxes[] = array('sev' => 100, 'class' => 'Device', 'event' => 'Down', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'));
        }
    }
    // Uptime
    if ($status['uptime']) {
        if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
            $query = 'SELECT * FROM `devices` AS D ';
            $query .= 'WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`uptime` < ' . $config['uptime_warning'];
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query);
            foreach ($entries as $device) {
                $boxes[] = array('sev' => 10, 'class' => 'Device', 'event' => 'Rebooted', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'), 'location' => $device['location']);
            }
        }
    }
    // Ports Down
    if ($status['ports'] || $status['links']) {
        // warning about deprecated option: $config['warn']['ifdown']
        if (isset($config['warn']['ifdown']) && !$config['warn']['ifdown']) {
            print_warning("<strong>Config option obsolete</strong>\n                    Please note that config option <strong>\$config['warn']['ifdown']</strong> is now obsolete.\n                    Use options: <strong>\$config['frontpage']['device_status']['ports']</strong> and <strong>\$config['frontpage']['device_status']['errors']</strong>\n                    To remove this message, delete <strong>\$config['warn']['ifdown']</strong> from configuration file.");
        }
        $query = 'SELECT * FROM `ports` AS I ';
        if ($status['links'] && !$status['ports']) {
            $query .= 'INNER JOIN `links` as L ON I.`port_id` = L.`local_port_id` ';
        }
        $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
        $query .= "WHERE I.`ifOperStatus` = 'down' AND I.`ifAdminStatus` = 'up' ";
        if ($status['links'] && !$status['ports']) {
            $query .= ' AND L.`active` = 1 ';
        }
        $query .= $query_port_permitted;
        $query .= ' AND I.`ifLastChange` >= DATE_SUB(NOW(), INTERVAL ' . $max_interval . ' HOUR) ';
        $query .= 'ORDER BY I.`ifLastChange` DESC, D.`hostname` ASC, I.`ifDescr` * 1 ASC ';
        $entries = dbFetchRows($query);
        $i = 1;
        foreach ($entries as $port) {
            if ($i > $max_count) {
                // Limit to 200 ports on overview page
                break;
            }
            humanize_port($port);
            $boxes[] = array('sev' => 50, 'class' => 'Port', 'event' => 'Down', 'device_link' => generate_device_link($port, short_hostname($port['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['label'], 13)), 'time' => formatUptime($config['time']['now'] - strtotime($port['ifLastChange'])), 'location' => $device['location']);
        }
    }
    // Ports Errors (only deltas)
    if ($status['errors']) {
        foreach ($cache['ports']['errored'] as $port_id) {
            $port = get_port_by_id($port_id);
            $device = device_by_id_cache($port['device_id']);
            humanize_port($port);
            if ($port['ifInErrors_delta']) {
                $port['string'] .= 'Rx: ' . format_number($port['ifInErrors_delta']);
            }
            if ($port['ifInErrors_delta'] && $port['ifOutErrors_delta']) {
                $port['string'] .= ', ';
            }
            if ($port['ifOutErrors_delta']) {
                $port['string'] .= 'Tx: ' . format_number($port['ifOutErrors_delta']);
            }
            $boxes[] = array('sev' => 75, 'class' => 'Port', 'event' => 'Errors', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['label'], 13)), 'time' => $port['string'], 'location' => $device['location']);
        }
    }
    // Services
    if ($status['services']) {
        $query = 'SELECT * FROM `services` AS S ';
        $query .= 'LEFT JOIN `devices` AS D ON S.device_id = D.device_id ';
        $query .= "WHERE S.`service_status` = 'down' AND S.`service_ignore` = 0";
        $query .= $query_device_permitted;
        $query .= 'ORDER BY D.`hostname` ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $service) {
            $boxes[] = array('sev' => 50, 'class' => 'Service', 'event' => 'Down', 'device_link' => generate_device_link($service, short_hostname($service['hostname'])), 'entity_link' => $service['service_type'], 'time' => formatUptime($config['time']['now'] - strtotime($service['service_changed']), 'short'), 'location' => $device['location']);
        }
    }
    // BGP
    if ($status['bgp']) {
        if (isset($config['enable_bgp']) && $config['enable_bgp']) {
            $query = 'SELECT * FROM `devices` AS D ';
            $query .= 'LEFT JOIN `bgpPeers` AS B ON B.`device_id` = D.`device_id` ';
            $query .= 'LEFT JOIN `bgpPeers-state` AS BS ON B.`bgpPeer_id` = BS.`bgpPeer_id` ';
            $query .= "WHERE (`bgpPeerAdminStatus` = 'start' OR `bgpPeerAdminStatus` = 'running') AND `bgpPeerState` != 'established' ";
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query);
            foreach ($entries as $peer) {
                $peer_ip = strstr($peer['bgpPeerRemoteAddr'], ':') ? Net_IPv6::compress($peer['bgpPeerRemoteAddr']) : $peer['bgpPeerRemoteAddr'];
                $peer['wide'] = strstr($peer['bgpPeerRemoteAddr'], ':') ? TRUE : FALSE;
                $boxes[] = array('sev' => 75, 'class' => 'BGP Peer', 'event' => 'Down', 'device_link' => generate_device_link($peer, short_hostname($peer['hostname'])), 'entity_link' => $peer_ip, 'wide' => $peer['wide'], 'time' => formatUptime($peer['bgpPeerFsmEstablishedTime'], 'short-3'), 'location' => $device['location']);
            }
        }
    }
    // Return boxes array
    return $boxes;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:status.inc.php

示例3: unset

 } else {
     unset($peername);
 }
 // display overlib graphs
 $graph_type = 'bgp_updates';
 $local_daily_url = 'graph.php?id=' . $peer['bgpPeer_id'] . '&amp;type=' . $graph_type . '&amp;from=' . $config['time']['day'] . '&amp;to=' . $config['time']['now'] . '&amp;width=500&amp;height=150&&afi=ipv4&safi=unicast';
 if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) {
     $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']);
 } else {
     $peer_ip = $peer['bgpLocalAddr'];
 }
 $localaddresslink = "<span class=list-large><a href='device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\\'{$local_daily_url}\\'>', LEFT" . $config['overlib_defaults'] . ');" onmouseout="return nd();">' . $peer_ip . '</a></span>';
 $graph_type = 'bgp_updates';
 $peer_daily_url = 'graph.php?id=' . $peer['bgpPeer_id'] . '&amp;type=' . $graph_type . '&amp;from=' . $config['time']['day'] . '&amp;to=' . $config['time']['now'] . '&amp;width=500&amp;height=150';
 if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) {
     $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']);
 } else {
     $peer_ident = $peer['bgpPeerIdentifier'];
 }
 $peeraddresslink = "<span class=list-large><a href='device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\\'{$peer_daily_url}\\'>', LEFT" . $config['overlib_defaults'] . ');" onmouseout="return nd();">' . $peer_ident . '</a></span>';
 echo '<tr class="bgp"' . ($peer['alert'] ? ' bordercolor="#cc0000"' : '') . ($peer['disabled'] ? ' bordercolor="#cccccc"' : '') . '>';
 unset($sep);
 foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) {
     $afi = $afisafi['afi'];
     $safi = $afisafi['safi'];
     $this_afisafi = $afi . $safi;
     $peer['afi'] .= $sep . $afi . '.' . $safi;
     $sep = '<br />';
     $peer['afisafi'][$this_afisafi] = 1;
     // Build a list of valid AFI/SAFI for this peer
 }
开发者ID:n-st,项目名称:librenms,代码行数:31,代码来源:bgp.inc.php

示例4: gettext

 if ($_POST['network_subnet'] && !is_numeric($_POST['network_subnet'])) {
     $input_errors[] = gettext("A valid destination network bit count must be specified.");
 }
 if ($_POST['gateway'] && is_ipaddr($_POST['network'])) {
     if (!isset($a_gateways[$_POST['gateway']])) {
         $input_errors[] = gettext("A valid gateway must be specified.");
     }
     if (!validate_address_family($_POST['network'], lookup_gateway_ip_by_name($_POST['gateway']))) {
         $input_errors[] = gettext("The gateway '{$a_gateways[$_POST['gateway']]['gateway']}' is a different Address Family as network '{$_POST['network']}'.");
     }
 }
 /* check for overlaps */
 $current_targets = get_staticroutes(true);
 $new_targets = array();
 if (is_ipaddrv6($_POST['network'])) {
     $osn = Net_IPv6::compress(gen_subnetv6($_POST['network'], $_POST['network_subnet'])) . "/" . $_POST['network_subnet'];
     $new_targets[] = $osn;
 }
 if (is_ipaddr($_POST['network'])) {
     if ($_POST['network_subnet'] > 32) {
         $input_errors[] = gettext("A IPv4 subnet can not be over 32 bits.");
     } else {
         $osn = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
         $new_targets[] = $osn;
     }
 } elseif (is_alias($_POST['network'])) {
     $osn = $_POST['network'];
     foreach (filter_expand_alias_array($_POST['network']) as $tgt) {
         if (is_ipaddr($tgt)) {
             $tgt .= "/32";
         }
开发者ID:rdmenezes,项目名称:pfsense,代码行数:31,代码来源:system_routes_edit.php

示例5: calculateIpCalcResult

/**
 * ipCalc calculations
 */
function calculateIpCalcResult($cidr)
{
    /* first verify address type */
    $type = IdentifyAddress($cidr);
    /* IPv4 */
    if ($type == "IPv4") {
        $net = Net_IPv4::parseAddress($cidr);
        //set ip address type
        $out['Type'] = 'IPv4';
        //calculate network details
        $out['IP address'] = $net->ip;
        // 192.168.0.50
        $out['Network'] = $net->network;
        // 192.168.0.0
        $out['Broadcast'] = $net->broadcast;
        // 192.168.255.255
        $out['Subnet bitmask'] = $net->bitmask;
        // 16
        $out['Subnet netmask'] = $net->netmask;
        // 255.255.0.0
        $out['Subnet wildcard'] = long2ip(~ip2long($net->netmask));
        //0.0.255.255
        //calculate min/max IP address
        $out['Min host IP'] = long2ip(ip2long($out['Network']) + 1);
        $out['Max host IP'] = long2ip(ip2long($out['Broadcast']) - 1);
        $out['Number of hosts'] = ip2long($out['Broadcast']) - ip2long($out['Min host IP']);
        //subnet class
        $out['Subnet Class'] = checkIpv4AddressType($out['Network'], $out['Broadcast']);
        //if IP == subnet clear the Host fields
        if ($out['IP address'] == $out['Network']) {
            $out['IP address'] = "/";
        }
    } else {
        //set ip address type
        $out['Type'] = 'IPv6';
        //calculate network details
        /*         $out['Host address']              = Net_IPv6::removeNetmaskSpec ( $cidr );  */
        $out['Host address'] = $cidr;
        $out['Host address'] = Net_IPv6::compress($out['Host address'], 1);
        $out['Host address (uncompressed)'] = Net_IPv6::uncompress($out['Host address']);
        $mask = Net_IPv6::getNetmaskSpec($cidr);
        $subnet = Net_IPv6::getNetmask($cidr);
        $out['Subnet prefix'] = Net_IPv6::compress($subnet) . '/' . $mask;
        $out['Prefix length'] = Net_IPv6::getNetmaskSpec($cidr);
        // get reverse DNS entries
        $out['Host Reverse DNS'] = calculateReverseDNS6($out['Host address (uncompressed)']);
        $out['Subnet Reverse DNS'] = calculateReverseDNS6($subnet, $mask);
        //if IP == subnet clear the Host fields and Host Reverse DNS
        if ($out['Host address'] == $out['Subnet prefix']) {
            $out['Host address'] = '/';
            $out['Host address (uncompressed)'] = '/';
            unset($out['Host Reverse DNS']);
        }
        //min / max hosts
        $maxIp = gmp_strval(gmp_add(gmp_sub(gmp_pow(2, 128 - $mask), 1), ip2long6($subnet)));
        $out['Min host IP'] = long2ip6(gmp_strval(gmp_add(ip2long6($subnet), 1)));
        $out['Max host IP'] = long2ip6($maxIp);
        $out['Number of hosts'] = MaxHosts($mask, 1);
        //address type
        $out['Address type'] = Net_IPv6::getAddressType($cidr);
        $out['Address type'] = checkIpv6AddressType($out['Address type']);
    }
    /* return results */
    return $out;
}
开发者ID:retexica,项目名称:phpipam,代码行数:68,代码来源:functions-tools.php

示例6: print_arptable

/**
 * Display ARP/NDP table addresses.
 *
 * Display pages with ARP/NDP tables addresses from devices.
 *
 * @param array $vars
 * @return none
 *
 */
function print_arptable($vars)
{
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    $pageno = isset($vars['pageno']) && !empty($vars['pageno']) ? $vars['pageno'] : 1;
    $pagesize = isset($vars['pagesize']) && !empty($vars['pagesize']) ? $vars['pagesize'] : 10;
    $start = $pagesize * $pageno - $pagesize;
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= ' AND I.`device_id` = ?';
                    $param[] = $value;
                    break;
                case 'port':
                case 'port_id':
                    $where .= ' AND I.`port_id` = ?';
                    $param[] = $value;
                    break;
                case 'ip_version':
                    $where .= ' AND `ip_version` = ?';
                    $param[] = $value;
                    break;
                case 'address':
                    if (isset($vars['searchby']) && $vars['searchby'] == 'ip') {
                        $where .= ' AND `ip_address` LIKE ?';
                        $value = trim($value);
                        ///FIXME. Need another conversion ("2001:b08:b08" -> "2001:0b08:0b08") -- mike
                        if (Net_IPv6::checkIPv6($value)) {
                            $value = Net_IPv6::uncompress($value, true);
                        }
                        $param[] = '%' . $value . '%';
                    } else {
                        $where .= ' AND `mac_address` LIKE ?';
                        $param[] = '%' . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($value)) . '%';
                    }
                    break;
            }
        }
    }
    // Show ARP tables only for permitted ports
    $query_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    $query = 'FROM `ip_mac` AS M ';
    $query .= 'LEFT JOIN `ports` AS I ON I.`port_id` = M.`port_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(`mac_id`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY M.`mac_address`';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query ARP/NDP table addresses
    $entries = dbFetchRows($query, $param);
    // Query ARP/NDP table address count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE, 'port' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    if (!isset($vars['port']) || empty($vars['port']) || $vars['page'] == 'search') {
        $list['port'] = TRUE;
    }
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        $string .= '      <th>MAC Address</th>' . PHP_EOL;
        $string .= '      <th>IP Address</th>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        if ($list['port']) {
            $string .= '      <th>Interface</th>' . PHP_EOL;
        }
        $string .= '      <th>Remote Device</th>' . PHP_EOL;
        $string .= '      <th>Remote Interface</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        humanize_port($entry);
        $ip_version = $entry['ip_version'];
        $ip_address = $ip_version == 6 ? Net_IPv6::compress($entry['ip_address']) : $entry['ip_address'];
        $arp_host = dbFetchRow('SELECT * FROM `ipv' . $ip_version . '_addresses` AS A
                           LEFT JOIN `ports` AS I ON A.`port_id` = I.`port_id`
                           LEFT JOIN `devices` AS D ON D.`device_id` = I.`device_id`
                           WHERE A.`ipv' . $ip_version . '_address` = ?', array($ip_address));
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:arptable.inc.php

示例7: discover_process_ipv6

function discover_process_ipv6(&$valid, $ifIndex, $ipv6_address, $ipv6_prefixlen, $ipv6_origin, $context_name = '')
{
    global $device;
    $ipv6_network = Net_IPv6::getNetmask("{$ipv6_address}/{$ipv6_prefixlen}") . '/' . $ipv6_prefixlen;
    $ipv6_compressed = Net_IPv6::compress($ipv6_address);
    if (Net_IPv6::getAddressType($ipv6_address) == NET_IPV6_LOCAL_LINK) {
        // ignore link-locals (coming from IPV6-MIB)
        return;
    }
    if (dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifIndex` = ?', array($device['device_id'], $ifIndex)) != '0' && $ipv6_prefixlen > '0' && $ipv6_prefixlen < '129' && $ipv6_compressed != '::1') {
        $port_id = dbFetchCell('SELECT port_id FROM `ports` WHERE device_id = ? AND ifIndex = ?', array($device['device_id'], $ifIndex));
        if (dbFetchCell('SELECT COUNT(*) FROM `ipv6_networks` WHERE `ipv6_network` = ?', array($ipv6_network)) < '1') {
            dbInsert(array('ipv6_network' => $ipv6_network, 'context_name' => $context_name), 'ipv6_networks');
            echo 'N';
        } else {
            //Update Context
            dbUpdate(array('context_name' => $device['context_name']), 'ipv6_network', '`ipv6_network` = ?', array($ipv6_network));
            echo 'n';
        }
        $ipv6_network_id = dbFetchCell('SELECT `ipv6_network_id` FROM `ipv6_networks` WHERE `ipv6_network` = ? AND `context_name` = ?', array($ipv6_network, $context_name));
        if (dbFetchCell('SELECT COUNT(*) FROM `ipv6_addresses` WHERE `ipv6_address` = ? AND `ipv6_prefixlen` = ? AND `port_id` = ?', array($ipv6_address, $ipv6_prefixlen, $port_id)) == '0') {
            dbInsert(array('ipv6_address' => $ipv6_address, 'ipv6_compressed' => $ipv6_compressed, 'ipv6_prefixlen' => $ipv6_prefixlen, 'ipv6_origin' => $ipv6_origin, 'ipv6_network_id' => $ipv6_network_id, 'port_id' => $port_id, 'context_name' => $context_name), 'ipv6_addresses');
            echo '+';
        } else {
            //Update Context
            dbUpdate(array('context_name' => $device['context_name']), 'ipv6_address', '`ipv6_address` = ? AND `ipv6_prefixlen` = ? AND `port_id` = ?', array($ipv6_address, $ipv6_prefixlen, $port_id));
            echo '.';
        }
        $full_address = "{$ipv6_address}/{$ipv6_prefixlen}";
        $valid_address = $full_address . '-' . $port_id;
        $valid['ipv6'][$valid_address] = 1;
    }
    //end if
}
开发者ID:arrmo,项目名称:librenms,代码行数:34,代码来源:functions.inc.php

示例8: humanspeed

        if (!$mask) {
            $mask = "128";
        }
        if (!Net_IPv6::isInNetmask($interface['ipv6_address'], $addy, $mask)) {
            $ignore = 1;
        } else {
            $ignore = 0;
        }
    }
    if (!$ignore) {
        if (is_integer($row / 2)) {
            $row_colour = $list_colour_a;
        } else {
            $row_colour = $list_colour_b;
        }
        $speed = humanspeed($interface['ifSpeed']);
        $type = humanmedia($interface['ifType']);
        list($prefix, $length) = explode("/", $interface['ipv6_network']);
        if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
            $error_img = generateiflink($interface, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors);
        } else {
            $error_img = "";
        }
        if (interfacepermitted($interface['interface_id'])) {
            echo "<tr bgcolor={$row_colour}><td></td>\n          <td class=list-bold>" . generatedevicelink($interface) . "</td>\n          <td class=list-bold>" . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . " {$error_img}</td>\n          <td>" . Net_IPv6::compress($interface['ipv6_address']) . "/" . $length . "</td>\n          <td>" . $interface['ifAlias'] . "</td>\n        </tr>\n";
            $row++;
        }
    }
    unset($ignore);
}
echo "</table>";
开发者ID:kyrisu,项目名称:observernms,代码行数:31,代码来源:ipv6.php

示例9: print_arptable

/**
 * Display ARP/NDP table addresses.
 *
 * Display pages with ARP/NDP tables addresses from devices.
 *
 * @param array $vars
 * @return none
 *
 */
function print_arptable($vars)
{
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $pageno = $vars['pageno'];
    $pagesize = $vars['pagesize'];
    $start = $pagesize * $pageno - $pagesize;
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= generate_query_values($value, 'device_id');
                    break;
                case 'port':
                case 'port_id':
                    $where .= generate_query_values($value, 'I.port_id');
                    break;
                case 'ip_version':
                    $where .= generate_query_values($value, 'ip_version');
                    break;
                case 'address':
                    if (isset($vars['searchby']) && $vars['searchby'] == 'ip') {
                        $value = trim($value);
                        if (strpos($value, ':') !== FALSE) {
                            if (Net_IPv6::checkIPv6($value)) {
                                $value = Net_IPv6::uncompress($value, TRUE);
                            } else {
                                // FIXME. Need another conversion ("2001:b08:b08" -> "2001:0b08:0b08") -- mike
                            }
                        }
                        $where .= generate_query_values($value, 'ip_address', '%LIKE%');
                    } else {
                        // MAC Addresses
                        $value = str_replace(array(':', ' ', '-', '.', '0x'), '', $value);
                        $where .= generate_query_values($value, 'mac_address', '%LIKE%');
                    }
                    break;
            }
        }
    }
    if (isset($vars['sort'])) {
        switch ($vars['sort']) {
            case "port":
                $sort = " ORDER BY `I`.`port_label`";
                break;
            case "ip_version":
                $sort = " ORDER BY `ip_version`";
                break;
            case "ip":
            case "address":
                $sort = " ORDER BY `ip_address`";
                break;
            case "mac":
            default:
                $sort = " ORDER BY `mac_address`";
        }
    }
    // Show ARP tables only for permitted ports
    $query_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    $query = 'FROM `ip_mac` AS M ';
    $query .= 'LEFT JOIN `ports` AS I ON I.`port_id` = M.`port_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(`mac_id`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= $sort;
    $query .= " LIMIT {$start},{$pagesize}";
    // Query ARP/NDP table addresses
    $entries = dbFetchRows($query, $param);
    // Query ARP/NDP table address count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE, 'port' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    if (!isset($vars['port']) || empty($vars['port']) || $vars['page'] == 'search') {
        $list['port'] = TRUE;
    }
    $string = generate_box_open();
    $string .= '<table class="table  table-striped table-hover table-condensed">' . PHP_EOL;
    $cols = array('mac' => 'MAC Address', 'ip' => 'IP Address', 'device' => 'Device', 'port' => 'Port', '!remote_device' => 'Remote Device', '!remote_port' => 'Remote Port');
    if (!$list['device']) {
        unset($cols['device']);
    }
    if (!$list['port']) {
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:arptable.inc.php

示例10: do_input_validation

 do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
 if ($_POST['prefixrange_from'] && !is_ipaddrv6($_POST['prefixrange_from'])) {
     $input_errors[] = gettext("A valid prefix range must be specified.");
 }
 if ($_POST['prefixrange_to'] && !is_ipaddrv6($_POST['prefixrange_to'])) {
     $input_errors[] = gettext("A valid prefix range must be specified.");
 }
 if ($_POST['prefixrange_from'] && $_POST['prefixrange_to'] && $_POST['prefixrange_length']) {
     $netmask = Net_IPv6::getNetmask($_POST['prefixrange_from'], $_POST['prefixrange_length']);
     $netmask = Net_IPv6::compress($netmask);
     if ($netmask != Net_IPv6::compress(strtolower($_POST['prefixrange_from']))) {
         $input_errors[] = sprintf(gettext("Prefix Delegation From address is not a valid IPv6 Netmask for %s"), $netmask . '/' . $_POST['prefixrange_length']);
     }
     $netmask = Net_IPv6::getNetmask($_POST['prefixrange_to'], $_POST['prefixrange_length']);
     $netmask = Net_IPv6::compress($netmask);
     if ($netmask != Net_IPv6::compress(strtolower($_POST['prefixrange_to']))) {
         $input_errors[] = sprintf(gettext("Prefix Delegation To address is not a valid IPv6 Netmask for %s"), $netmask . '/' . $_POST['prefixrange_length']);
     }
 }
 $range_from_to_ok = true;
 if ($_POST['range_from']) {
     if (!is_ipaddrv6($_POST['range_from'])) {
         $input_errors[] = gettext("A valid range must be specified.");
         $range_from_to_ok = false;
     } elseif ($config['interfaces'][$if]['ipaddrv6'] == 'track6' && !Net_IPv6::isInNetmask($_POST['range_from'], '::', $ifcfgsn)) {
         $input_errors[] = sprintf(gettext("The prefix (upper %s bits) must be zero.  Use the form %s"), $ifcfgsn, $str_help_mask);
         $range_from_to_ok = false;
     }
 }
 if ($_POST['range_to']) {
     if (!is_ipaddrv6($_POST['range_to'])) {
开发者ID:NewEraCracker,项目名称:pfsense,代码行数:31,代码来源:services_dhcpv6.php

示例11: verifyCidr

/**
 * verify ip address /mask 10.10.10.10./24 - CIDR 
 *
 * if subnet == 0 we dont check if IP is subnet -> needed for ipCalc
 */
function verifyCidr($cidr, $issubnet = 1)
{
    /* split it to network and subnet */
    $temp = explode("/", $cidr);
    $network = $temp[0];
    $netmask = $temp[1];
    //if one part is missing die
    if (empty($network) || empty($netmask)) {
        $errors[] = _("Invalid CIDR format!");
    }
    /* Identify address type */
    $type = IdentifyAddress($network);
    /* IPv4 verification */
    if ($type == 'IPv4') {
        require_once 'PEAR/Net/IPv4.php';
        $Net_IPv4 = new Net_IPv4();
        if ($net = $Net_IPv4->parseAddress($cidr)) {
            //validate IP
            if (!$Net_IPv4->validateIP($net->ip)) {
                $errors[] = _("Invalid IP address!");
            } elseif ($net->network != $net->ip && $issubnet == 1) {
                $errors[] = _("IP address cannot be subnet! (Consider using") . " " . $net->network . ")";
            } elseif (!$Net_IPv4->validateNetmask($net->netmask)) {
                $errors[] = _('Invalid netmask') . ' ' . $net->netmask;
            }
        } else {
            $errors[] = _('Invalid CIDR format!');
        }
    } else {
        require_once 'PEAR/Net/IPv6.php';
        $Net_IPv6 = new Net_IPv6();
        //validate IPv6
        if (!$Net_IPv6->checkIPv6($cidr)) {
            $errors[] = _("Invalid IPv6 address!");
        } else {
            //validate subnet
            $subnet = $Net_IPv6->getNetmask($cidr);
            $subnet = $Net_IPv6->compress($subnet);
            //get subnet part
            $subnetParse = explode("/", $cidr);
            $subnetMask = $subnetParse[1];
            $subnetNet = $subnetParse[0];
            if ($subnetNet != $subnet && $issubnet == 1) {
                $errors[] = _("IP address cannot be subnet! (Consider using") . " " . $subnet . "/" . $subnetMask . ")";
            }
        }
    }
    /* return array of errors */
    return $errors;
}
开发者ID:retexica,项目名称:phpipam,代码行数:55,代码来源:functions-network.php

示例12: humanize_bgp

function humanize_bgp(&$peer)
{
    // Exit if already humanized
    if ($peer['humanized']) {
        return;
    }
    // Set colours and classes based on the status of the peer
    if ($peer['bgpPeerAdminStatus'] == 'stop' || $peer['bgpPeerAdminStatus'] == 'halted') {
        // Peer is disabled, set row to warning and text classes to muted.
        $peer['table_tab_colour'] = "#aaaaaa";
        $peer['html_row_class'] = "warning";
        $peer['state_class'] = "muted";
        $peer['admin_class'] = "muted";
        $peer['alert'] = 0;
        $peer['disabled'] = 1;
    } elseif ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") {
        // Peer is enabled, set state green and check other things
        $peer['admin_class'] = "text-success";
        if ($peer['bgpPeerState'] == "established") {
            // Peer is up, set colour to blue and disable row class
            $peer['state_class'] = "text-success";
            $peer['table_tab_colour'] = "#194B7F";
            $peer['html_row_class'] = "";
        } else {
            // Peer is down, set colour to red and row class to error.
            $peer['state_class'] = "text-danger";
            $peer['table_tab_colour'] = "#cc0000";
            $peer['html_row_class'] = "error";
        }
    }
    // Set text and colour if peer is same AS, private AS or external.
    if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) {
        $peer['peer_type'] = "<span style='color: #00f;'>iBGP</span>";
    } elseif ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') {
        $peer['peer_type'] = "<span style='color: #f00;'>Priv eBGP</span>";
    } else {
        $peer['peer_type'] = "<span style='color: #0a0;'>eBGP</span>";
    }
    // Format (compress) the local/remote IPs if they're IPv6
    $peer['human_localip'] = strstr($peer['bgpPeerLocalAddr'], ':') ? Net_IPv6::compress($peer['bgpPeerLocalAddr']) : $peer['bgpPeerLocalAddr'];
    $peer['human_remoteip'] = strstr($peer['bgpPeerRemoteAddr'], ':') ? Net_IPv6::compress($peer['bgpPeerRemoteAddr']) : $peer['bgpPeerRemoteAddr'];
    // Set humanized entry in the array so we can tell later
    $peer['humanized'] = TRUE;
}
开发者ID:skive,项目名称:observium,代码行数:44,代码来源:rewrites.inc.php

示例13: discover_process_ipv6

function discover_process_ipv6(&$valid, $ifIndex, $ipv6_address, $ipv6_prefixlen, $ipv6_origin)
{
    global $device, $config;
    $ipv6_network = Net_IPv6::getNetmask("{$ipv6_address}/{$ipv6_prefixlen}") . '/' . $ipv6_prefixlen;
    $ipv6_compressed = Net_IPv6::compress($ipv6_address);
    if (Net_IPv6::getAddressType($ipv6_address) == NET_IPV6_LOCAL_LINK) {
        # ignore link-locals (coming from IPV6-MIB)
        return;
    }
    if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex)) != '0' && $ipv6_prefixlen > '0' && $ipv6_prefixlen < '129' && $ipv6_compressed != '::1') {
        $port_id = dbFetchCell("SELECT port_id FROM `ports` WHERE device_id = ? AND ifIndex = ?", array($device['device_id'], $ifIndex));
        if (dbFetchCell("SELECT COUNT(*) FROM `ipv6_networks` WHERE `ipv6_network` = ?", array($ipv6_network)) < '1') {
            dbInsert(array('ipv6_network' => $ipv6_network), 'ipv6_networks');
            echo "N";
        }
        // Below looks like a duplicate of the above FIXME
        if (dbFetchCell("SELECT COUNT(*) FROM `ipv6_networks` WHERE `ipv6_network` = ?", array($ipv6_network)) < '1') {
            dbInsert(array('ipv6_network' => $ipv6_network), 'ipv6_networks');
            echo "N";
        }
        $ipv6_network_id = dbFetchCell("SELECT `ipv6_network_id` FROM `ipv6_networks` WHERE `ipv6_network` = ?", array($ipv6_network));
        if (dbFetchCell("SELECT COUNT(*) FROM `ipv6_addresses` WHERE `ipv6_address` = ? AND `ipv6_prefixlen` = ? AND `port_id` = ?", array($ipv6_address, $ipv6_prefixlen, $port_id)) == '0') {
            dbInsert(array('ipv6_address' => $ipv6_address, 'ipv6_compressed' => $ipv6_compressed, 'ipv6_prefixlen' => $ipv6_prefixlen, 'ipv6_origin' => $ipv6_origin, 'ipv6_network_id' => $ipv6_network_id, 'port_id' => $port_id), 'ipv6_addresses');
            echo "+";
        } else {
            echo ".";
        }
        $full_address = "{$ipv6_address}/{$ipv6_prefixlen}";
        $valid_address = $full_address . "-" . $port_id;
        $valid['ipv6'][$valid_address] = 1;
    }
}
开发者ID:REAP720801,项目名称:librenms,代码行数:32,代码来源:functions.inc.php

示例14: print_addresses


//.........这里部分代码省略.........
        //$query_netscaler_count = str_replace(array('vsvr_ip', '0.0.0.0'), array('vsvr_ipv6', '0:0:0:0:0:0:0:0'), $query_netscaler_count);
    }
    $entries = dbFetchRows($query_netscaler, $param_netscaler);
    // Rewrite netscaler addresses
    foreach ($entries as $entry) {
        $ip_address = $address_type == 'ipv4' ? $entry['vsvr_ip'] : $entry['vsvr_' . $address_type];
        $ip_network = $address_type == 'ipv4' ? $entry['vsvr_ip'] . '/32' : $entry['vsvr_' . $address_type] . '/128';
        $ip_array[] = array('type' => 'netscaler_vsvr', 'device_id' => $entry['device_id'], 'hostname' => $entry['hostname'], 'vsvr_id' => $entry['vsvr_id'], 'vsvr_label' => $entry['vsvr_label'], 'ifAlias' => 'Netscaler: ' . $entry['vsvr_type'] . '/' . $entry['vsvr_entitytype'], $address_type . '_address' => $ip_address, $address_type . '_network' => $ip_network);
    }
    //print_message($query_netscaler_count);
    $query = 'FROM `ip_addresses` AS A ';
    $query .= 'LEFT JOIN `ports`   AS I ON I.`port_id`   = A.`port_id` ';
    $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
    $query .= 'LEFT JOIN `ip_networks` AS N ON N.`ip_network_id` = A.`ip_network_id` ';
    $query .= $where . $query_port_permitted;
    //$query_count = 'SELECT COUNT(`ip_address_id`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY A.`ip_address`';
    if ($ip_valid) {
        $pagination = FALSE;
    }
    // Override by address type
    $query = str_replace(array('ip_address', 'ip_network'), array($address_type . '_address', $address_type . '_network'), $query);
    //$query_count = str_replace(array('ip_address', 'ip_network'), array($address_type.'_address', $address_type.'_network'), $query_count);
    // Query addresses
    $entries = dbFetchRows($query, $param);
    $ip_array = array_merge($ip_array, $entries);
    $ip_array = array_sort($ip_array, $address_type . '_address');
    // Query address count
    //if ($pagination) { $count = dbFetchCell($query_count, $param); }
    if ($pagination) {
        $count = count($ip_array);
        $ip_array = array_slice($ip_array, $start, $pagesize);
    }
    $list = array('device' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    $string = generate_box_open($vars['header']);
    $string .= '<table class="' . OBS_CLASS_TABLE_STRIPED . '">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        $string .= '      <th>Interface</th>' . PHP_EOL;
        $string .= '      <th>Address</th>' . PHP_EOL;
        $string .= '      <th>Description</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($ip_array as $entry) {
        $address_show = TRUE;
        if ($ip_valid) {
            // If address not in specified network, don't show entry.
            if ($address_type === 'ipv4') {
                $address_show = Net_IPv4::ipInNetwork($entry[$address_type . '_address'], $addr . '/' . $mask);
            } else {
                $address_show = Net_IPv6::isInNetmask($entry[$address_type . '_address'], $addr, $mask);
            }
        }
        if ($address_show) {
            list($prefix, $length) = explode('/', $entry[$address_type . '_network']);
            if (port_permitted($entry['port_id']) || $entry['type'] == 'netscaler_vsvr') {
                if ($entry['type'] == 'netscaler_vsvr') {
                    $entity_link = generate_entity_link($entry['type'], $entry);
                } else {
                    humanize_port($entry);
                    if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) {
                        $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors');
                    }
                    $entity_link = generate_port_link($entry, $entry['port_label_short']) . ' ' . $port_error;
                }
                $device_link = generate_device_link($entry);
                $string .= '  <tr>' . PHP_EOL;
                if ($list['device']) {
                    $string .= '    <td class="entity" style="white-space: nowrap">' . $device_link . '</td>' . PHP_EOL;
                }
                $string .= '    <td class="entity">' . $entity_link . '</td>' . PHP_EOL;
                if ($address_type === 'ipv6') {
                    $entry[$address_type . '_address'] = Net_IPv6::compress($entry[$address_type . '_address']);
                }
                $string .= '    <td>' . generate_popup_link('ip', $entry[$address_type . '_address'] . '/' . $length) . '</td>' . PHP_EOL;
                $string .= '    <td>' . $entry['ifAlias'] . '</td>' . PHP_EOL;
                $string .= '  </tr>' . PHP_EOL;
            }
        }
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    $string .= generate_box_close();
    // Print pagination header
    if ($pagination) {
        $string = pagination($vars, $count) . $string . pagination($vars, $count);
    }
    // Print addresses
    echo $string;
}
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:addresses.inc.php

示例15: trim

         }
         $peer_data = trim(`{$peer_cmd}`);
         list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
         if ($debug) {
             echo "State = {$bgpPeerState} - AdminStatus: {$bgpPeerAdminStatus}\n";
         }
         $bgpLocalAddr = str_replace('"', '', str_replace(' ', '', $bgpLocalAddr));
         if ($bgpLocalAddr == "00000000000000000000000000000000") {
             $bgpLocalAddr = '';
             # Unknown?
         } else {
             $bgpLocalAddr = strtolower($bgpLocalAddr);
             for ($i = 0; $i < 32; $i += 4) {
                 $bgpLocalAddr6[] = substr($bgpLocalAddr, $i, 4);
             }
             $bgpLocalAddr = Net_IPv6::compress(implode(':', $bgpLocalAddr6));
             unset($bgpLocalAddr6);
         }
     }
 }
 if ($bgpPeerFsmEstablishedTime) {
     if ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState']) {
         if ($device['sysContact']) {
             $email = $device['sysContact'];
         } else {
             $email = $config['email_default'];
         }
         if ($peer['bgpPeerState'] == $bgpPeerState) {
             mail($email, "BGP Session flapped: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session flapped " . formatUptime($bgpPeerFsmEstablishedTime) . " ago.\n\nHostname : " . $device['hostname'] . "\nPeer IP  : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' (' . $peer['astext'] . ')', $config['email_headers']);
             eventlog('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id']);
         } else {
开发者ID:kyrisu,项目名称:observernms,代码行数:31,代码来源:bgpPeer.inc.php


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