Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -6,89 +6,118 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
/// FIXME. Ohh noo.. someone FIX this huuuuuuge page
// Pagination
//echo(pagination($vars, $ports_count));
foreach ($ports as $port) {
// Populate ports array (much faster for large systems)
//r($port_ids);
$where = generate_where_clause(generate_query_values($ports_ids, 'ports.port_id'));
$speed = humanspeed($port['ifSpeed']);
$type = rewrite_iftype($port['ifType']);
$select = "`ports`.*, `ports`.`port_id` AS `port_id`";
$port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8);
$port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8);
include($config['html_dir'] . "/includes/port-sort-select.inc.php");
if ($port['in_errors'] > 0 || $port['out_errors'] > 0)
{
$error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", 'errors');
$sql = "SELECT " . $select;
$sql .= " FROM `ports`";
$sql .= " INNER JOIN `devices` USING (`device_id`)";
$sql .= " " . $where . generate_port_sort($vars); // . generate_query_limit($vars);
} else {
$error_img = '';
}
unset($ports);
humanize_port($port);
// End populating ports array
$graph_type = "port_" . $vars['graph'];
echo '<div class="row">';
$graph_array = array();
foreach (dbFetchRows($sql) as $port) {
$speed = humanspeed($port['ifSpeed']);
$type = rewrite_iftype($port['ifType']);
$port['in_rate'] = format_bps($port['ifInOctets_rate'] * 8);
$port['out_rate'] = format_bps($port['ifOutOctets_rate'] * 8);
if ($port['in_errors'] > 0 || $port['out_errors'] > 0) {
$error_img = generate_port_link($port, get_icon('error'), 'port_errors');
if ($_SESSION['widescreen'])
{
if ($config['graphs']['size'] === 'big') {
$width_div = 585;
$width = 507;
$height = 149;
$height_div = 220;
} else {
$width_div=349;
$width=275;
$height = 109;
$height_div = 180;
$error_img = '';
}
} else {
if ($config['graphs']['size'] === 'big') {
$width_div = 611;
$width = 528;
$height = 159;
$height_div = 218;
humanize_port($port);
$device = device_by_id_cache($port['device_id']);
//r($port);
$graph_type = "port_" . $vars['graph'];
$graph_array = [];
if ($_SESSION['widescreen']) {
if ($config['graphs']['size'] === 'big') {
$width_div = 585;
$width = 507;
$height = 149;
$height_div = 220;
} else {
$width_div = 349;
$width = 275;
$height = 109;
$height_div = 180;
}
} else {
$width_div=303;
$width=226;
$height = 102;
$height_div = 158;
if ($config['graphs']['size'] === 'big') {
$width_div = 611;
$width = 528;
$height = 159;
$height_div = 218;
} else {
$width_div = 303;
$width = 226;
$height = 102;
$height_div = 158;
}
}
}
if (isset($vars['from']) && is_numeric($vars['from']) && isset($vars['to']) && is_numeric($vars['to']))
{
$graph_array['from'] = $vars['from'];
$graph_array['to'] = $vars['to'];
} else {
$graph_array['from'] = $config['time']['day'];
$graph_array['to'] = $config['time']['now'];
}
if (isset($vars['from']) && is_numeric($vars['from']) && isset($vars['to']) && is_numeric($vars['to'])) {
$graph_array['from'] = $vars['from'];
$graph_array['to'] = $vars['to'];
} else {
$graph_array['from'] = get_time('day');
$graph_array['to'] = get_time();
}
$graph_array['height'] = 100;
$graph_array['width'] = 210;
$graph_array['id'] = $port['port_id'];
$graph_array['type'] = $graph_type;
$graph_array['legend'] = "no";
$graph_array['height'] = 100;
$graph_array['width'] = 210;
$graph_array['id'] = $port['port_id'];
$graph_array['type'] = $graph_type;
$graph_array['legend'] = "no";
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $port['hostname'] . ' - ' . $port['port_label']);
$graph_array['title'] = "yes";
$graph_array['width'] = $width;
$graph_array['height'] = $height;
$graph = generate_graph_tag($graph_array);
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $port['hostname'] . ' - ' . $port['port_label']);
//$graph_array['title'] = "yes";
$graph_array['width'] = $width;
$graph_array['height'] = $height;
$graph = generate_graph_tag($graph_array);
echo("<div style='display: block; padding: 1px; margin: 2px; min-width: ".$width_div."px; max-width:".$width_div."px; min-height:".$height_div."px; max-height:".$height_div."; text-align: center; float: left; background-color: #f5f5f5;'>");
echo(overlib_link($link, $graph, $overlib_content));
echo("</div>");
echo generate_box_open(['title' => short_hostname($device['hostname']) . ' :: ' . $port['port_label_short'],
'url' => generate_port_url($port),
'header-border' => TRUE,
'box-style' => 'float: left; margin-left: 10px; margin-bottom: 10px; width:' . $width_div . 'px; min-width: ' . $width_div . 'px; max-width:' . $width_div . 'px; min-height:' . $height_div . 'px; max-height:' . $height_div . ';']);
echo overlib_link($link, $graph, $overlib_content);
echo generate_box_close();
}
echo '</div>';
// EOF

