* * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ $minutes = 15; $seconds = $minutes * 60; $top = $config['front_page_settings']['top']['ports']; $query = " SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total FROM ports as p, devices as d WHERE d.device_id = p.device_id AND unix_timestamp() - p.poll_time < $seconds ORDER BY total desc LIMIT $top "; echo("Top $top ports (last $minutes minutes)"); echo(''); foreach (dbFetchRows($query) as $result) { echo(''); } echo('
'.$result['hostname'].''.$result['ifIndex'].''.$result['ifDescr'].''.$result['total'].'
'); /* // FIXME: Change to port_rrd_exists($device, $port) if (file_exists($config['rrd_dir'] . "/" . $device['hostname'] . "/port-". $port['ifIndex'] . ".rrd")) { $iid = $id; echo("
Interface Traffic
"); $graph_type = "port_bits"; include("includes/print-interface-graphs.inc.php"); echo("
Interface Packets
"); $graph_type = "port_upkts"; include("includes/print-interface-graphs.inc.php"); echo("
Interface Non Unicast
"); $graph_type = "port_nupkts"; include("includes/print-interface-graphs.inc.php"); echo("
Interface Errors
"); $graph_type = "port_errors"; include("includes/print-interface-graphs.inc.php"); if (is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . $port['ifIndex'] . "-dot3.rrd")) { echo("
Ethernet Errors
"); $graph_type = "port_etherlike"; include("includes/print-interface-graphs.inc.php"); } } */ /* from html/includes/print-interface.inc.php: generate_port_link($port, $port['ifIndex'] . ". ".$port['label']) */ /* from html/includes/functions.inc.php: function generate_port_link($port, $text = NULL, $type = NULL) { global $config; $port = ifNameDescr($port); if (!$text) { $text = fixIfName($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['hostname'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); } $content = "
".$port['hostname']." - " . fixifName($port['label']) . "
"; if ($port['ifAlias']) { $content .= $port['ifAlias']."
"; } $content .= "
"; $graph_array['type'] = $port['graph_type']; $graph_array['legend'] = "yes"; $graph_array['height'] = "100"; $graph_array['width'] = "340"; $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 .= "
"; $url = generate_port_url($port); if (port_permitted($port['port_id'], $port['device_id'])) { return overlib_link($url, $text, $content, $class); } else { return fixifName($text); } } */ /* includes/print-interface-graphs.inc.php: global $config; $graph_array['height'] = "100"; $graph_array['width'] = "215"; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $port['port_id']; $graph_array['type'] = $graph_type; include("includes/print-graphrow.inc.php"); */ /* html/includes/print-graphrow.inc.php: global $config; if($_SESSION['widescreen']) { if (!$graph_array['height']) { $graph_array['height'] = "110"; } if (!$graph_array['width']) { $graph_array['width'] = "215"; } $periods = array('sixhour', 'day', 'week', 'month', 'year', 'twoyear'); } else { if (!$graph_array['height']) { $graph_array['height'] = "100"; } if (!$graph_array['width']) { $graph_array['width'] = "215"; } $periods = array('day', 'week', 'month', 'year'); } $graph_array['to'] = $config['time']['now']; foreach ($periods as $period) { $graph_array['from'] = $config['time'][$period]; $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; $link_array = $graph_array; $link_array['page'] = "graphs"; unset($link_array['height'], $link_array['width']); $link = generate_url($link_array); echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); } function overlib_link($url, $text, $contents, $class) { global $config; $contents = str_replace("\"", "\'", $contents); $output = '"; $output .= $text.""; return $output; } function print_graph_tag($args) { echo(generate_graph_tag($args)); } function generate_graph_tag($args) { foreach ($args as $key => $arg) { $urlargs[] = $key."=".$arg; } return ''; } function generate_port_url($port, $vars=array()) { return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']), $vars); } function generate_link($text, $vars, $new_vars = array()) { return ''.$text.''; } function generate_url($vars, $new_vars = array()) { $vars = array_merge($vars, $new_vars); $url = $vars['page']."/"; unset($vars['page']); foreach ($vars as $var => $value) { if ($value == "0" || $value != "" && strstr($var, "opt") === FALSE && is_numeric($var) === FALSE) { $url .= $var ."=".$value."/"; } } return($url); } */ ?>