コード例 #1
0
ファイル: status.inc.php プロジェクト: Natolumin/observium
function generate_status_row($status, $vars)
{
    global $config;
    $table_cols = 7;
    humanize_status($status);
    $alert = $status['state_event'] == 'alert' ? 'oicon-exclamation-red' : '';
    // FIXME - make this "four graphs in popup" a function/include and "small graph" a function.
    // FIXME - DUPLICATED IN device/overview/status
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $status['status_id'];
    $graph_array['type'] = "status_graph";
    $graph_array['legend'] = "no";
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    $status_misc = '<span class="label">' . $status['entPhysicalClass'] . '</span>';
    $row .= '<tr class="' . $status['row_class'] . '">
        <td class="state-marker"></td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $row .= '<td class="entity">' . generate_device_link($status) . '</td>';
        $table_cols++;
    }
    if ($status['status_event'] && $status['status_name']) {
        $mini_graph = generate_graph_tag($graph_array);
    } else {
        // Do not show "Draw Error" minigraph
        $mini_graph = '';
    }
    $row .= '<td class="entity">' . generate_entity_link('status', $status) . '</td>';
    if ($vars['tab'] != "overview") {
        $row .= '<td><span class="label">' . $status['entPhysicalClass'] . '</span></td>';
        $table_cols++;
    }
    $row .= '<td style="width: 90px; text-align: right;">' . generate_entity_link('status', $status, $mini_graph, NULL, FALSE) . '</td>';
    if ($vars['tab'] != "overview") {
        $row .= '<td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $status['status_last_change'], 'short-2') . ' ago', format_unixtime($status['status_last_change'])) . '</td>
        <td style="text-align: right;"><strong><span class="' . $status['state_class'] . '">' . $status['status_event'] . '</span></strong></td>';
        $table_cols++;
        $table_cols++;
    }
    $row .= '<td style="width: 80px; text-align: right;"><strong><span class="' . $status['state_class'] . '">' . $status['status_name'] . '</span></strong></td>
        </tr>' . PHP_EOL;
    if ($vars['view'] == "graphs") {
        $vars['graph'] = "status";
    }
    if ($vars['graph'] || $vars['id'] == $status['status_id']) {
        // If id set in vars, display only specific graphs
        $row .= '<tr class="' . $status['row_class'] . '">
      <td class="state-marker"></td>
      <td colspan="' . $table_cols . '">';
        unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $status['status_id'];
        $graph_array['type'] = "status_graph";
        $row .= generate_graph_row($graph_array, TRUE);
        $row .= '</td></tr>';
    }
    # endif graphs
    return $row;
}
コード例 #2
0
ファイル: default.inc.php プロジェクト: Natolumin/observium
 $htmlname = str_replace('|', '__', $varname);
 // JQuery et al don't like the pipes a lot, replace once here in temporary variable
 $confname = '$config[\'' . implode("']['", explode('|', $varname)) . '\']';
 echo '  <tr class="' . $linetype . ' vertical-align">' . PHP_EOL;
 echo '    <td class="state-marker"></td>';
 echo '    <td style="width: 5px;"></td>';
 echo '    <td><strong style="color: #0a5f7f;">' . $variable['name'] . '</strong>';
 echo '<br /><i><small>' . escape_html($variable['shortdesc']) . '</small></i>' . PHP_EOL;
 echo '      </td>' . PHP_EOL;
 echo '      <td class="text-nowrap">' . PHP_EOL;
 echo '<div class="pull-right">';
 if ($locked) {
     echo generate_tooltip_link(NULL, '<i class="oicon-lock-warning"></i>', 'This setting is locked because it has been set in your <strong>config.php</strong> file.');
     echo '&nbsp;';
 }
 echo generate_tooltip_link(NULL, '<i id="clipboard" class="oicon-question" data-clipboard-text="' . $confname . '"></i>', 'Variable name to use in <strong>config.php</strong>: ' . $confname);
 echo '      </div>' . PHP_EOL;
 echo '      </td>' . PHP_EOL;
 echo '      <td>' . PHP_EOL;
 // Split enum|foo|bar into enum  foo|bar
 list($vartype, $varparams) = explode('|', $variable['type'], 2);
 $params = array();
 // If a callback function is defined, use this to fill params.
 if ($variable['params_call'] && function_exists($variable['params_call'])) {
     $params = call_user_func($variable['params_call']);
     // Else if the params are defined directly, use these.
 } else {
     if (is_array($variable['params'])) {
         $params = $variable['params'];
     } else {
         if (!empty($varparams)) {
コード例 #3
0
ファイル: syslogs.inc.php プロジェクト: Natolumin/observium
/**
 * Display syslog messages.
 *
 * Display pages with device syslog messages.
 * Examples:
 * print_syslogs() - display last 10 syslog messages from all devices
 * print_syslogs(array('pagesize' => 99)) - display last 99 syslog messages from all device
 * print_syslogs(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 syslog messages from page 3 with pagination header
 * print_syslogs(array('pagesize' => 10, 'device' = 4)) - display last 10 syslog messages for device_id 4
 * print_syslogs(array('short' => TRUE)) - show small block with last syslog messages
 *
 * @param array $vars
 * @return none
 *
 */
function print_syslogs($vars)
{
    // Short events? (no pagination, small out)
    $short = isset($vars['short']) && $vars['short'];
    // 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;
    $priorities = $GLOBALS['config']['syslog']['priorities'];
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            $cond = array();
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= generate_query_values($value, 'device_id');
                    break;
                case 'priority':
                    if (!is_array($value)) {
                        $value = explode(',', $value);
                    }
                    foreach ($value as $k => $v) {
                        // Rewrite priority strings to numbers
                        $value[$k] = priority_string_to_numeric($v);
                    }
                    // Do not break here, it's true!
                // Do not break here, it's true!
                case 'program':
                    $where .= generate_query_values($value, $var);
                    break;
                case 'message':
                    $where .= generate_query_values($value, 'msg', '%LIKE%');
                    break;
                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(*) ' . $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="' . OBSERVIUM_URL . '/wiki/Category:Documentation" target="_blank">documentation</a> and <a href="' . OBSERVIUM_URL . '/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 = generate_box_open($vars['header']);
        $string .= '<table class="' . OBS_CLASS_TABLE_STRIPED_MORE . '">' . PHP_EOL;
        if (!$short) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th class="state-marker"></th>' . PHP_EOL;
            #    $string .= '      <th></th>' . 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) {
            switch ($entry['priority']) {
                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 ($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 width="130">';
                $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; width: 95px;"><span class="label label-' . $priorities[$entry['priority']]['label-class'] . '">' . nicecase($priorities[$entry['priority']]['name']) . ' (' . $entry['priority'] . ')</span></td>' . PHP_EOL;
                }
            }
            $entry['program'] = empty($entry['program']) ? '[[EMPTY]]' : $entry['program'];
            if ($short) {
                $string .= '    <td class="syslog">';
                $string .= '<span class="label label-' . $priorities[$entry['priority']]['label-class'] . '"><strong>' . $entry['program'] . '</strong></span> ';
            } else {
                $string .= '    <td>';
                $string .= '<span class="label label-' . $priorities[$entry['priority']]['label-class'] . '">' . $entry['program'] . '</span>';
            }
            $string .= escape_html($entry['msg']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>' . PHP_EOL;
        $string .= generate_box_close();
        // Print pagination header
        if ($pagination && !$short) {
            $string = pagination($vars, $count) . $string . pagination($vars, $count);
        }
        // Print syslog
        echo $string;
    }
}
コード例 #4
0
ファイル: alert.inc.php プロジェクト: Natolumin/observium
/**
 * Display alert_table entries.
 *
 * @param array $vars
 * @return none
 *
 */
function print_alert_table($vars)
{
    global $alert_rules;
    global $config;
    // This should be set outside, but do it here if it isn't
    if (!is_array($alert_rules)) {
        $alert_rules = cache_alert_rules();
    }
    /// WARN HERE
    if (isset($vars['device']) && !isset($vars['device_id'])) {
        $vars['device_id'] = $vars['device'];
    }
    if (isset($vars['entity']) && !isset($vars['entity_id'])) {
        $vars['entity_id'] = $vars['entity'];
    }
    // Short? (no pagination, small out)
    $short = isset($vars['short']) && $vars['short'];
    list($query, $param, $query_count) = build_alert_table_query($vars);
    // Fetch alerts
    $count = dbFetchCell($query_count, $param);
    $alerts = dbFetchRows($query, $param);
    // Set which columns we're going to show.
    // We hide the columns that have been given as search options via $vars
    $list = array('device_id' => FALSE, 'entity_id' => FALSE, 'entity_type' => FALSE, 'alert_test_id' => FALSE);
    foreach ($list as $argument => $nope) {
        if (!isset($vars[$argument]) || empty($vars[$argument]) || $vars[$argument] == "all") {
            $list[$argument] = TRUE;
        }
    }
    if ($vars['format'] != "condensed") {
        $list['checked'] = TRUE;
        $list['changed'] = TRUE;
        $list['alerted'] = TRUE;
    }
    if ($vars['short'] == TRUE) {
        $list['checked'] = FALSE;
        $list['alerted'] = FALSE;
    }
    // Hide device if we know entity_id
    if (isset($vars['entity_id'])) {
        $list['device_id'] = FALSE;
    }
    // Hide entity_type if we know the alert_test_id
    if (isset($vars['alert_test_id']) || TRUE) {
        $list['entity_type'] = FALSE;
    }
    // Hide entity types in favour of icons to save space
    if ($vars['pagination'] && !$short) {
        $pagination_html = pagination($vars, $count);
        echo $pagination_html;
    }
    echo generate_box_open($vars['header']);
    echo '<table class="table table-condensed  table-striped  table-hover">';
    if ($vars['no_header'] == FALSE) {
        echo '
  <thead>
    <tr>
      <th class="state-marker"></th>
      <th style="width: 1px;"></th>';
        if ($list['device_id']) {
            echo '      <th style="width: 15%">Device</th>';
        }
        if ($list['entity_type']) {
            echo '      <th style="width: 10%">Type</th>';
        }
        if ($list['entity_id']) {
            echo '      <th style="">Entity</th>';
        }
        if ($list['alert_test_id']) {
            echo '      <th style="min-width: 15%;">Alert</th>';
        }
        echo '
      <th style="width: 100px;">Status</th>';
        if ($list['checked']) {
            echo '      <th style="width: 95px;">Checked</th>';
        }
        if ($list['changed']) {
            echo '      <th style="width: 95px;">Changed</th>';
        }
        if ($list['alerted']) {
            echo '      <th style="width: 95px;">Alerted</th>';
        }
        echo '    <th style="width: 45px;"></th>
    </tr>
  </thead>';
    }
    echo '<tbody>' . PHP_EOL;
    foreach ($alerts as $alert) {
        // Process the alert entry, generating colours and classes from the data
        humanize_alert_entry($alert);
        // Get the entity array using the cache
        $entity = get_entity_by_id_cache($alert['entity_type'], $alert['entity_id']);
        // Get the device array using the cache
        $device = device_by_id_cache($alert['device_id']);
        // Get the entity_name.
        ### FIXME - This is probably duplicated effort from above. We should pass it $entity
        $entity_name = entity_name($alert['entity_type'], $entity);
        // Set the alert_rule from the prebuilt cache array
        $alert_rule = $alert_rules[$alert['alert_test_id']];
        echo '<tr class="' . $alert['html_row_class'] . '" style="cursor: pointer;" onclick="openLink(\'' . generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alert', 'alert_entry' => $alert['alert_table_id'])) . '\')">';
        echo '<td class="state-marker"></td>';
        echo '<td style="width: 1px;"></td>';
        // If we know the device, don't show the device
        if ($list['device_id']) {
            echo '<td><span class="entity-title">' . generate_device_link($device) . '</span></td>';
        }
        // If we're showing all entity types, print the entity type here
        if ($list['entity_type']) {
            echo '<td>' . nicecase($alert['entity_type']) . '</td>';
        }
        // Print a link to the entity
        if ($list['entity_id']) {
            echo '<td><span class="entity-title"><i class="' . $config['entities'][$alert['entity_type']]['icon'] . '"></i> ' . generate_entity_link($alert['entity_type'], $alert['entity_id']) . '</span></td>';
        }
        // Print link to the alert rule page
        if ($list['alert_test_id']) {
            echo '<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>';
        }
        echo '<td>';
        echo '<span class="label label-' . ($alert['html_row_class'] != 'up' ? $alert['html_row_class'] : 'success') . '">' . generate_tooltip_link('', $alert['status'], '<div class="small" style="max-width: 500px;"><strong>' . $alert['last_message'] . '</strong></div>', $alert['alert_class']) . '</span>';
        echo '</td>';
        // echo('<td class="'.$alert['class'].'">'.$alert['last_message'].'</td>');
        if ($list['checked']) {
            echo '<td>' . generate_tooltip_link('', $alert['checked'], format_unixtime($alert['last_checked'], 'r')) . '</td>';
        }
        if ($list['changed']) {
            echo '<td>' . generate_tooltip_link('', $alert['changed'], format_unixtime($alert['last_changed'], 'r')) . '</td>';
        }
        if ($list['alerted']) {
            echo '<td>' . generate_tooltip_link('', $alert['alerted'], format_unixtime($alert['last_alerted'], 'r')) . '</td>';
        }
        echo '<td>';
        // This stuff should go in an external entity popup in the future.
        $state = json_decode($alert['state'], true);
        $alert['state_popup'] = '';
        if (count($state['failed'])) {
            $alert['state_popup'] .= generate_box_open(array('title' => 'Failed Tests'));
            //'<h4>Failed Tests</h4>';
            $alert['state_popup'] .= '<table style="min-width: 400px;" class="table   table-striped table-condensed">';
            $alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Cond</th><th>Value</th><th>Measured</th></tr></thead>';
            foreach ($state['failed'] as $test) {
                $alert['state_popup'] .= '<tr><td><strong>' . $test['metric'] . '</strong></td><td>' . $test['condition'] . '</td><td>' . $test['value'] . '</td><td><i class="red">' . $state['metrics'][$test['metric']] . '</i></td></tr>';
            }
            $alert['state_popup'] .= '</table>';
            $alert['state_popup'] .= generate_box_close();
        }
        $alert['state_popup'] .= generate_entity_popup_graphs($alert, array('entity_type' => 'alert_entry'));
        // Print (i) icon with popup of state.
        echo overlib_link("", '<i class="icon-info-sign text-primary"></i>', $alert['state_popup'], NULL);
        echo '&nbsp;&nbsp;<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alert', 'alert_entry' => $alert['alert_table_id'])) . '"><i class="icon-cog text-muted"></i></a>';
        echo '</td>';
        echo '</tr>';
    }
    echo '  </tbody>' . PHP_EOL;
    echo '</table>' . PHP_EOL;
    echo generate_box_close();
    if ($vars['pagination'] && !$short) {
        echo $pagination_html;
    }
}
コード例 #5
0
ファイル: alert_log.inc.php プロジェクト: Natolumin/observium
/**
 * Display events.
 *
 * Display pages with alert logs in multiple formats.
 * Examples:
 * print_alert_log() - display last 10 events from all devices
 * print_alert_log(array('pagesize' => 99)) - display last 99 events from all device
 * print_alert_log(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 events from page 3 with pagination header
 * print_alert_log(array('pagesize' => 10, 'device' = 4)) - display last 10 events for device_id 4
 * print_alert_log(array('short' => TRUE)) - show small block with last events
 *
 * @param array $vars
 * @return none
 *
 */
function print_alert_log($vars)
{
    global $alert_rules, $config;
    // This should be set outside, but do it here if it isn't
    if (!is_array($alert_rules)) {
        $alert_rules = cache_alert_rules();
    }
    // Get events array
    $events = get_alert_log($vars);
    if (!$events['count']) {
        if (!$vars['no_empty_message']) {
            // There have been no entries returned. Print the warning.
            print_message('<h4>No alert log entries found!</h4>', FALSE);
        }
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'entity' => FALSE);
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'alert_log') {
            $list['device'] = TRUE;
        }
        if ($events['short'] || !isset($vars['entity']) || empty($vars['entity'])) {
            $list['entity'] = TRUE;
        }
        if (!isset($vars['alert_test_id']) || empty($vars['alert_test_id']) || $vars['page'] == 'alert_check' || TRUE) {
            $list['alert_test_id'] = TRUE;
        }
        if (!isset($vars['entity_type']) || empty($vars['entity_type']) || $vars['page'] == 'alert_check' || TRUE) {
            $list['entity_type'] = TRUE;
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="table table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$events['short']) {
            $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;
    }
}
コード例 #6
0
ファイル: packages.inc.php プロジェクト: Natolumin/observium
            $content .= $version . $dbuild;
            foreach ($bloo as $device_id => $no) {
                $this_device = device_by_id_cache($device_id);
                //$content .= '<span style="background-color: #f5f5f5; margin: 5px;">'.$this_device['hostname'].'</span> ';
                if (!empty($this_device['hostname'])) {
                    $content .= " - " . $this_device['hostname'];
                }
            }
            //$content .= "</div>";
        }
        //$content .= "</div>";
        if (empty($vars['name'])) {
            if ($first) {
                $first = false;
                $middot = "";
            } else {
                $middot = "&nbsp;&nbsp;&middot;&nbsp;&nbsp;";
            }
            //echo("<span style='margin:5px;'>".overlib_link("", $version, $content,  NULL)."</span>");
            echo $middot . generate_tooltip_link('', $version . $dbuild, $content);
        } else {
            echo "{$version} {$content} <br />";
        }
    }
    echo '      </td>' . PHP_EOL;
    echo '    </tr>' . PHP_EOL;
}
echo '  </tbody>';
echo '</table>';
echo generate_box_close();
// EOF
コード例 #7
0
   foreach (json_decode($tunnel['tunnel_endpoint'], TRUE) as $entry) {
       $tunnel_endpoint[] = 'Local: ' . generate_popup_link('ip', $entry['local']) . ', Remote: ' . generate_popup_link('ip', $entry['remote']);
   }
   $tunnel_endpoint = implode('<br />', $tunnel_endpoint);
   $timediff = $GLOBALS['config']['time']['now'] - $tunnel['tunnel_added'];
   echo '<tr class="' . $tunnel['row_class'] . '">
 <td class="state-marker"></td>
 <td>' . generate_popup_link('ip', $tunnel['local_addr']) . '</td>
 <td><b>&#187;</b></td>
 <td>' . generate_popup_link('ip', $tunnel['peer_addr']) . '</td>
 <td>' . $tunnel['tunnel_name'] . '</td>
 <td><span>' . $tunnel_endpoint . '</span></td>
 <td><span>' . generate_tooltip_link(NULL, formatUptime($tunnel['tunnel_lifetime'], 'short-3'), $tunnel['tunnel_lifetime'] . ' sec') . '</span></td>
 <td><span class="label ' . $tunnel['ike_label_class'] . '">' . $tunnel['tunnel_ike_alive'] . '</span></td>
 <td><span>' . generate_tooltip_link(NULL, formatUptime($tunnel['tunnel_ike_lifetime'], 'short-3'), $tunnel['tunnel_ike_lifetime'] . ' sec') . '</span></td>
 <td><span>' . generate_tooltip_link(NULL, formatUptime($timediff, "short-3") . ' ago', format_unixtime($tunnel['tunnel_added'])) . '</span></td>
 </tr>';
   switch ($vars['graph']) {
       case 'bits':
       case 'pkts':
           $graph_array['type'] = 'ipsectunnel_' . $vars['graph'];
           $graph_array['id'] = $tunnel['tunnel_id'];
   }
   if ($vars['graph'] == 'bits' || $vars['graph'] == 'pkts') {
       $tunnel['graph'] = 1;
   }
   if ($tunnel['graph']) {
       $graph_array['to'] = $config['time']['now'];
       echo '<tr class="' . $tunnel['row_class'] . '">';
       echo '<td colspan="10">';
       print_graph_row($graph_array);
コード例 #8
0
ファイル: events.inc.php プロジェクト: Natolumin/observium
/**
 * 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>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['entity'] = TRUE;
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="' . OBS_CLASS_TABLE_STRIPED_MORE . '">' . PHP_EOL;
        if (!$events['short']) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th class="state-marker"></th>' . PHP_EOL;
            $string .= '      <th>Date</th>' . PHP_EOL;
            if ($list['device']) {
                $string .= '      <th>Device</th>' . PHP_EOL;
            }
            if ($list['entity']) {
                $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) {
            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 .= generate_tooltip_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']) {
                if ($entry['entity_type'] == 'device' && !$entry['entity_id']) {
                    $entry['entity_id'] = $entry['device_id'];
                }
                if ($entry['entity_type'] == 'port') {
                    $this_if = get_port_by_id_cache($entry['entity_id']);
                    $entry['link'] = '<span class="entity"><i class="' . $config['entities']['port']['icon'] . '"></i> ' . generate_port_link($this_if, $this_if['port_label_short']) . '</span>';
                } else {
                    if (!empty($config['entities'][$entry['entity_type']]['icon'])) {
                        $entry['link'] = '<i class="' . $config['entities'][$entry['entity_type']]['icon'] . '"></i> <span class="entity">' . generate_entity_link($entry['entity_type'], $entry['entity_id']) . '</span>';
                    } else {
                        $entry['link'] = nicecase($entry['entity_type']);
                    }
                }
                if (!$events['short']) {
                    $string .= '    <td style="white-space: nowrap">' . $entry['link'] . '</td>' . PHP_EOL;
                }
            }
            if ($events['short']) {
                $string .= '    <td class="syslog">';
                if (strpos($entry['message'], $entry['link']) !== 0) {
                    $string .= $entry['link'] . ' ';
                }
            } else {
                $string .= '    <td>';
            }
            $string .= escape_html($entry['message']) . '</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;
    }
}
コード例 #9
0
function generate_pseudowire_row($pw, $vars)
{
    global $config;
    humanize_pseudowire($pw);
    $table_cols = 11;
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $pw['pseudowire_id'];
    $graph_array['type'] = $pw['graph'];
    $graph_array['legend'] = "no";
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    if ($pw['event'] && $pw['pwOperStatus']) {
        $mini_graph = generate_graph_tag($graph_array);
    } else {
        // Do not show "Draw Error" minigraph
        $mini_graph = '';
    }
    $out = '<tr class="' . $pw['row_class'] . '"><td class="state-marker"></td>';
    $out .= '<td class="entity" style="text-align: right;">' . generate_entity_link('pseudowire', $pw, NULL, NULL, TRUE, TRUE) . '</td>';
    $out .= '<td>' . nicecase($pw['pwType']) . '/' . nicecase($pw['pwPsnType']) . '</td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $out .= '<td class="entity">' . generate_device_link($pw, NULL, array('tab' => 'pseudowires')) . '</td>';
        $table_cols++;
    }
    $out .= '<td class="entity">' . generate_entity_link('port', $pw['port_id']) . '</td>';
    $out .= '<td><span class="text-success"><i class="glyphicon glyphicon-arrow-right"></i></span></td>';
    if ($pw['peer_port_id']) {
        $out .= '<td class="entity">' . generate_entity_link('device', $pw['peer_device_id']) . '</td>';
        $out .= '<td class="entity">' . generate_entity_link('port', $pw['peer_port_id']) . '</td>';
    } else {
        $out .= '<td class="entity">' . generate_popup_link('ip', $pw['peer_addr']) . '</td>';
        $out .= '<td>' . $pw['pwRemoteIfString'] . '</td>';
    }
    $out .= '<td>' . generate_entity_link('pseudowire', $pw, $mini_graph, NULL, FALSE) . '</td>';
    $out .= '<td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $pw['last_change'], 'short-2') . ' ago', format_unixtime($pw['last_change'])) . '</td>';
    $out .= '<td style="text-align: right;"><strong><span class="' . $pw['pw_class'] . '">' . $pw['event'] . '</span></strong></td>';
    $out .= '<td style="text-align: right;"><strong><span class="' . $pw['pw_class'] . '">' . $pw['pwOperStatus'] . '</span></strong></td>';
    $out .= '<td>' . formatUptime($pw['pwUptime'], 'short-2') . '</td>';
    $out .= '</tr>';
    if ($vars['graph'] || $vars['view'] == "graphs" || $vars['id'] == $pw['pseudowire_id']) {
        // If id set in vars, display only specific graphs
        $graph_array = array();
        $graph_array['type'] = $vars['graph'] ? $vars['graph'] : $pw['graph'];
        $graph_array['id'] = $pw['pseudowire_id'];
        $out .= '<tr class="' . $pw['row_class'] . '">';
        $out .= '  <td class="state-marker"></td>';
        $out .= '  <td colspan="' . $table_cols . '">';
        $out .= generate_graph_row($graph_array, TRUE);
        $out .= '  </td>';
        $out .= '</tr>';
    }
    return $out;
}
コード例 #10
0
ファイル: contacts.inc.php プロジェクト: Natolumin/observium
            if (isset($param_data['tooltip'])) {
                echo generate_tooltip_link(NULL, '<i class="oicon-question"></i>', $param_data['tooltip']);
            }
            echo '          </div>' . PHP_EOL;
            echo '        </div>' . PHP_EOL;
        }
    }
    if (count($data['parameters']['optional'])) {
        echo '  <h3 id="add_assoc_label"><i class="oicon-sql-join-inner"></i> Optional parameters</h3>' . PHP_EOL;
        foreach ($data['parameters']['optional'] as $parameter => $param_data) {
            echo '        <div class="control-group">' . PHP_EOL;
            echo '          <label class="control-label" for="contact_' . $transport . '_' . $parameter . '">' . $param_data['description'] . '</label>' . PHP_EOL;
            echo '          <div class="controls">' . PHP_EOL;
            echo '            <input type=text name="contact_' . $transport . '_' . $parameter . '" size="32" value=""/>' . PHP_EOL;
            if (isset($param_data['tooltip'])) {
                echo generate_tooltip_link(NULL, '<i class="oicon-question"></i>', $param_data['tooltip']);
            }
            echo '          </div>' . PHP_EOL;
            echo '        </div>' . PHP_EOL;
        }
    }
    echo '      </div>' . PHP_EOL;
}
?>

<script type="text/javascript">
<!--
$("#contact_method").change(function() {
  var select = this.value;

<?php 
コード例 #11
0
ファイル: port.inc.php プロジェクト: Natolumin/observium
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>';
            $string .= '</td>';
            // Print port graph thumbnails
            $string .= '<td style="width: 147px;">';
            $port['graph_type'] = "port_bits";
            $graph_array = array();
            $graph_array['to'] = $config['time']['now'];
            $graph_array['id'] = $port['port_id'];
            $graph_array['type'] = $port['graph_type'];
            $graph_array['width'] = 100;
            $graph_array['height'] = 20;
            $graph_array['bg'] = 'ffffff00';
            $graph_array['from'] = $config['time']['day'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $port['graph_type'] = "port_upkts";
            $graph_array['type'] = $port['graph_type'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $port['graph_type'] = "port_errors";
            $graph_array['type'] = $port['graph_type'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $string .= '</td>';
            $string .= '<td style="width: 100px; white-space: nowrap;">';
            if ($port['ifOperStatus'] == "up" || $port['ifOperStatus'] == "monitoring") {
                // Colours generated by humanize_port
                $string .= '<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 />
      <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>';
            }
            $string .= '</td><td style="width: 110px;">';
            if ($port['ifType'] && $port['ifType'] != "") {
                $string .= '<span class="small">' . $port['human_type'] . '</span>';
            } else {
                $string .= '-';
            }
            $string .= '<br />';
            if ($port['ifSpeed']) {
                $string .= '<span class="small">' . humanspeed($port['ifSpeed']) . '</span>';
            }
            if ($port['ifDuplex'] && $port['ifDuplex'] != "unknown") {
                $string .= '<span class="small"> (' . str_replace("Duplex", "", $port['ifDuplex']) . ')</span>';
            }
            $string .= '<br />';
            if ($port['ifMtu'] && $port['ifMtu'] != "") {
                $string .= '<span class="small">MTU ' . $port['ifMtu'] . '</span>';
            } else {
                $string .= '<span class="small">Unknown MTU</span>';
            }
            // if ($ifHardType && $ifHardType != "") { $string .= '<span class="small">" . $ifHardType . "</span>"); } else { $string .= '-'; }
            //$string .= '<br />';
            // Set VLAN data if the port has ifTrunk populated
            if ($port['ifTrunk']) {
                if ($port['ifVlan']) {
                    // Native VLAN
                    if (!isset($cache['ports_vlan'])) {
                        $native_state = dbFetchCell('SELECT `state` FROM `ports_vlans` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port['port_id']));
                        $native_name = dbFetchCell('SELECT `vlan_name` FROM vlans     WHERE `device_id` = ? AND `vlan_vlan` = ?;', array($device['device_id'], $port['ifVlan']));
                    } else {
                        $native_state = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['state'];
                        $native_name = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['vlan_name'];
                    }
                    switch ($native_state) {
                        case 'blocking':
                            $class = 'text-danger';
                            break;
                        case 'forwarding':
                            $class = 'text-success';
                            break;
                        default:
                            $class = 'muted';
                    }
                    if (empty($native_name)) {
                        $native_name = 'VLAN' . str_pad($port['ifVlan'], 4, '0', STR_PAD_LEFT);
                    }
                    $native_tooltip = 'NATIVE: <strong class=' . $class . '>' . $port['ifVlan'] . ' [' . $native_name . ']</strong><br />';
                }
                if (!isset($cache['ports_vlan'])) {
                    $vlans = dbFetchRows('SELECT * FROM `ports_vlans` AS PV
                         LEFT JOIN vlans AS V ON PV.`vlan` = V.`vlan_vlan` AND PV.`device_id` = V.`device_id`
                         WHERE PV.`port_id` = ? AND PV.`device_id` = ? ORDER BY PV.`vlan`;', array($port['port_id'], $device['device_id']));
                } else {
                    $vlans = $cache['ports_vlan'][$port['port_id']];
                }
                $vlans_count = count($vlans);
                $rel = $vlans_count || $native_tooltip ? 'tooltip' : '';
                // Hide tooltip for empty
                $string .= '<p class="small"><a class="label label-info" data-rel="' . $rel . '" data-tooltip="<div class=\'small\' style=\'max-width: 320px; text-align: justify;\'>' . $native_tooltip;
                if ($vlans_count) {
                    $string .= 'ALLOWED: ';
                    $vlans_aggr = array();
                    foreach ($vlans as $vlan) {
                        if ($vlans_count > 20) {
                            // Aggregate VLANs
                            $vlans_aggr[] = $vlan['vlan'];
                        } else {
                            // List VLANs
                            switch ($vlan['state']) {
                                case 'blocking':
                                    $class = 'text-danger';
                                    break;
                                case 'forwarding':
                                    $class = 'text-success';
                                    break;
                                default:
                                    $class = 'muted';
                            }
                            if (empty($vlan['vlan_name'])) {
                                'VLAN' . str_pad($vlan['vlan'], 4, '0', STR_PAD_LEFT);
                            }
                            $string .= '<strong class=' . $class . '>' . $vlan['vlan'] . ' [' . $vlan['vlan_name'] . ']</strong><br />';
                        }
                    }
                    if ($vlans_count > 20) {
                        // End aggregate VLANs
                        $string .= '<strong>' . range_to_list($vlans_aggr, ', ') . '</strong>';
                    }
                }
                $string .= '</div>">' . $port['ifTrunk'] . '</a></p>';
            } else {
                if ($port['ifVlan']) {
                    if (!isset($cache['ports_vlan'])) {
                        $native_state = dbFetchCell('SELECT `state` FROM `ports_vlans` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port['port_id']));
                        $native_name = dbFetchCell('SELECT `vlan_name` FROM vlans     WHERE `device_id` = ? AND `vlan_vlan` = ?;', array($device['device_id'], $port['ifVlan']));
                    } else {
                        $native_state = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['state'];
                        $native_name = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['vlan_name'];
                    }
                    switch ($native_state) {
                        case 'blocking':
                            $class = 'label-error';
                            break;
                        case 'forwarding':
                            $class = 'label-success';
                            break;
                        default:
                            $class = '';
                    }
                    $rel = $native_name ? 'tooltip' : '';
                    // Hide tooltip for empty
                    $string .= '<br /><span data-rel="' . $rel . '" class="label ' . $class . '"  data-tooltip="<strong class=\'small\'>' . $port['ifVlan'] . ' [' . $native_name . ']</strong>">VLAN ' . $port['ifVlan'] . '</span>';
                } else {
                    if ($port['ifVrf']) {
                        $vrf_name = dbFetchCell("SELECT `vrf_name` FROM `vrfs` WHERE `vrf_id` = ?", array($port['ifVrf']));
                        $string .= '<br /><span class="label label-success" data-rel="tooltip" data-tooltip="VRF">' . $vrf_name . '</span>';
                    }
                }
            }
            $string .= '</td>';
            // If the port is ADSL, print ADSL port data.
            if ($port_adsl['adslLineCoding']) {
                $string .= '<td style="width: 200px;"><span class="small">';
                $string .= '<span class="label">' . $port_adsl['adslLineCoding'] . '</span> <span class="label">' . rewrite_adslLineType($port_adsl['adslLineType']) . '</span>';
                $string .= '<br />';
                $string .= 'SYN <i class="icon-circle-arrow-down green"></i> ' . formatRates($port_adsl['adslAtucChanCurrTxRate']) . ' <i class="icon-circle-arrow-up blue"></i> ' . formatRates($port_adsl['adslAturChanCurrTxRate']);
                $string .= '<br />';
                //$string .= 'Max:'.formatRates($port_adsl['adslAtucCurrAttainableRate']) . '/'. formatRates($port_adsl['adslAturCurrAttainableRate']);
                //$string .= '<br />';
                $string .= 'ATN <i class="icon-circle-arrow-down green"></i> ' . $port_adsl['adslAtucCurrAtn'] . 'dBm <i class="icon-circle-arrow-up blue"></i> ' . $port_adsl['adslAturCurrAtn'] . 'dBm';
                $string .= '<br />';
                $string .= 'SNR <i class="icon-circle-arrow-down green"></i> ' . $port_adsl['adslAtucCurrSnrMgn'] . 'dB <i class="icon-circle-arrow-up blue"></i> ' . $port_adsl['adslAturCurrSnrMgn'] . 'dB';
                $string .= '</span>';
            } else {
                // Otherwise print normal port data
                $string .= '<td style="width: 150px;"><span class="small">';
                if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != "") {
                    $string .= $port['human_mac'];
                } else {
                    $string .= '-';
                }
                $string .= '<br />' . $port['ifLastChange'] . '</span>';
            }
            $string .= '</td>';
            $string .= '<td style="min-width: 200px" class="small">';
            if (strpos($port['port_label'], "oopback") === FALSE && !$graph_type) {
                unset($br);
                // Populate links array for ports with direct links
                if (!isset($cache['ports_option']['neighbours']) || in_array($port['port_id'], $cache['ports_option']['neighbours'])) {
                    foreach (dbFetchRows('SELECT * FROM `neighbours` WHERE `port_id` = ?', array($port['port_id'])) as $neighbour) {
                        // print_r($link);
                        if ($neighbour['remote_port_id']) {
                            $int_links[$neighbour['remote_port_id']] = $neighbour['remote_port_id'];
                            $int_links_phys[$neighbour['remote_port_id']] = 1;
                        } else {
                            $int_links_unknown[] = $neighbour;
                        }
                    }
                } else {
                }
                // Populate links array for devices which share an IPv4 subnet
                if (!isset($cache['ports_option']['ipv4_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv4_addresses'])) {
                    foreach (dbFetchColumn('SELECT DISTINCT(`ipv4_network_id`) FROM `ipv4_addresses`
                                 LEFT JOIN `ipv4_networks` USING(`ipv4_network_id`)
                                 WHERE `port_id` = ? AND `ipv4_network` NOT IN (?);', array($port['port_id'], $config['ignore_common_subnet'])) as $network_id) {
                        $sql = 'SELECT N.*, P.`port_id`, P.`device_id` FROM `ipv4_addresses` AS A, `ipv4_networks` AS N, `ports` AS P
                   WHERE A.`port_id` = P.`port_id` AND P.`device_id` != ?
                   AND A.`ipv4_network_id` = ? AND N.`ipv4_network_id` = A.`ipv4_network_id`
                   AND P.`ifAdminStatus` = "up"';
                        $params = array($device['device_id'], $network_id);
                        foreach (dbFetchRows($sql, $params) as $new) {
                            if ($cache['devices']['id'][$new['device_id']]['disabled'] && !$config['web_show_disabled']) {
                                continue;
                            }
                            $int_links[$new['port_id']] = $new['port_id'];
                            $int_links_v4[$new['port_id']][] = $new['ipv4_network'];
                        }
                    }
                }
                // Populate links array for devices which share an IPv6 subnet
                if (!isset($cache['ports_option']['ipv6_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv6_addresses'])) {
                    foreach (dbFetchColumn("SELECT DISTINCT(`ipv6_network_id`) FROM `ipv6_addresses`\n                                 LEFT JOIN `ipv6_networks` USING(`ipv6_network_id`)\n                                 WHERE `port_id` = ? AND `ipv6_network` NOT IN (?);", array($port['port_id'], $config['ignore_common_subnet'])) as $network_id) {
                        $sql = "SELECT N.*, P.`port_id`, P.`device_id` FROM `ipv6_addresses` AS A, `ipv6_networks` AS N, `ports` AS P\n                   WHERE A.`port_id` = P.`port_id` AND P.device_id != ?\n                   AND A.`ipv6_network_id` = ? AND N.`ipv6_network_id` = A.`ipv6_network_id`\n                   AND P.`ifAdminStatus` = 'up' AND A.`ipv6_origin` != 'linklayer' AND A.`ipv6_origin` != 'wellknown'";
                        $params = array($device['device_id'], $network_id);
                        foreach (dbFetchRows($sql, $params) as $new) {
                            if ($cache['devices']['id'][$new['device_id']]['disabled'] && !$config['web_show_disabled']) {
                                continue;
                            }
                            $int_links[$new['port_id']] = $new['port_id'];
                            $int_links_v6[$new['port_id']][] = $new['ipv6_network'];
                        }
                    }
                }
                // Output contents of links array
                foreach ($int_links as $int_link) {
                    $link_if = get_port_by_id_cache($int_link);
                    if (!device_permitted($link_if['device_id'])) {
                        continue;
                    }
                    // Skip not permitted links
                    $link_dev = device_by_id_cache($link_if['device_id']);
                    $string .= $br;
                    if ($int_links_phys[$int_link]) {
                        $string .= '<a data-alt="Directly connected" class="oicon-connect"></a> ';
                    } else {
                        $string .= '<a data-alt="Same subnet" class="oicon-network-hub"></a> ';
                    }
                    $string .= '<b>' . generate_port_link($link_if, $link_if['port_label_short']) . ' on ' . generate_device_link($link_dev, short_hostname($link_dev['hostname'])) . '</b>';
                    ## FIXME -- do something fancy here.
                    if ($int_links_v6[$int_link]) {
                        $string .= '&nbsp;' . overlib_link('', '<span class="label label-success">IPv6</span>', implode("<br />", $int_links_v6[$int_link]), NULL);
                    }
                    if ($int_links_v4[$int_link]) {
                        $string .= '&nbsp;' . overlib_link('', '<span class="label label-info">IPv4</span>', implode("<br />", $int_links_v4[$int_link]), NULL);
                    }
                    $br = "<br />";
                }
                // Output content of unknown links array (where ports don't exist in our database, or they weren't matched)
                foreach ($int_links_unknown as $int_link) {
                    // FIXME -- Expose platform and version here.
                    $string .= '<a data-alt="Directly connected" class="oicon-plug-connect"></a> ';
                    $string .= '<b><i>' . short_ifname($int_link['remote_port']) . '</i></b> on ';
                    $string .= '<i><b>' . generate_tooltip_link(NULL, $int_link['remote_hostname'], '<div class="small" style="max-width: 500px;"><b>' . $int_link['remote_platform'] . '</b><br />' . $int_link['remote_version'] . '</div>') . '</b></i>';
                    $string .= '<br />';
                }
            }
            if (!isset($cache['ports_option']['pseudowires']) || in_array($port['port_id'], $cache['ports_option']['pseudowires'])) {
                foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `port_id` = ?", array($port['port_id'])) as $pseudowire) {
                    //`port_id`,`peer_device_id`,`peer_ldp_id`,`pwID`,`pwIndex`
                    #    $pw_peer_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($pseudowire['peer_device_id']));
                    $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, `pseudowires` AS P WHERE I.`device_id` = ? AND P.`pwID` = ? AND P.`port_id` = I.`port_id`", array($pseudowire['peer_device_id'], $pseudowire['pwID']));
                    #    $pw_peer_int = get_port_by_id_cache($pseudowire['peer_device_id']);
                    $pw_peer_dev = device_by_id_cache($pseudowire['peer_device_id']);
                    if (is_array($pw_peer_int)) {
                        humanize_port($pw_peer_int);
                        $string .= $br . '<i class="oicon-arrow-switch"></i> <strong>' . generate_port_link($pw_peer_int, $pw_peer_int['port_label_short']) . ' on ' . generate_device_link($pw_peer_dev, short_hostname($pw_peer_dev['hostname'])) . '</strong>';
                    } else {
                        $string .= $br . '<i class="oicon-arrow-switch"></i> <strong> VC ' . $pseudowire['pwID'] . ' on ' . $pseudowire['peer_addr'] . '</strong>';
                    }
                    $string .= ' <span class="label">' . $pseudowire['pwPsnType'] . '</span>';
                    $string .= ' <span class="label">' . $pseudowire['pwType'] . '</span>';
                    $br = "<br />";
                }
            }
            if (!isset($cache['ports_option']['ports_pagp']) || in_array($port['ifIndex'], $cache['ports_option']['ports_pagp'])) {
                foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? AND `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) {
                    humanize_port($member);
                    $pagp[$device['device_id']][$port['ifIndex']][$member['ifIndex']] = TRUE;
                    $string .= $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($member) . ' [PAgP]</strong>';
                    $br = "<br />";
                }
            }
            if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) {
                $pagp[$device['device_id']][$port['pagpGroupIfIndex']][$port['ifIndex']] = TRUE;
                $parent = dbFetchRow("SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ?", array($port['pagpGroupIfIndex'], $device['device_id']));
                humanize_port($parent);
                $string .= $br . '<i class="oicon-arrow-split"></i> <strong>' . generate_port_link($parent) . ' [PAgP]</strong>';
                $br = "<br />";
            }
            if (!isset($cache['ports_option']['ports_stack_low']) || in_array($port['ifIndex'], $cache['ports_option']['ports_stack_low'])) {
                foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if) {
                    if ($higher_if['port_id_high']) {
                        if ($pagp[$device['device_id']][$higher_if['port_id_high']][$port['ifIndex']]) {
                            continue;
                        }
                        // Skip if same PAgP port
                        $this_port = get_port_by_index_cache($device['device_id'], $higher_if['port_id_high']);
                        if (is_array($this_port)) {
                            $string .= $br . '<i class="oicon-arrow-split"></i> <strong>' . generate_port_link($this_port) . '</strong>';
                            $br = "<br />";
                        }
                    }
                }
            }
            if (!isset($cache['ports_option']['ports_stack_high']) || in_array($port['ifIndex'], $cache['ports_option']['ports_stack_high'])) {
                foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if) {
                    if ($lower_if['port_id_low']) {
                        if ($pagp[$device['device_id']][$port['ifIndex']][$lower_if['port_id_low']]) {
                            continue;
                        }
                        // Skip if same PAgP ports
                        $this_port = get_port_by_index_cache($device['device_id'], $lower_if['port_id_low']);
                        if (is_array($this_port)) {
                            $string .= $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($this_port) . '</strong>';
                            $br = "<br />";
                        }
                    }
                }
            }
            unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
            $string .= '</td></tr>';
        }
    }
    // End Detailed View
    // If we're showing graphs, generate the graph and print the img tags
    if ($vars['graph'] == "etherlike") {
        $graph_file = get_port_rrdfilename($port, "dot3", TRUE);
    } else {
        $graph_file = get_port_rrdfilename($port, NULL, TRUE);
    }
    if ($vars['graph'] && is_file($graph_file)) {
        $string .= '<tr><td colspan="' . $table_cols . '">';
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $port['port_id'];
        $graph_array['type'] = 'port_' . $vars['graph'];
        $string .= generate_graph_row($graph_array);
        $string .= '</td></tr>';
    }
    return $string;
}
コード例 #12
0
            <td>';
if ($check['suppress_recovery'] || TRUE) {
    echo '<span class="label label-suppressed" title="Recovery notification suppressed">No Recovery</span><br />';
}
if ($check['delay'] > 0 || TRUE) {
    echo '<span class="label label-delayed">Delay ' . $check['delay'] . '</span><br />';
}
echo '
            </td>
            <td><i>' . $check['status_numbers'] . '</i><br />';
if (count($contacts)) {
    $content = "";
    foreach ($contacts as $contact) {
        $content .= '<span class="label">' . $contact['contact_method'] . '</span> ' . $contact['contact_descr'] . '<br />';
    }
    echo generate_tooltip_link('', '<span class="label label-success">' . count($contacts) . ' Notifiers</span>', $content);
} else {
    echo '<span class="label label-primary">Default Notifier</span>';
}
echo '</td>
          </tr>
        </tbody></table>' . PHP_EOL;
echo generate_box_close();
echo '
  </div>
</div>';
// Build group-specific navbar
$navbar = array('brand' => escape_html($check['alert_name']), 'class' => "navbar-narrow");
$navbar['options']['entries'] = array('text' => 'Alert Entries');
$navbar['options']['details'] = array('text' => 'Alert Details');
if ($_SESSION['userlevel'] == '10') {
コード例 #13
0
ファイル: contact.inc.php プロジェクト: Natolumin/observium
    if (count($data['parameters']['required'])) {
        $form['row'][++$i]['contact_required'] = array('type' => 'raw', 'html' => '<strong>Required parameters:</strong>');
        foreach (array_merge($data['parameters']['required'], $data['parameters']['global']) as $parameter => $param_data) {
            $form['row'][++$i]['contact_endpoint_' . $parameter] = array('type' => 'text', 'width' => '80%', 'name' => $param_data['description'], 'readonly' => $readonly, 'value' => $contact['endpoint_parameters'][$parameter]);
            if (isset($param_data['tooltip'])) {
                $form['row'][$i]['tooltip_' . $parameter] = array('type' => 'raw', 'readonly' => $readonly, 'html' => generate_tooltip_link(NULL, '<i class="oicon-question"></i>', $param_data['tooltip']));
                //echo(generate_tooltip_link(NULL, '<i class="oicon-question"></i>', $param_data['tooltip']));
            }
        }
    }
    if (count($data['parameters']['optional'])) {
        $form['row'][++$i]['contact_optional'] = array('type' => 'raw', 'html' => '<strong>Optional parameters:</strong>');
        foreach ($data['parameters']['optional'] as $parameter => $param_data) {
            $form['row'][++$i]['contact_endpoint_' . $parameter] = array('type' => 'text', 'width' => '80%', 'name' => $param_data['description'], 'readonly' => $readonly, 'value' => $contact['endpoint_parameters'][$parameter]);
            if (isset($param_data['tooltip'])) {
                $form['row'][$i]['tooltip_' . $parameter] = array('type' => 'raw', 'readonly' => $readonly, 'html' => generate_tooltip_link(NULL, '<i class="oicon-question"></i>', $param_data['tooltip']));
                //echo(generate_tooltip_link(NULL, '<i class="oicon-question"></i>', $param_data['tooltip']));
            }
        }
    }
    $form['row'][++$i]['submit'] = array('type' => 'submit', 'name' => 'Save Changes', 'icon' => 'icon-ok icon-white', 'right' => TRUE, 'class' => 'btn-primary', 'readonly' => $readonly, 'value' => 'update-contact-entry');
    //r($form);
    print_form($form);
    unset($form, $i);
    ?>

  </div>

 <div class="col-sm-6">

<?php 
コード例 #14
0
ファイル: navbar.inc.php プロジェクト: Natolumin/observium
} else {
    $ua['icon'] = 'icon-laptop';
}
$ua['content'] = 'Your current IP:&nbsp;' . $_SERVER['REMOTE_ADDR'] . '<br />';
if ($config['web_mouseover'] && $ua['browser'] != 'mobile') {
    // Add popup with current IP and previous session
    $last_id = dbFetchCell("SELECT `id` FROM `authlog` WHERE `user` = ? AND `result` LIKE 'Logged In%' ORDER BY `id` DESC LIMIT 1;", array($_SESSION['username']));
    $ua['previous_session'] = dbFetchRow("SELECT * FROM `authlog` WHERE `user` = ? AND `id` < ? AND `result` LIKE 'Logged In%' ORDER BY `id` DESC LIMIT 1;", array($_SESSION['username'], $last_id));
    if ($ua['previous_session']) {
        $ua['previous_browser'] = detect_browser($ua['previous_session']['user_agent']);
        $ua['content'] .= '<hr><span class="small">Previous session from&nbsp;<em class="pull-right">' . ($_SESSION['userlevel'] > 5 ? $ua['previous_session']['address'] : preg_replace('/^\\d+/', '*', $ua['previous_session']['address'])) . '</em></span>';
        $ua['content'] .= '<br /><span class="small pull-right"><em> at ' . format_timestamp($ua['previous_session']['datetime']) . '</span>';
        $ua['content'] .= '<br /><span class="small pull-right"><i class="' . $ua['previous_browser']['icon'] . '"></i>&nbsp;' . $ua['previous_browser']['browser_full'] . ' (' . $ua['previous_browser']['platform'] . ')' . '</em></span>';
    }
}
echo '<li>' . generate_tooltip_link($ua['url'], ' <i class="' . $ua['icon'] . '"></i>', $ua['content']) . '</li>';
?>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="oicon-gear"></i> <b class="caret"></b></a>
              <ul class="dropdown-menu">
<?php 
// Refresh menu
echo '<li class="dropdown-submenu">';
echo '  <a tabindex="-1" href="' . generate_url($vars) . '"><i class="oicon-arrow-circle"></i> Refresh <span id="countrefresh"></span></a>';
echo '  <ul class="dropdown-menu">';
foreach ($page_refresh['list'] as $refresh_time) {
    $refresh_class = $refresh_time == $page_refresh['current'] ? 'active' : '';
    if (!$page_refresh['allowed']) {
        $refresh_class = 'disabled';
    }
    if ($refresh_time == 0) {
コード例 #15
0
ファイル: sla.inc.php プロジェクト: Natolumin/observium
function generate_sla_row($sla, $vars)
{
    global $config;
    humanize_sla($sla);
    $table_cols = "8";
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $sla['sla_id'];
    $graph_array['type'] = $sla['graph_type'];
    $graph_array['legend'] = "no";
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    if ($sla['rtt_event'] && $sla['rtt_sense']) {
        $mini_graph = generate_graph_tag($graph_array);
    } else {
        // Do not show "Draw Error" minigraph
        $mini_graph = '';
    }
    $out = '<tr class="' . $sla['row_class'] . '"><td class="state-marker"></td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $out .= '<td class="entity">' . generate_device_link($sla) . '</td>';
        $table_cols++;
    }
    $out .= '<td class="entity">' . generate_entity_link('sla', $sla) . '</td>';
    $out .= '<td>' . $sla['sla_owner'] . '</td>';
    $out .= '<td>' . $sla['rtt_label'] . '</td>';
    $out .= '<td>' . generate_entity_link('sla', $sla, $mini_graph, NULL, FALSE) . '</td>';
    $out .= '<td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $sla['rtt_last_change'], 'short-2') . ' ago', format_unixtime($sla['rtt_last_change'])) . '</td>';
    $out .= '<td style="text-align: right;"><strong><span class="' . $sla['rtt_class'] . '">' . $sla['rtt_event'] . '</span></strong></td>';
    $out .= '<td style="text-align: right;"><strong><span class="' . $sla['rtt_class'] . '">' . $sla['rtt_sense'] . '</span></strong></td>';
    $out .= '<td><span class="' . $sla['sla_class'] . '">' . $sla['human_value'] . $sla['human_unit'] . '</span></td>';
    $out .= '</tr>';
    if ($vars['graph'] || $vars['view'] == "graphs" || $vars['id'] == $sla['sla_id']) {
        // If id set in vars, display only specific graphs
        $graph_array = array();
        $graph_array['type'] = $sla['graph_type'];
        $graph_array['id'] = $sla['sla_id'];
        $out .= '<tr class="' . $sla['row_class'] . '">';
        $out .= '  <td class="state-marker"></td>';
        $out .= '  <td colspan="' . $table_cols . '">';
        $out .= generate_graph_row($graph_array, TRUE);
        $out .= '  </td>';
        $out .= '</tr>';
    }
    return $out;
}
コード例 #16
0
ファイル: sensor.inc.php プロジェクト: Natolumin/observium
function generate_sensor_row($sensor, $vars)
{
    global $config;
    humanize_sensor($sensor);
    $table_cols = 4;
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $sensor['sensor_id'];
    $graph_array['type'] = "sensor_graph";
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    if ($sensor['sensor_event'] && is_numeric($sensor['sensor_value'])) {
        $mini_graph = generate_graph_tag($graph_array);
    } else {
        // Do not show "Draw Error" minigraph
        $mini_graph = '';
    }
    $row = '
      <tr class="' . $sensor['row_class'] . '">
        <td class="state-marker"></td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $row .= '        <td class="entity">' . generate_device_link($sensor) . '</td>' . PHP_EOL;
        $table_cols++;
    }
    if ($vars['entity_icon'] == TRUE) {
        $row .= '        <td width="20px"><i class="' . $config['sensor_types'][$sensor['sensor_class']]['icon'] . '"></i></td>';
    }
    $row .= '        <td class="entity">' . generate_entity_link("sensor", $sensor) . '</td>';
    if ($vars['show_class']) {
        $row .= '        <td>' . nicecase($sensor['sensor_class']) . '</td>' . PHP_EOL;
        $table_cols++;
    }
    if ($vars['tab'] != 'overview') {
        $row .= '        <td><span class="label ' . ($sensor['sensor_custom_limit'] ? 'label-warning' : '') . '">' . $sensor['sensor_thresholds'] . '</span></td>' . PHP_EOL;
        $table_cols++;
    }
    $row .= '        <td style="width: 90px; text-align: right;">' . generate_entity_link('sensor', $sensor, $mini_graph, NULL, FALSE) . '</td>';
    if ($vars['tab'] != 'overview') {
        $row .= '        <td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $sensor['sensor_last_change'], 'short-2') . ' ago', format_unixtime($sensor['sensor_last_change'])) . '</td>';
        $table_cols++;
        $row .= '        <td style="text-align: right;"><strong><span class="' . $sensor['state_class'] . '">' . $sensor['sensor_event'] . '</span></strong></td>';
        $table_cols++;
    }
    $row .= '        <td style="width: 80px; text-align: right;"><strong><span class="' . $sensor['state_class'] . '">' . $sensor['human_value'] . $sensor['sensor_symbol'] . '</span></strong>
        </tr>' . PHP_EOL;
    if ($vars['view'] == "graphs" || $vars['id'] == $sensor['sensor_id']) {
        $vars['graph'] = "graph";
    }
    if ($vars['graph']) {
        $row .= '
      <tr class="' . $sensor['row_class'] . '">
        <td class="state-marker"></td>
        <td colspan="' . $table_cols . '">';
        $graph_array = array();
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $sensor['sensor_id'];
        $graph_array['type'] = 'sensor_' . $vars['graph'];
        $row .= generate_graph_row($graph_array, TRUE);
        $row .= '</td></tr>';
    }
    # endif graphs
    return $row;
}
コード例 #17
0
ファイル: logalert.inc.php プロジェクト: Natolumin/observium
/**
 * 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;
}
コード例 #18
0
ファイル: mibs.inc.php プロジェクト: Natolumin/observium
     $error_rate = isset($error_codes[$error_db['error_code']]['rate']) && $error_codes[$error_db['error_code']]['rate'] < $error_db['error_rate'];
     if ($error_both) {
         $error_exceeded = $error_count && $error_rate;
     } else {
         $error_exceeded = $error_count || $error_rate;
     }
     if ($error_exceeded) {
         $error_class = 'danger';
         $error_class2 = 'error';
     } else {
         $error_class = $error_class2 = 'warning';
     }
     $text_class = count(explode(' ', $error_db['oid'])) > 3 ? '' : 'text-nowrap';
     echo '<tr width="100%" class="' . $error_class2 . '"><td style="width: 50%;" class="' . $text_class . '"><strong><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;' . $error_db['oid'] . '</strong></td>' . PHP_EOL;
     $timediff = $GLOBALS['config']['time']['now'] - $error_db['updated'];
     echo '<td style="width: 100px; white-space: nowrap; text-align: right;">' . generate_tooltip_link('', formatUptime($timediff, "short-3") . ' ago', format_unixtime($error_db['updated'])) . '</td>' . PHP_EOL;
     echo '<td style="width: 80px; white-space: nowrap;"><span class="text-' . $error_class . '">' . $error_codes[$error_db['error_code']]['reason'] . '</span></td>' . PHP_EOL;
     echo '<td style="width: 40px; text-align: right;"><span class="label">' . $error_db['error_count'] . '</span></td>' . PHP_EOL;
     echo '<td style="width: 80px; text-align: right;"><span class="label">' . round($error_db['error_rate'], 2) . '/poll</span></td>' . PHP_EOL;
     echo '<td>' . PHP_EOL;
     $form = array('type' => 'simple');
     // Elements
     $form['row'][0]['mib'] = array('type' => 'hidden', 'value' => $mib);
     $form['row'][0]['toggle_oid'] = array('type' => 'hidden', 'value' => $error_db['oid']);
     $form['row'][0]['submit'] = array('type' => 'submit', 'name' => '', 'class' => 'btn-mini btn-' . $error_class, 'icon' => $btn_icon, 'right' => TRUE, 'readonly' => $readonly, 'disabled' => TRUE, 'value' => 'toggle_oid');
     print_form($form);
     unset($form);
     echo '</td>' . PHP_EOL;
     echo '</td></tr>' . PHP_EOL;
 }
 echo '  </table>