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


PHP short_hostname函数代码示例

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


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

示例1: foreach

 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Generate a list of ports and then call the multi_bits grapher to generate from the list
$i = 0;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ? AND D.device_id = I.device_id", array($vars['id'])) as $port) {
    $rrd_filename = get_port_rrdfilename($port, NULL, TRUE);
    if (is_file($rrd_filename)) {
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = $port['hostname'] . "-" . $port['ifDescr'];
        $rrd_list[$i]['descr_in'] = short_hostname($port['hostname']);
        $rrd_list[$i]['descr_out'] = short_ifname($port['ifDescr'], NULL, FALSE);
        // Options sets for skip htmlentities
        $i++;
    }
}
$units = 'b';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = "8";
$colours_out = 'blues';
$nototal = 1;
$ds_in = "INOCTETS";
$ds_out = "OUTOCTETS";
include "includes/graphs/generic_multi_bits_separated.inc.php";
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:bits.inc.php

示例2: elseif

            if ($port_id) {
                $vars['id'] = $port_id;
            }
        } elseif (!empty($vars['ifalias'])) {
            // Get port by ifAlias
            $port_id = get_port_id_by_ifAlias($device['device_id'], $vars['ifalias']);
            if ($port_id) {
                $vars['id'] = $port_id;
            }
        }
    } elseif (!empty($vars['circuit'])) {
        // Get port by circuit id
        $port_id = get_port_id_by_customer(array('circuit' => $vars['circuit']));
        if ($port_id) {
            $vars['id'] = $port_id;
        }
    }
}
if (is_numeric($vars['id']) && ($auth || port_permitted($vars['id']))) {
    $port = get_port_by_id($vars['id']);
    $device = device_by_id_cache($port['device_id']);
    $title = generate_device_link($device);
    $title .= " :: Port  <b>" . generate_port_link($port) . "</b>";
    $title_array = array();
    $title_array[] = array('text' => $device['hostname'], 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'])));
    $title_array[] = array('text' => 'Ports', 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'ports')));
    $title_array[] = array('text' => rewrite_ifname($port['label']), 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $port['port_id'])));
    $graph_title = short_hostname($device['hostname']) . " :: " . strtolower(short_ifname($port['ifDescr'], NULL, FALSE));
    $auth = TRUE;
    $rrd_filename = get_port_rrdfilename($port, NULL, TRUE);
}
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:auth.inc.php

示例3: get_status_array