View File

@ -6,70 +6,72 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
// Pagination
echo(pagination($vars, $ports_count));
if ($vars['pageno']) {
$ports = array_chunk($ports, $vars['pagesize']);
$ports = $ports[$vars['pageno']-1];
}
// End Pagination
// Populate ports array (much faster for large systems)
$port_ids = array();
foreach ($ports as $p) {
$port_ids[] = $p['port_id'];
}
$where = ' WHERE `ports`.`port_id` IN (' . implode(',', $port_ids) . ') ';
//r($port_ids);
$where = generate_where_clause(generate_query_values($ports_ids, 'ports.port_id'));
$select = "`ports`.*, `ports`.`port_id` AS `port_id`";
#$select = "*,`ports`.`port_id` as `port_id`";
include($config['html_dir']."/includes/port-sort-select.inc.php");
include($config['html_dir'] . "/includes/port-sort-select.inc.php");
$sql = "SELECT ".$select;
$sql = "SELECT " . $select;
$sql .= " FROM `ports`";
$sql .= " INNER JOIN `devices` USING (`device_id`)";
//$sql .= " LEFT JOIN `ports-state` USING (`port_id`)";
$sql .= " ".$where;
$sql .= " " . $where . generate_port_sort($vars) . generate_query_limit($vars);
unset($ports);
$ports = dbFetchRows($sql);
// Re-sort because the DB doesn't do that.
include($config['html_dir']."/includes/port-sort.inc.php");
// End populating ports array
echo generate_box_open();
echo '<table class="' . OBS_CLASS_TABLE_STRIPED . ' table-hover">' . PHP_EOL;
$cols = array(
'state-marker' => '',
[ NULL, 'style' => "width: 1px;" ],
'device' => [ 'device' => 'Device', 'style' => "min-width: 150px;" ],
[ 'port' => 'Port Name', 'descr' => 'Description', 'errors' => 'Errors', 'style' => "min-width: 250px;" ],
[ 'traffic' => ['Bits', 'subfields' => ['traffic_in' => 'In', 'traffic_out' => 'Out']], 'style' => "width: 100px;" ],
[ 'traffic_perc' => ['%', 'subfields' => ['traffic_perc_in' => 'In', 'traffic_perc_out' => 'Out']], 'style' => "width: 110px;" ],
[ 'packets' => ['Pkts', 'subfields' => ['packets_in' => 'In', 'packets_out' => 'Out']], 'style' => "width: 90px;" ],
[ 'speed' => 'Speed', 'mtu' => 'MTU', 'style' => "width: 90px;" ],
[ 'media' => 'Media', 'mac' => 'MAC', 'style' =>"width: 150px;" ]
);
//echo get_table_header_old($cols, $vars);
if ($vars['view'] == "detail") {
$cols = [
'state-marker' => '',
[ NULL, 'style' => "width: 1px;" ],
'device' => [ 'device' => 'Device', 'style' => "min-width: 150px;" ],
[ 'port' => 'Port Name', 'descr' => 'Description', 'errors' => 'Errors', 'style' => "min-width: 250px;" ],
[ NULL ],
[ 'traffic' => [ 'Bits', 'subfields' => [ 'traffic_in' => 'In', 'traffic_out' => 'Out' ] ],
'packets' => [ 'Pkts', 'subfields' => [ 'packets_in' => 'In', 'packets_out' => 'Out' ] ],
'style' => "width: 100px;" ],
[ 'media' => "Media", 'speed' => 'Speed' ],
[ 'mac' => "MAC" ],
];
} else {
$cols = [
'state-marker' => '',
[NULL, 'style' => "width: 1px;"],
'device' => ['device' => 'Device', 'style' => "min-width: 150px;"],
['port' => 'Port Name', 'descr' => 'Description', 'errors' => 'Errors', 'style' => "min-width: 250px;"],
['traffic' => ['Bits', 'subfields' => ['traffic_in' => 'In', 'traffic_out' => 'Out']], 'style' => "width: 100px;"],
['traffic_perc' => ['%', 'subfields' => ['traffic_perc_in' => 'In', 'traffic_perc_out' => 'Out']], 'style' => "width: 110px;"],
['packets' => ['Pkts', 'subfields' => ['packets_in' => 'In', 'packets_out' => 'Out']], 'style' => "width: 90px;"],
['speed' => 'Speed', 'mtu' => 'MTU', 'style' => "width: 90px;"],
['media' => 'Media', 'mac' => 'MAC', 'style' => "width: 150px;"]
];
}
echo generate_table_header($cols, $vars);
echo '<tbody>' . PHP_EOL;
$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0;
foreach ($ports as $port) {
$ports_total++;
print_port_row($port, $vars);
foreach (dbFetchRows($sql) as $port) {
print_port_row($port, $vars);
}
/* Example of usage dbFetchFunc()
dbFetchFunc(static function ($port) use ($vars) {
print_port_row($port, $vars);
}, $sql);
*/
echo '</tbody></table>';
echo generate_box_close();