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

@ -1,77 +1,62 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @copyright (C) Adam Armstrong
*
*/
$graph_array['to'] = $config['time']['now'];
$graph_array['from'] = $config['time']['day'];
$graph_array['to'] = get_time();
$graph_array['from'] = get_time('day');
//$graph_array_zoom = $graph_array;
//$graph_array_zoom['height'] = "150";
//$graph_array_zoom['width'] = "400";
//$graph_array['legend'] = "no";
$app_devices = array();
foreach (dbFetchRows("SELECT * FROM `applications` WHERE `app_type` = ? ".$GLOBALS['cache']['where']['devices_permitted'], array($vars['app'])) as $app)
{
if (isset($cache['devices']['id'][$app['device_id']]))
{
$app_devices[] = array_merge($app, $cache['devices']['id'][$app['device_id']]);
}
$where_clause = generate_where_clause(['`app_type` = ?', generate_query_permitted_ng(['devices'])]);
// Merge device and app arrays for ease of sorting. This may not scale well to huge numbers of apps.
$devices = [];
foreach (dbFetchRows("SELECT * FROM `applications` " . $where_clause, [$vars['app']]) as $app) {
$devices[$app['app_id']] = array_merge($app, device_by_id_cache($app['device_id']));
}
$app_devices = array_sort_by($app_devices, 'hostname', SORT_ASC, SORT_STRING);
//echo generate_box_open();
// FIXME. Use db query instead
$devices = array_sort_by($devices, 'hostname', SORT_ASC, SORT_STRING);
//echo '<table class="table table-hover table-condensed table-striped ">';
foreach ($devices as $device) {
foreach ($app_devices as $app_device)
{
// Faux $app array for easier code reading
$app = &$device;
echo generate_box_open();
echo generate_box_open();
echo '<table class="table table-hover table-condensed table-striped ">';
echo '<table class="table table-hover table-condensed table-striped ">';
print_device_row($app_device, NULL, array('tab' => 'apps', 'app' => $app['app_type']));
print_device_row($device, NULL, ['tab' => 'apps', 'app' => $app['app_type'], 'instance' => $app['app_id']]);
echo '<tr><td colspan="6">';
echo '<tr><td colspan="6">';
$graph_array['id'] = $app_device['app_id'];
$graph_array['types'] = array();
$graph_array['legend'] = "no";
$graph_array['id'] = $device['app_id'];
$graph_array['types'] = [];
$graph_array['legend'] = "no";
foreach ($config['app'][$vars['app']]['top'] as $graph_type)
{
$graph_array['types'][] = "application_".$vars['app']."_".$graph_type;
}
print_graph_summary_row($graph_array);
foreach ($config['app'][$vars['app']]['top'] as $graph_type) {
$graph_array['types'][] = "application_" . $vars['app'] . "_" . $graph_type;
}
print_graph_summary_row($graph_array);
/*
foreach ($config['app'][$vars['app']]['top'] as $graph_type)
{
$graph_array['type'] = "application_".$vars['app']."_".$graph_type;
$graph_array['id'] = $app_device['app_id'];
$graph_array_zoom['type'] = "application_".$vars['app']."_".$graph_type;
$graph_array_zoom['id'] = $app_device['app_id'];
echo '</td>';
echo '</tr>';
echo '<h3>' . nicecase($graph_type) . '</h3>';
print_graph_row($graph_array);
}
*/
echo '</table>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo generate_box_close();
echo generate_box_close();
}

View File

@ -4,70 +4,95 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$graph_array['width'] = "218";
$graph_array['height'] = "100";
$graph_array['to'] = $config['time']['now'];
$graph_array['from'] = $config['time']['day'];
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$graph_array['legend'] = "no";
foreach (dbFetchRows("SELECT * FROM `applications` WHERE 1 ".generate_query_values_and(array_keys((array)$app_types), 'app_type').$GLOBALS['cache']['where']['devices_permitted'].' ORDER BY `app_type`;') as $app)
{
if (isset($cache['devices']['id'][$app['device_id']]))
{
$app_types[$app['app_type']][] = array_merge($app, $cache['devices']['id'][$app['device_id']]);
}
}
foreach (array_keys($app_types) as $app_type)
{
echo('<div class="row"><div class="col-md-12">');
echo('<h4>'.generate_link(nicecase($app_type),array('page' => 'apps', 'app' => $app_type)).'</h4>');
$app_devices = array_sort_by($app_types[$app_type], 'hostname', SORT_ASC, SORT_STRING);
foreach ($app_devices as $app)
{
$graph_type = $config['app'][$app['app_type']]['top'][0];
$graph_array['type'] = "application_".$app['app_type']."_".$graph_type;
$graph_array['id'] = $app['app_id'];
$graph_array_zoom['type'] = "application_".$app['app_type']."_".$graph_type;
$graph_array_zoom['id'] = $app['app_id'];
$link_array = $graph_array;
$link_array['page'] = "device";
$link_array['device'] = $app['device_id'];
$link_array['tab'] = "apps";
$link_array['app'] = $app['app_type'];
unset($link_array['height'], $link_array['width']);
$overlib_url = generate_url($link_array);
$overlib_link = '<span style="float:left; margin-left: 10px; font-weight: bold;">'.short_hostname($app['hostname'])."</span>";
if (!empty($app['app_instance']))
{
$overlib_link .= '<span style="float:right; margin-right: 10px; font-weight: bold;">'.$app['app_instance']."</span>";
$app['content_add'] = '('.$app['app_instance'].')';
if ($_SESSION['widescreen']) {
if ($config['graphs']['size'] === 'big') {
$width_div = 586;
$width = 508;
$height = 149;
$height_div = 220;
} else {
$width_div = 350;
$width = 276;
$height = 109;
$height_div = 180;
}
} else {
if ($config['graphs']['size'] === 'big') {
$width_div = 614;
$width = 533;
$height = 159;
$height_div = 218;
} else {
$width_div = 302;
$width = 227;
$height = 100;
$height_div = 158;
}
$overlib_link .= "<br/>";
$overlib_link .= generate_graph_tag($graph_array);
$overlib_content = generate_overlib_content($graph_array, $app['hostname'] . " - ". $app['app_type'] . $app['content_add']);
echo("<div style='display: block; padding: 1px; padding-top: 3px; margin: 2px; min-width: ".$width_div."px; max-width:".$width_div."px; min-height:165px; max-height:165px;
text-align: center; float: left; background-color: #f5f5f5;'>");
echo(overlib_link($overlib_url, $overlib_link, $overlib_content));
echo("</div>");
}
echo('</div></div>');
}
$graph_array['height'] = 100;
$graph_array['width'] = 212;
$where_clause = generate_where_clause(generate_query_permitted_ng(['devices']));
$query = "SELECT * FROM `applications` " . $where_clause . " ORDER BY `app_type`;";
foreach (dbFetchRows($query) as $app) {
$app_types[$app['app_type']]['instances'][$app['app_id']] = array_merge($app, device_by_id_cache($app['device_id']));
}
echo '<div class="row">';
foreach ($app_types as $app_type => $app) {
echo '<div class="col-md-12"><div class="box box-solid"><h2>' . generate_link(nicecase($app_type), ['page' => 'apps', 'app' => $app_type]) . '</h2></div><div class="row">';
$app['instances'] = array_sort_by($app['instances'], 'hostname', SORT_ASC, SORT_STRING);
foreach ($app['instances'] as $app_id => $device) {
$app_id = $device['app_id'];
$graph_type = $config['app'][$app_type]['top'][0];
$graph_array['type'] = "application_" . $app_type . "_" . $graph_type;
$graph_array['id'] = $app_id;
$graph_array['device'] = $device['device_id'];
$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, $device['hostname']);
$graph_array['width'] = $width;
$graph_array['height'] = $height;
$graph = generate_graph_tag($graph_array);
echo generate_box_open(['title' => $device['hostname'],
'url' => generate_device_url($device),
'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></div>';
}
echo '</div>';
// EOF