function get_status_array($status)
{
    // Mike: I know that there are duplicated variables, but later will remove global
    global $config, $cache;
    $max_interval = filter_var($status['max']['interval'], FILTER_VALIDATE_INT, array('options' => array('default' => 24, 'min_range' => 1)));
    $max_count = filter_var($status['max']['count'], FILTER_VALIDATE_INT, array('options' => array('default' => 200, 'min_range' => 1)));
    $query_device_permitted = generate_query_permitted(array('device'), array('device_table' => 'D', 'hide_ignored' => TRUE));
    $query_port_permitted = generate_query_permitted(array('port'), array('port_table' => 'I', 'hide_ignored' => TRUE));
    // Show Device Status
    if ($status['devices']) {
        $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 ';
            // Since reboot event more complicated than just device uptime less than some time
            //$query .= ' WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`uptime` < ' . $config['uptime_warning'];
            $query .= ' WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`last_rebooted` > ?';
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query, array($config['time']['now'] - $config['uptime_warning'] - 10));
            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['neighbours']) {
        $status['neighbours'] = $status['neighbours'] && !$status['ports'];
        // Disable 'neighbours' if 'ports' already enabled
        $query = 'SELECT * FROM `ports` AS I ';
        if ($status['neighbours']) {
            $query .= 'INNER JOIN `neighbours` as L ON I.`port_id` = L.`port_id` ';
        }
        $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
        $query .= "WHERE D.`status` = 1 AND D.ignore = 0 AND I.ignore = 0 AND I.deleted = 0 AND I.`ifAdminStatus` = 'up' AND (I.`ifOperStatus` = 'lowerLayerDown' OR I.`ifOperStatus` = 'down') ";
        if ($status['neighbours']) {
            $query .= ' AND L.`active` = 1 ';
        }
        $query .= $query_port_permitted;
        $query .= ' AND I.`ifLastChange` >= DATE_SUB(NOW(), INTERVAL ' . $max_interval . ' HOUR) ';
        if ($status['neighbours']) {
            $query .= 'GROUP BY L.`port_id` ';
        }
        $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['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) {
            if (in_array($port_id, $cache['ports']['ignored'])) {
                continue;
            }
            // Skip ignored ports
            $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['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']) {
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:status.inc.php

示例4: generate_port_row

function generate_port_row($port, $vars = array())
{
    global $config, $cache;
    $device = device_by_id_cache($port['device_id']);
    humanize_port($port);
    if (!isset($vars['view'])) {
        $vars['view'] = "basic";
    }
    // Populate $port_adsl if the port has ADSL-MIB data
    if (!isset($cache['ports_option']['ports_adsl']) || in_array($port['port_id'], $cache['ports_option']['ports_adsl'])) {
        $port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id']));
    }
    // Populate $port['tags'] with various tags to identify port statuses and features
    // Port Errors
    if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) {
        $port['tags'] .= generate_port_link($port, '<span class="label label-important">Errors</span>', 'port_errors');
    }
    // Port Deleted
    if ($port['deleted'] == '1') {
        $port['tags'] .= '<a href="' . generate_url(array('page' => 'deleted-ports')) . '"><span class="label label-important">Deleted</span></a>';
    }
    // Port CBQoS
    if (isset($cache['ports_option']['ports_cbqos'])) {
        if (in_array($port['port_id'], $cache['ports_option']['ports_cbqos'])) {
            $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
        }
    } else {
        if (dbFetchCell("SELECT COUNT(*) FROM `ports_cbqos` WHERE `port_id` = ?", array($port['port_id']))) {
            $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
        }
    }
    // Port MAC Accounting
    if (isset($cache['ports_option']['mac_accounting'])) {
        if (in_array($port['port_id'], $cache['ports_option']['mac_accounting'])) {
            $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>';
        }
    } else {
        if (dbFetchCell("SELECT COUNT(*) FROM `mac_accounting` WHERE `port_id` = ?", array($port['port_id']))) {
            $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>';
        }
    }
    // Populated formatted versions of port rates.
    $port['bps_in'] = formatRates($port['ifInOctets_rate'] * 8);
    $port['bps_out'] = formatRates($port['ifOutOctets_rate'] * 8);
    $port['pps_in'] = format_si($port['ifInUcastPkts_rate']) . "pps";
    $port['pps_out'] = format_si($port['ifOutUcastPkts_rate']) . "pps";
    $string = '';
    if ($vars['view'] == "basic" || $vars['view'] == "graphs") {
        $table_cols = '8';
        $string .= '<tr class="' . $port['row_class'] . '">
            <td class="state-marker"></td>
            <td style="width: 1px;"></td>';
        if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
            $table_cols++;
            // Increment table columns by one to make sure graph line draws correctly
            $string .= '    <td style="width: 200px;"><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'], "20")) . '</span><br />
                <span class="em">' . escape_html(truncate($port['location'], 32, "")) . '</span></td>';
        }
        $string .= '    <td><span class="entity">' . generate_port_link($port, rewrite_ifname($port['port_label'])) . ' ' . $port['tags'] . '</span><br />
                <span class="em">' . escape_html(truncate($port['ifAlias'], 50, '')) . '</span></td>' . '<td style="width: 110px;"> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i>  <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br /></td>' . '<td style="width: 90px;"> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i>  <span class="small" style="' . $port['bps_in_style'] . '">' . $port['ifInOctets_perc'] . '%</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . $port['ifOutOctets_perc'] . '%</span><br /></td>' . '<td style="width: 110px;"><i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i>  <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span></td>' . '<td style="width: 110px;"><small>' . $port['human_speed'] . '<br />' . $port['ifMtu'] . '</small></td>
            <td ><small>' . $port['human_type'] . '<br />' . $port['human_mac'] . '</small></td>
          </tr>';
    } else {
        if ($vars['view'] == "details" || $vars['view'] == "detail") {
            $table_cols = '9';
            $string .= '<tr class="' . $port['row_class'] . '"';
            if ($vars['tab'] != "port") {
                $string .= ' onclick="openLink(\'' . generate_port_url($port) . '\')" style="cursor: pointer;"';
            }
            $string .= '>';
            $string .= '         <td class="state-marker"></td>
         <td style="width: 1px;"></td>';
            if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
                $table_cols++;
                // Increment table columns by one to make sure graph line draws correctly
                $string .= '    <td width="200"><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'], "20")) . '</span><br />
                <span class="em">' . escape_html(truncate($port['location'], 32, "")) . '</span></td>';
            }
            $string .= '
         <td style="min-width: 250px;">';
            $string .= '        <span class="entity-title">
              ' . generate_port_link($port) . ' ' . $port['tags'] . '
           </span><br /><span class="small">' . escape_html($port['ifAlias']) . '</span>';
            if ($port['ifAlias']) {
                $string .= '<br />';
            }
            unset($break);
            if (!isset($cache['ports_option']['ipv4_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv4_addresses'])) {
                foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip) {
                    $string .= $break . generate_popup_link('ip', $ip['ipv4_address'] . '/' . $ip['ipv4_prefixlen'], NULL, 'small');
                    $break = "<br />";
                }
            }
            if (!isset($cache['ports_option']['ipv6_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv6_addresses'])) {
                foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip6) {
                    $string .= $break . generate_popup_link('ip', $ip6['ipv6_address'] . '/' . $ip6['ipv6_prefixlen'], NULL, 'small');
                    $break = "<br />";
                }
            }
            //$string .= '</span>';
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:port.inc.php

