function generate_port_popup($port, $text = NULL, $type = NULL) { global $config; if (!isset($port['os'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); } humanize_port($port); if (!$text) { $text = rewrite_ifname($port['label']); } if ($type) { $port['graph_type'] = $type; } if (!isset($port['graph_type'])) { $port['graph_type'] = 'port_bits'; } $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); if (!isset($port['os'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); } $content = generate_device_popup_header($port); $content .= generate_port_popup_header($port); $content .= '<div style="width: 700px">'; $graph_array['type'] = $port['graph_type']; $graph_array['legend'] = "yes"; $graph_array['height'] = "100"; $graph_array['width'] = "275"; $graph_array['to'] = $config['time']['now']; $graph_array['from'] = $config['time']['day']; $graph_array['id'] = $port['port_id']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['week']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['month']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['year']; $content .= generate_graph_tag($graph_array); $content .= "</div>"; return $content; }
function generate_device_popup($device, $vars = array(), $start = 0, $end = 0) { global $config; if (!$start) { $start = $config['time']['day']; } if (!$end) { $end = $config['time']['now']; } $contents = generate_device_popup_header($device, $vars = array()); if (isset($config['os'][$device['os']]['over'])) { $graphs = $config['os'][$device['os']]['over']; } elseif (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 ($device['graphs'] as $graph) { $graphs_enabled[] = $graph['graph']; } foreach ($graphs as $entry) { $graph = $entry['graph']; if ($graph && in_array(str_replace('device_', '', $graph), $graphs_enabled) !== FALSE) { if (isset($entry['text'])) { // Text is provided in the array, this overrides the default $text = $entry['text']; } else { // No text provided for the minigraph, fetch from array preg_match('/^(?P<type>[a-z0-9A-Z-]+)_(?P<subtype>[a-z0-9A-Z-_]+)/', $graph, $graphtype); if (isset($graphtype['type']) && isset($graphtype['subtype'])) { $type = $graphtype['type']; $subtype = $graphtype['subtype']; $text = $config['graph_types'][$type][$subtype]['descr']; } else { $text = nicecase($subtype); // Fallback to the type itself as a string, should not happen! } } $contents .= ' <div style="width: 730px"> <span style="margin-left: 5px; font-size: 12px; font-weight: bold;">' . $text . '</span><br /> <img src="graph.php?device=' . $device['device_id'] . '&from=' . $start . '&to=' . $end . '&width=275&height=100&type=' . $graph . '&legend=no&draw_all=yes' . '" style="margin: 2px;"> <img src="graph.php?device=' . $device['device_id'] . '&from=' . $config['time']['week'] . '&to=' . $end . '&width=275&height=100&type=' . $graph . '&legend=no&draw_all=yes' . '" style="margin: 2px;"> </div>'; } } return $contents; }
function generate_entity_popup($entity, $vars) { if (is_numeric($entity)) { $entity = get_entity_by_id_cache($entity, $vars['entity_type']); } $device = device_by_id_cache($entity['device_id']); $content = generate_device_popup_header($device); $content .= generate_entity_popup_header($entity, $vars); $content .= generate_entity_popup_graphs($entity, $vars); return $content; }
function generate_device_popup($device, $vars = array(), $start = NULL, $end = NULL) { global $config; if (!$start) { $start = $config['time']['day']; } if (!$end) { $end = $config['time']['now']; } $content = generate_device_popup_header($device, $vars = array()); if (isset($config['os'][$device['os']]['graphs'])) { $graphs = $config['os'][$device['os']]['graphs']; } elseif (isset($device['os_group']) && isset($config['os'][$device['os_group']]['graphs'])) { $graphs = $config['os'][$device['os_group']]['graphs']; } else { $graphs = $config['os']['default']['graphs']; } // Preprocess device graphs array foreach ($device['graphs'] as $graph) { if ($graph['enabled'] != '0') { $graphs_enabled[] = $graph['graph']; } } foreach ($graphs as $entry) { $graph = $entry; if ($graph && in_array(str_replace('device_', '', $graph), $graphs_enabled) !== FALSE) { // No text provided for the minigraph, fetch from array preg_match('/^(?P<type>[a-z0-9A-Z-]+)_(?P<subtype>[a-z0-9A-Z-_]+)/', $graph, $graphtype); if (isset($graphtype['type']) && isset($graphtype['subtype'])) { $type = $graphtype['type']; $subtype = $graphtype['subtype']; $text = $config['graph_types'][$type][$subtype]['descr']; } else { $text = nicecase($subtype); // Fallback to the type itself as a string, should not happen! } // FIXME -- function! $graph_array = array(); $graph_array['height'] = "100"; $graph_array['width'] = "290"; $graph_array['to'] = $config['time']['now']; $graph_array['device'] = $device['device_id']; $graph_array['type'] = $graph; $graph_array['from'] = $config['time']['day']; $graph_array['legend'] = "no"; $graph_array['bg'] = "FFFFFF"; $content .= '<div style="width: 730px; white-space: nowrap;">'; $content .= "<div class=entity-title><h4>" . $text . "</h4></div>"; /* $content .= generate_box_open(array('title' => $text, 'body-style' => 'white-space: nowrap;')); */ $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['week']; $content .= generate_graph_tag($graph_array); $content .= '</div>'; //$content .= generate_box_close(); } } //r($content); return $content; }
/** * Returns a string containing an HTML to be used as a port popups * * @param array $port array * @param string $text to be used as port label * @param string $type graph type to be used in graphs (bits, nupkts, etc) * * @return string HTML port popup contents */ function generate_port_popup($port, $text = NULL, $type = NULL) { $time = $GLOBALS['config']['time']; if (!isset($port['os'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); } humanize_port($port); if (!$text) { $text = rewrite_ifname($port['port_label']); } if ($type) { $port['graph_type'] = $type; } if (!isset($port['graph_type'])) { $port['graph_type'] = 'port_bits'; } if (!isset($port['os'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); } $content = generate_device_popup_header($port); $content .= generate_port_popup_header($port); $content .= '<div style="width: 700px">'; //$content .= generate_box_open(array('body-style' => 'width: 700px;')); $graph_array['type'] = $port['graph_type']; $graph_array['legend'] = "yes"; $graph_array['height'] = "100"; $graph_array['width'] = "275"; $graph_array['to'] = $time['now']; $graph_array['from'] = $time['day']; $graph_array['id'] = $port['port_id']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $time['week']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $time['month']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $time['year']; $content .= generate_graph_tag($graph_array); $content .= "</div>"; //$content .= generate_box_close(); return $content; }