Example #1
0
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;
}
echo '<table class="table ' . $stripe_class . ' table-condensed table-bordered">';
echo '
      <thead><tr>
        <th class="state-marker"></th> 
        <th>' . nicecase($vars['metric']) . '</th>
        <th width="200">Physical Class</th>
        <th width="100">Historical</th>
        <th width="100">State</th>
      </tr></thead>';
$row = 1;
$sql = "SELECT *, `status`.`status_id` AS `status_id`";
$sql .= " FROM  `status`";
$sql .= " LEFT JOIN  `status-state` ON  `status`.status_id =  `status-state`.status_id";
$sql .= " WHERE `device_id` = ?";
foreach (dbFetchRows($sql, array($device['device_id'])) as $status) {
    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';
    # the 00 at the end makes the area transparent.
    $graph_array['from'] = $config['time']['day'];
    $mini_graph = generate_graph_tag($graph_array);
    $status_misc = '<span class="label">' . $status['entPhysicalClass'] . '</span>';