示例5: print_events

/**
 * Display events.
 *
 * Display pages with device/port/system events on some formats.
 * Examples:
 * print_events() - display last 10 events from all devices
 * print_events(array('pagesize' => 99)) - display last 99 events from all device
 * print_events(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 events from page 3 with pagination header
 * print_events(array('pagesize' => 10, 'device' = 4)) - display last 10 events for device_id 4
 * print_events(array('short' => TRUE)) - show small block with last events
 *
 * @param array $vars
 * @return none
 *
 */
function print_events($vars)
{
    // Get events array
    $events = get_events_array($vars);
    if (!$events['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No eventlog entries found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'port' => FALSE);
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'eventlog') {
            $list['device'] = TRUE;
        }
        if ($events['short'] || !isset($vars['port']) || empty($vars['port'])) {
            $list['port'] = TRUE;
        }
        $string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$events['short']) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th>Date</th>' . PHP_EOL;
            if ($list['device']) {
                $string .= '      <th>Device</th>' . PHP_EOL;
            }
            if ($list['port']) {
                $string .= '      <th>Entity</th>' . PHP_EOL;
            }
            $string .= '      <th>Message</th>' . PHP_EOL;
            $string .= '    </tr>' . PHP_EOL;
            $string .= '  </thead>' . PHP_EOL;
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($events['entries'] as $entry) {
            $icon = geteventicon($entry['message']);
            if ($icon) {
                $icon = '<img src="images/16/' . $icon . '" />';
            }
            $string .= '  <tr>' . PHP_EOL;
            if ($events['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td style="width: 160px">';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['port']) {
                if ($entry['type'] == 'port') {
                    $this_if = get_port_by_id_cache($entry['reference']);
                    $entry['link'] = '<span class="entity">' . generate_port_link($this_if, short_ifname($this_if['label'])) . '</span>';
                } else {
                    $entry['link'] = ucfirst($entry['type']);
                }
                if (!$events['short']) {
                    $string .= '    <td>' . $entry['link'] . '</td>' . PHP_EOL;
                }
            }
            if ($events['short']) {
                $string .= '    <td class="syslog">' . $entry['link'] . ' ';
            } else {
                $string .= '    <td>';
            }
            $string .= htmlspecialchars($entry['message']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        // Print pagination header
        if ($events['pagination_html']) {
            $string = $events['pagination_html'] . $string . $events['pagination_html'];
        }
        // Print events
        echo $string;
    }
}
开发者ID:skive,项目名称:observium,代码行数:95,代码来源:events.inc.php

示例6: print_logalert_log

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function print_logalert_log($vars)
{
    global $config;
    foreach (dbFetchRows("SELECT * FROM `syslog_rules` ORDER BY `la_name`") as $la) {
        $syslog_rules[$la['la_id']] = $la;
    }
    $entries = get_logalert_log($vars);
    if (!$entries['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No logging alert entries found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE);
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'alert_log') {
            $list['device'] = TRUE;
        }
        if (!isset($vars['la_id']) || empty($vars['la_id'])) {
            $list['la_id'] = TRUE;
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="table table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$entries['short']) {
            $cols = array();
            $cols[] = array(NULL, 'class="state-marker"');
            $cols['date'] = array('Date', 'style="width: 140px"');
            if ($list['device']) {
                $cols['device'] = array('Device', 'style="width: 150px;"');
            }
            if ($list['la_id']) {
                $cols['la_id'] = array('Alert Rule', 'style="width: 150px;"');
            }
            $cols[] = array('Program', 'style="width: 80px"');
            $cols[] = 'Message';
            $cols[] = array('Notified', 'style="width: 40px"');
            $string .= get_table_header($cols);
            // , $vars); // Actually sorting is disabled now
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($entries['entries'] as $entry) {
            $string .= '  <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
            $string .= '<td class="state-marker"></td>' . PHP_EOL;
            if ($entries['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= generate_tooltip_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td>';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'alertlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['la_id']) {
                $string .= '<td><strong><a href="' . generate_url(array('page' => 'syslog_rules', 'la_id' => $entry['la_id'])) . '">' . (is_array($syslog_rules[$entry['la_id']]) ? $syslog_rules[$entry['la_id']]['la_name'] : 'Rule Deleted') . '</td>' . PHP_EOL;
            }
            $string .= '<td>' . (strlen($entry['program']) ? '<span class="label">' . $entry['program'] . '</span> ' : '') . '</td>' . PHP_EOL;
            $string .= '<td>' . escape_html($entry['message']) . '</td>' . PHP_EOL;
            if (!$vars['short']) {
                //$string .= '<td>' . escape_html($entry['log_type']) . '</td>' . PHP_EOL;
                $string .= '<td style="text-align: right">' . ($entry['notified'] == '1' ? '<span class="label label-success">YES</span>' : ($entry['notified'] == '-1' ? '<span class="label label-suppressed">NO</span>' : '<span class="label">NO</span>')) . '</td>' . PHP_EOL;
            }
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
    }
    // Print pagination header
    if ($entries['pagination_html']) {
        $string = $entries['pagination_html'] . $string . $entries['pagination_html'];
    }
    // Print events
    echo $string;
}
开发者ID:Natolumin,项目名称:observium,代码行数:86,代码来源:logalert.inc.php

示例7: get_status_array

function get_status_array($status)
{
    // Mike: I know that there are duplicated variables, but later will remove global
    global $config, $cache;
    $max_interval = filter_var($status['max']['interval'], FILTER_VALIDATE_INT, array('options' => array('default' => 24, 'min_range' => 1)));
    $max_count = filter_var($status['max']['count'], FILTER_VALIDATE_INT, array('options' => array('default' => 200, 'min_range' => 1)));
    $query_device_permitted = generate_query_permitted(array('device'), array('device_table' => 'D'));
    $query_port_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    // Show Device Status
    if ($status['devices']) {
        $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);
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:status.inc.php

示例8: print_pseudowires

/**
 * Display pseudowires.
 *
 * Display pages with device pseudowires in some formats.
 * Examples:
 * print_pseudowires() - display all pseudowires from all devices
 * print_pseudowires(array('pagesize' => 99)) - display 99 pseudowires from all device
 * print_pseudowires(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 pseudowires from page 3 with pagination header
 * print_pseudowires(array('pagesize' => 10, 'device' = 4)) - display 10 pseudowires for device_id 4
 *
 * @param array $vars
 * @return none
 *
 */
function print_pseudowires($vars)
{
    // Get pseudowires array
    $events = get_pseudowires_array($vars);
    if (!$events['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No pseudowires found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE);
        if ($vars['page'] != 'device') {
            $list['device'] = TRUE;
        }
        if (in_array($vars['graph'], array('bits', 'upkts', 'nupkts', 'pktsize', 'percent', 'errors', 'etherlike', 'fdb_count'))) {
            $graph_types = array($vars['graph']);
        } else {
            $graph_types = array('bits', 'upkts', 'errors');
        }
        $string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
        $cols = array('id' => 'PW ID', 'type' => array('Type', 'style="width: 5%;"'), 'device_a' => 'Local Device', 'port_a' => 'Local Port', 'NONE' => NULL, 'device_b' => 'Remote Device', 'port_b' => 'Remote Port');
        if (!$list['device']) {
            unset($cols['device_a']);
        }
        $string .= get_table_header($cols);
        //, $vars); // Currently sorting is not available
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($events['entries'] as $entry) {
            $string .= '  <tr>' . PHP_EOL;
            $string .= '    <td style="font-size: 18px; padding: 4px; width: 5%;">' . $entry['pwID'] . '</td>' . PHP_EOL;
            $string .= '    <td>' . strtoupper($entry['pwPsnType']) . '<br />' . nicecase($entry['pwType']) . '</td>' . PHP_EOL;
            if ($list['device']) {
                $local_dev = device_by_id_cache($entry['device_id']);
                $string .= '    <td class="entity">' . generate_device_link($local_dev, short_hostname($local_dev['hostname']), array('tab' => 'pseudowires')) . '</td>' . PHP_EOL;
            }
            $local_if = get_port_by_id_cache($entry['port_id']);
            $string .= '    <td class="entity">' . generate_port_link($local_if) . '<br />' . $local_if['ifAlias'];
            if ($vars['view'] == "minigraphs") {
                $string .= '<br />';
                if ($local_if) {
                    $local_if['width'] = "150";
                    $local_if['height'] = "30";
                    $local_if['from'] = $GLOBALS['config']['time']['day'];
                    $local_if['to'] = $GLOBALS['config']['time']['now'];
                    foreach ($graph_types as $graph_type) {
                        $local_if['graph_type'] = "port_" . $graph_type;
                        $string .= generate_port_thumbnail($local_if, FALSE);
                    }
                }
            }
            $string .= '</td>' . PHP_EOL;
            $string .= '    <td style="width: 3%;"><i class="oicon-arrow_right"></i></td>' . PHP_EOL;
            if (is_numeric($entry['peer_port_id'])) {
                $peer_if = get_port_by_id_cache($entry['peer_port_id']);
                $peer_dev = device_by_id_cache($peer_if['device_id']);
                $string .= '    <td class="entity">' . generate_device_link($peer_dev, short_hostname($peer_dev['hostname']), array('tab' => 'pseudowires')) . '</br>' . $entry['peer_addr'] . '</td>' . PHP_EOL;
                $string .= '    <td class="entity">' . generate_port_link($peer_if) . '<br />' . $peer_if['ifAlias'];
                if ($vars['view'] == "minigraphs") {
                    $string .= '<br />';
                    if ($peer_if) {
                        $peer_if['width'] = "150";
                        $peer_if['height'] = "30";
                        $peer_if['from'] = $GLOBALS['config']['time']['day'];
                        $peer_if['to'] = $GLOBALS['config']['time']['now'];
                        foreach ($graph_types as $graph_type) {
                            $peer_if['graph_type'] = "port_" . $graph_type;
                            $string .= generate_port_thumbnail($peer_if, FALSE);
                        }
                    }
                }
                $string .= '</td>' . PHP_EOL;
            } else {
                // Show only peer address (and PTR name)
                $string .= '    <td class="entity">' . $entry['peer_rdns'] . '<br />' . $entry['peer_addr'] . '</td>' . PHP_EOL;
                $string .= '    <td class="entity"><br />' . $entry['pwRemoteIfString'] . '</td>' . PHP_EOL;
            }
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        // Print pagination header
        if ($events['pagination_html']) {
            $string = $events['pagination_html'] . $string . $events['pagination_html'];
        }
        // Print
        echo $string;
    }
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:100,代码来源:pseudowires.inc.php

示例9: print_alert_log


//.........这里部分代码省略.........
            $cols = array();
            $cols[] = array(NULL, 'class="state-marker"');
            $cols['date'] = array('Date', 'style="width: 160px"');
            if ($list['device']) {
                $cols['device'] = 'Device';
            }
            if ($list['alert_test_id']) {
                $cols['alert_test_id'] = 'Alert Check';
            }
            if ($list['entity']) {
                $cols['entity'] = 'Entity';
            }
            $cols[] = 'Message';
            $cols['status'] = 'Status';
            $cols['notified'] = array('Notified', 'style="width: 40px"');
            $string .= get_table_header($cols);
            // , $vars); // Actually sorting is disabled now
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($events['entries'] as $entry) {
            $alert_rule = $alert_rules[$entry['alert_test_id']];
            // Functionize?
            // Set colours and classes based on the status of the alert
            if ($entry['log_type'] == 'OK') {
                $entry['class'] = "green";
                $entry['html_row_class'] = "success";
            } else {
                if ($entry['log_type'] == 'RECOVER_NOTIFY') {
                    $entry['class'] = "green";
                    $entry['html_row_class'] = "info";
                } else {
                    if ($entry['log_type'] == 'ALERT_NOTIFY') {
                        $entry['class'] = "red";
                        $entry['html_row_class'] = "error";
                    } elseif ($entry['log_type'] == 'FAIL') {
                        $entry['class'] = "red";
                        $entry['html_row_class'] = "error";
                    } elseif ($entry['log_type'] == 'FAIL_DELAYED') {
                        $entry['class'] = "purple";
                        $entry['html_row_class'] = "warning";
                    } elseif ($entry['log_type'] == 'FAIL_SUPPRESSED') {
                        $entry['class'] = "purple";
                        $entry['html_row_class'] = "suppressed";
                    } elseif ($entry['log_type'] == 'RECOVER_SUPPRESSED') {
                        $entry['class'] = "purple";
                        $entry['html_row_class'] = "suppressed";
                    } else {
                        // Anything else set the colour to grey and the class to disabled.
                        $entry['class'] = "gray";
                        $entry['html_row_class'] = "disabled";
                    }
                }
            }
            $string .= '  <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
            $string .= '<td class="state-marker"></td>' . PHP_EOL;
            if ($events['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= generate_tooltip_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td>';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'alertlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['alert_test_id']) {
                $string .= '     <td class="entity"><a href="' . generate_url(array('page' => 'alert_check', 'alert_test_id' => $alert_rule['alert_test_id'])) . '">' . escape_html($alert_rule['alert_name']) . '</a></td>';
            }
            if ($list['entity']) {
                $string .= '    <td class="entity">';
                if ($list['entity_type']) {
                    $string .= '<i class="' . $config['entities'][$entry['entity_type']]['icon'] . '"></i> ';
                }
                if ($events['short']) {
                    $string .= '    ' . generate_entity_link($entry['entity_type'], $entry['entity_id'], NULL, NULL, NULL, TRUE) . '</td>' . PHP_EOL;
                } else {
                    $string .= '    ' . generate_entity_link($entry['entity_type'], $entry['entity_id']) . '</td>' . PHP_EOL;
                }
            }
            $string .= '<td>' . escape_html($entry['message']) . '</td>' . PHP_EOL;
            if (!$vars['short']) {
                $string .= '<td>' . escape_html($entry['log_type']) . '</td>' . PHP_EOL;
                $string .= '<td style="text-align: right">' . ($entry['notified'] ? '<span class="label label-success">YES</span>' : '<span class="label">NO</span>') . '</td>' . PHP_EOL;
            }
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
        // Print pagination header
        if ($events['pagination_html']) {
            $string = $events['pagination_html'] . $string . $events['pagination_html'];
        }
        // Print events
        echo $string;
    }
}
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:alert_log.inc.php

示例10: print_events

/**
 * Display events.
 *
 * Display pages with device/port/system events on some formats.
 * Examples:
 * print_events() - display last 10 events from all devices
 * print_events(array('pagesize' => 99)) - display last 99 events from all device
 * print_events(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 events from page 3 with pagination header
 * print_events(array('pagesize' => 10, 'device' = 4)) - display last 10 events for device_id 4
 * print_events(array('short' => TRUE)) - show small block with last events
 *
 * @param array $vars
 * @return none
 *
 */
function print_events($vars)
{
    global $config;
    // Get events array
    $events = get_events_array($vars);
    if (!$events['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>没有发现事件内容!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'port' => FALSE);
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'eventlog') {
            $list['device'] = TRUE;
        }
        if ($events['short'] || !isset($vars['port']) || empty($vars['port'])) {
            $list['entity'] = TRUE;
        }
        $string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$events['short']) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th class="state-marker"></th>' . PHP_EOL;
            $string .= '      <th>日期</th>' . PHP_EOL;
            if ($list['device']) {
                $string .= '      <th>设备</th>' . PHP_EOL;
            }
            if ($list['entity']) {
                $string .= '      <th>单位</th>' . PHP_EOL;
            }
            $string .= '      <th>信息</th>' . PHP_EOL;
            $string .= '    </tr>' . PHP_EOL;
            $string .= '  </thead>' . PHP_EOL;
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($events['entries'] as $entry) {
            #$icon = geteventicon($entry['message']);
            #if ($icon) { $icon = '<img src="images/16/' . $icon . '" />'; }
            switch ($entry['severity']) {
                case "0":
                    // Emergency
                // Emergency
                case "1":
                    // Alert
                // Alert
                case "2":
                    // Critical
                // Critical
                case "3":
                    // Error
                    $entry['html_row_class'] = "error";
                    break;
                case "4":
                    // Warning
                    $entry['html_row_class'] = "warning";
                    break;
                case "5":
                    // Notification
                    $entry['html_row_class'] = "recovery";
                    break;
                case "6":
                    // Informational
                    $entry['html_row_class'] = "up";
                    break;
                case "7":
                    // Debugging
                    $entry['html_row_class'] = "suppressed";
                    break;
                default:
            }
            $string .= '  <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
            $string .= '<td class="state-marker"></td>' . PHP_EOL;
            if ($events['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td style="width: 160px">';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['entity']) {
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:events.inc.php

示例11: dbFetchRow

<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
include "includes/graphs/device/auth.inc.php";
if ($auth && is_numeric($_GET['mod']) && is_numeric($_GET['chan'])) {
    $entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", array($device['device_id'], $_GET['mod']));
    $title .= " :: " . $entity['entPhysicalName'];
    $title .= " :: Fabric " . $_GET['chan'];
    $graph_title = short_hostname($device['hostname']) . "::" . $entity['entPhysicalName'] . "::Fabric" . $_GET['chan'];
    $rrd_filename = get_rrd_path($device, "c6kxbar-" . $_GET['mod'] . "-" . $_GET['chan'] . ".rrd");
}
开发者ID:skive,项目名称:observium,代码行数:20,代码来源:auth.inc.php

示例12: unset

 echo '<tr class="' . $peer['html_row_class'] . '">';
 unset($sep);
 foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerRemoteAddr = ?", array($peer['device_id'], $peer['bgpPeerRemoteAddr'])) 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
 }
 unset($sep);
 echo '
  <td style="width: 1px; background-color: ' . $peer['table_tab_colour'] . '; margin: 0px; padding: 0px"></td>
  <td style="width: 1px;"></td>';
 echo "\n            <td style='width: 150px;'>" . $localaddresslink . "<br />" . generate_device_link($peer, short_hostname($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')) . "</td>\n            <td style='width: 30px;'><b>&#187;</b></td>\n            <td style='width: 150px;'>" . $peeraddresslink . "<br />" . $peername . "</td>\n            <td style='width: 50px;'><b>" . $peer['peer_type'] . "</b></td>\n            <td style='width: 50px;'><small>" . $peer['afi'] . "</small></td>\n            <td><strong>AS" . $peer['bgpPeerRemoteAs'] . "</strong><br />" . $peer['astext'] . "</td>\n            <td><strong><span class='" . $peer['admin_class'] . "'>" . $peer['bgpPeerAdminStatus'] . "</span><br /><span class='" . $peer['state_class'] . "'>" . $peer['bgpPeerState'] . "</span></strong></td>\n            <td>" . formatUptime($peer['bgpPeerFsmEstablishedTime']) . "<br />\n                Updates <i class='oicon-arrow_down'></i> " . format_si($peer['bgpPeerInUpdates']) . "\n                        <i class='oicon-arrow_up'></i> " . format_si($peer['bgpPeerOutUpdates']) . "</td></tr>";
 unset($invalid);
 switch ($vars['graph']) {
     case 'prefixes_ipv4unicast':
     case 'prefixes_ipv4multicast':
     case 'prefixes_ipv4vpn':
     case 'prefixes_ipv6unicast':
     case 'prefixes_ipv6multicast':
         list(, $afisafi) = explode("_", $vars['graph']);
         if (isset($peer['afisafi'][$afisafi])) {
             $peer['graph'] = 1;
         }
     case 'updates':
         $graph_array['type'] = "bgp_" . $vars['graph'];
         $graph_array['id'] = $peer['bgpPeer_id'];
 }
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:bgp.inc.php

示例13: foreach

 echo '<table class="table table-bordered table-striped">';
 $i = "1";
 foreach (dbFetchRows("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`") as $vrf) {
     if ($i % 2) {
         $bg_colour = $list_colour_a;
     } else {
         $bg_colour = $list_colour_b;
     }
     echo "<tr valign=top bgcolor='{$bg_colour}'>";
     echo "<td width=240><a class=entity href='routing/vrf/" . $vrf['mplsVpnVrfRouteDistinguisher'] . "/" . $_GET['optc'] . "/'>" . $vrf['vrf_name'] . "</a><br /><span class=small>" . $vrf['mplsVpnVrfDescription'] . "</span></td>";
     echo "<td width=100 class=small>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>";
     #echo("<td width=200 class=small>" . $vrf['mplsVpnVrfDescription'] . "</td>");
     echo '<td><table class="table table-striped table-bordered table-condensed">';
     $x = 1;
     foreach ($vrf_devices[$vrf['mplsVpnVrfRouteDistinguisher']] as $device) {
         echo '<tr><td width=150><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'])) . '</span>';
         if ($device['vrf_name'] != $vrf['vrf_name']) {
             echo "<a href='#' onmouseover=\" return overlib('Expected Name : " . $vrf['vrf_name'] . "<br />Configured : " . $device['vrf_name'] . "', CAPTION, '<span class=entity-title>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <img align=absmiddle src=images/16/exclamation.png></a>";
         }
         echo "</td><td>";
         unset($seperator);
         foreach ($ports[$device['vrf_id']][$device['device_id']] as $port) {
             $port = array_merge($device, $port);
             switch ($_GET['optc']) {
                 case 'bits':
                 case 'upkts':
                 case 'nupkts':
                 case 'errors':
                     $port['width'] = "130";
                     $port['height'] = "30";
                     $port['from'] = $config['time']['day'];
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:vrf.inc.php

示例14: generate_link

    echo '<div class="row"><div class="col-md-12">';
    echo '<h4>' . generate_link(nicecase($app_type), array('page' => 'apps', 'app' => $app_type)) . '</h4>';
    $app_devices = array_sort_by($app_types[$app_type], 'hostname', SORT_ASC, SORT_STRING);
    foreach ($app_devices as $app) {
        $graph_type = $config['app'][$app['app_type']]['top'][0];
        $graph_array['type'] = "application_" . $app['app_type'] . "_" . $graph_type;
        $graph_array['id'] = $app['app_id'];
        $graph_array_zoom['type'] = "application_" . $app['app_type'] . "_" . $graph_type;
        $graph_array_zoom['id'] = $app['app_id'];
        $link_array = $graph_array;
        $link_array['page'] = "device";
        $link_array['device'] = $app['device_id'];
        $link_array['tab'] = "apps";
        $link_array['app'] = $app['app_type'];
        unset($link_array['height'], $link_array['width']);
        $overlib_url = generate_url($link_array);
        $overlib_link = '<span style="float:left; margin-left: 10px; font-weight: bold;">' . short_hostname($app['hostname']) . "</span>";
        if (!empty($app['app_instance'])) {
            $overlib_link .= '<span style="float:right; margin-right: 10px; font-weight: bold;">' . $app['app_instance'] . "</span>";
            $app['content_add'] = '(' . $app['app_instance'] . ')';
        }
        $overlib_link .= "<br/>";
        $overlib_link .= generate_graph_tag($graph_array);
        $overlib_content = generate_overlib_content($graph_array, $app['hostname'] . " - " . $app['app_type'] . $app['content_add']);
        echo "<div style='display: block; padding: 1px; padding-top: 3px; margin: 2px; min-width: " . $width_div . "px; max-width:" . $width_div . "px; min-height:165px; max-height:165px;\n                      text-align: center; float: left; background-color: #f5f5f5;'>";
        echo overlib_link($overlib_url, $overlib_link, $overlib_content);
        echo "</div>";
    }
    echo '</div></div>';
}
// EOF
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:overview.inc.php

示例15: print_syslogs


//.........这里部分代码省略.........
                case 'timestamp_from':
                    $where .= ' AND `timestamp` > ?';
                    $param[] = $value;
                    break;
                case 'timestamp_to':
                    $where .= ' AND `timestamp` < ?';
                    $param[] = $value;
                    break;
            }
        }
    }
    // Show events only for permitted devices
    $query_permitted = generate_query_permitted();
    $query = 'FROM `syslog` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(`seq`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `seq` DESC ';
    $query .= "LIMIT {$start},{$pagesize}";
    // Query syslog messages
    $entries = dbFetchRows($query, $param);
    // Query syslog count
    if ($pagination && !$short) {
        $count = dbFetchCell($query_count, $param);
    } else {
        $count = count($entries);
    }
    if (!$count) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No syslog entries found!</h4>
Check that the syslog daemon and Observium configuration options are set correctly, that your devices are configured to send syslog to Observium and that there are no firewalls blocking the messages.

See <a href="http://www.observium.org/wiki/Category:Documentation" target="_blank">documentation</a> and <a href="http://www.observium.org/wiki/Configuration_Options#Syslog_Settings" target="_blank">configuration options</a> for more information.');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'priority' => TRUE);
        // For now (temporarily) priority always displayed
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'syslog') {
            $list['device'] = TRUE;
        }
        if ($short || !isset($vars['priority']) || empty($vars['priority'])) {
            $list['priority'] = TRUE;
        }
        $string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$short) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th>Date</th>' . PHP_EOL;
            if ($list['device']) {
                $string .= '      <th>Device</th>' . PHP_EOL;
            }
            if ($list['priority']) {
                $string .= '      <th>Priority</th>' . PHP_EOL;
            }
            $string .= '      <th>Message</th>' . PHP_EOL;
            $string .= '    </tr>' . PHP_EOL;
            $string .= '  </thead>' . PHP_EOL;
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($entries as $entry) {
            $string .= '  <tr>';
            if ($short) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td width="160">';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'syslog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['priority']) {
                if (!$short) {
                    $string .= '    <td style="color: ' . $priorities[$entry['priority']]['color'] . '; white-space: nowrap;">' . nicecase($priorities[$entry['priority']]['name']) . ' (' . $entry['priority'] . ')</td>' . PHP_EOL;
                }
            }
            $entry['program'] = empty($entry['program']) ? '[[EMPTY]]' : $entry['program'];
            if ($short) {
                $string .= '    <td class="syslog">';
                $string .= '<strong style="color: ' . $priorities[$entry['priority']]['color'] . ';">' . $entry['program'] . '</strong> : ';
            } else {
                $string .= '    <td>';
                $string .= '<strong>' . $entry['program'] . '</strong> : ';
            }
            $string .= htmlspecialchars($entry['msg']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>' . PHP_EOL;
        // Print pagination header
        if ($pagination && !$short) {
            $string = pagination($vars, $count) . $string . pagination($vars, $count);
        }
        // Print syslog
        echo $string;
    }
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:syslogs.inc.php


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