function generate_device_popup_header($device, $vars = array())
{
    global $config;
    humanize_device($device);
    if ($device['os'] == "ios") {
        formatCiscoHardware($device, TRUE);
    }
    // FIXME or generic function for more than just IOS? [and/or do this at poll time]
    $contents = '
<table class="table table-striped table-bordered table-rounded table-condensed">
  <tr class="' . $device['html_row_class'] . '" style="font-size: 10pt;">
    <td class="state-marker"></td>
    <td width="40" style="padding: 10px; text-align: center; vertical-align: middle;">' . get_device_icon($device) . '</td>
    <td width="200"><a href="#" class="' . $class . '" style="font-size: 15px; font-weight: bold;">' . escape_html($device['hostname']) . '</a><br />' . escape_html(truncate($device['location'], 64, '')) . '</td>
    <td>' . escape_html($device['hardware']) . ' <br /> ' . $device['os_text'] . ' ' . escape_html($device['version']) . '</td>
    <td>' . deviceUptime($device, 'short') . '<br />' . escape_html($device['sysName']) . '
  </tr>
</table>
';
    return $contents;
}
Example #2
0
    $class = 'bg-danger';
} else {
    $class = 'bg-primary';
}
if ($device['ignore'] == '1') {
    $class = 'bg-warning';
    if ($device['status'] == '1') {
        $class = 'bg-success';
    }
}
if ($device['disabled'] == '1') {
    $class = 'bg-info';
}
$type = strtolower($device['os']);
if ($device['os'] == 'ios') {
    formatCiscoHardware($device, true);
}
$device['os_text'] = $config['os'][$device['os']]['text'];
echo '  <tr>
          <td class="' . $class . ' "></td>
          <td>' . $image . '</td>
          <td><span style="font-size: 15px;">' . generate_device_link($device) . '</span></td>';
echo '<td>';
if ($port_count) {
    echo ' <img src="images/icons/port.png" align=absmiddle /> ' . $port_count;
}
echo '<br />';
if ($sensor_count) {
    echo ' <img src="images/icons/sensors.png" align=absmiddle /> ' . $sensor_count;
}
echo '</td>';
Example #3
0
 * @package    observium
 * @subpackage webui
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
?>
<div class="well info_box">
    <div class="title"><i class="oicon-server"></i> Device Information</div>
    <div class="content">
<?php 
if ($config['overview_show_sysDescr']) {
    echo '<div style="font-family: courier, serif; margin: 3px"><strong>' . $device['sysDescr'] . "</strong></div>";
}
if ($device['os'] == "ios") {
    formatCiscoHardware($device);
}
// FIXME or do this in a general function for all OS types with a switch($device['os']) ?
echo '<table class="table table-condensed-more table-striped table-bordered">';
if ($device['purpose']) {
    echo '<tr>
        <td class="entity">Description</td>
        <td>' . htmlspecialchars($device['purpose']) . '</td>
      </tr>';
}
if ($device['hardware']) {
    echo '<tr>
        <td class="entity">Hardware</td>
        <td>' . htmlspecialchars($device['hardware']) . '</td>
      </tr>';
}
function generate_device_link_header($device, $vars = array())
{
    global $config;
    if (isset($device['humanized_device']) == FALSE) {
        humanize_device($device);
    }
    if ($device['os'] == "ios") {
        formatCiscoHardware($device, true);
    }
    #  print_r($device);
    $contents = '
      <table class="table table-striped table-bordered table-rounded table-condensed">
        <tr class="' . $device['html_row_class'] . '" style="font-size: 10pt;">
          <td style="width: 10px; background-color: ' . $device['html_tab_colour'] . '; margin: 0px; padding: 0px"></td>
          <td width="40" style="padding: 10px; text-align: center; vertical-align: middle;">' . getImage($device) . '</td>
          <td width="200"><a href="#" class="' . $class . '" style="font-size: 15px; font-weight: bold;">' . $device['hostname'] . '</a><br />' . truncate($device['location'], 64, '') . '</td>
          <td>' . $device['hardware'] . ' <br /> ' . $device['os_text'] . ' ' . $device['version'] . '</td>
          <td>' . deviceUptime($device, 'short') . '<br />' . $device['sysName'] . '
          </tr>
        </table>
';
    return $contents;
}
function print_device_hostbox($device, $mode = 'basic')
{
    global $config;
    if (!is_array($device)) {
        print_error("Invalid device passed to print_device_hostbox()!");
    }
    if ($device['os'] == "ios") {
        formatCiscoHardware($device, TRUE);
    }
    humanize_device($device);
    $hostbox_tags = array('html_row_class' => $device['html_row_class'], 'device_id' => $device['device_id'], 'device_link' => generate_device_link($device), 'hardware' => escape_html($device['hardware']), 'features' => escape_html($device['features']), 'os_text' => $device['os_text'], 'version' => escape_html($device['version']), 'sysName' => escape_html($device['sysName']), 'device_uptime' => deviceUptime($device, 'short'), 'location' => escape_html(truncate($device['location'], 32, '')));
    switch ($mode) {
        case 'detail':
        case 'details':
            $hostbox_tags['device_image'] = get_device_icon($device);
            $hostbox_tags['ports_count'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?;", array($device['device_id']));
            $hostbox_tags['sensors_count'] = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?;", array($device['device_id']));
            $hostbox = '
  <tr class="' . $hostbox_tags['html_row_class'] . '" onclick="location.href=\'device/device=' . $hostbox_tags['device_id'] . '/\'" style="cursor: pointer;">
    <td class="state-marker"></td>
    <td style="width: 64px; text-align: center; vertical-align: middle;">' . $hostbox_tags['device_image'] . '</td>
    <td style="width: 300px;"><span class="entity-title">' . $hostbox_tags['device_link'] . '</span><br />' . $hostbox_tags['location'] . '</td>
    <td style="width: 55px;">';
            if ($hostbox_tags['ports_count']) {
                $hostbox .= '<i class="oicon-network-ethernet"></i> ' . $hostbox_tags['ports_count'];
            }
            $hostbox .= '<br />';
            if ($hostbox_tags['sensors_count']) {
                $hostbox .= '<i class="oicon-dashboard"></i> ' . $hostbox_tags['sensors_count'];
            }
            $hostbox .= '</td>
    <td>' . $hostbox_tags['hardware'] . '<br />' . $hostbox_tags['features'] . '</td>
    <td>' . $hostbox_tags['os_text'] . '<br />' . $hostbox_tags['version'] . '</td>
    <td>' . $hostbox_tags['device_uptime'] . '<br />' . $hostbox_tags['sysName'] . '</td>
  </tr>';
            break;
        case 'status':
            $hostbox_tags['device_image'] = get_device_icon($device);
            // Graphs
            $graph_array = array();
            $graph_array['height'] = "100";
            $graph_array['width'] = "310";
            $graph_array['to'] = $config['time']['now'];
            $graph_array['device'] = $device['device_id'];
            $graph_array['type'] = "device_bits";
            $graph_array['from'] = $config['time']['day'];
            $graph_array['legend'] = "no";
            $graph_array['height'] = "45";
            $graph_array['width'] = "175";
            $graph_array['bg'] = "FFFFFF00";
            if (isset($config['os'][$device['os']]['over'])) {
                $graphs = $config['os'][$device['os']]['over'];
            } else {
                if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) {
                    $graphs = $config['os'][$device['os_group']]['over'];
                } else {
                    $graphs = $config['os']['default']['over'];
                }
            }
            // Preprocess device graphs array
            foreach ($GLOBALS['device_graphs'][$device['device_id']] as $graph) {
                $graphs_enabled[] = $graph['graph'];
            }
            foreach ($graphs as $entry) {
                if ($entry['graph'] && in_array(str_replace('device_', '', $entry['graph']), $graphs_enabled)) {
                    $graph_array['type'] = $entry['graph'];
                    $graph_array['popup_title'] = $entry['text'];
                    $hostbox_tags['graphs'][] = generate_graph_popup($graph_array);
                }
            }
            $hostbox = '
  <tr class="' . $hostbox_tags['html_row_class'] . '" onclick="location.href=\'device/device=' . $hostbox_tags['device_id'] . '/\'" style="cursor: pointer;">
    <td class="state-marker"></td>
    <td style="width: 64px; text-align: center; vertical-align: middle;">' . $hostbox_tags['device_image'] . '</td>
    <td style="width: 300px;"><span class="entity-title">' . $hostbox_tags['device_link'] . '</span><br />' . $hostbox_tags['location'] . '</td>
    <td>';
            if ($hostbox_tags['graphs']) {
                $hostbox .= '<div class="pull-right" style="height: 50px; padding: 2px; margin: 0;">' . implode($hostbox_tags['graphs']) . '</div>';
            }
            $hostbox .= '</td>
  </tr>';
            break;
        default:
            // basic
            $hostbox = '
  <tr class="' . $hostbox_tags['html_row_class'] . '" onclick="location.href=\'device/device=' . $hostbox_tags['device_id'] . '/\'" style="cursor: pointer;">
    <td style="width: 300;"><span class="entity-title">' . $hostbox_tags['device_link'] . '</span><br />' . $hostbox_tags['location'] . '</td>
    <td>' . $hostbox_tags['hardware'] . ' ' . $hostbox_tags['features'] . '</td>
    <td>' . $hostbox_tags['os_text'] . ' ' . $hostbox_tags['version'] . '</td>
    <td>' . $hostbox_tags['device_uptime'] . '</td>
  </tr>';
    }
    echo $hostbox;
}