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

@ -4,43 +4,45 @@
*
* 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
*
*/
register_html_title('Locations');
if (!$vars['view']) { $vars['view'] = 'basic'; }
if (!$vars['view']) {
$vars['view'] = 'basic';
}
$navbar['brand'] = 'Locations';
$navbar['class'] = 'navbar-narrow';
foreach (array('basic', 'traffic') as $type)
{
if ($vars['view'] == $type) { $navbar['options'][$type]['class'] = 'active'; }
$navbar['options'][$type]['url'] = generate_url(array('page' => 'locations', 'view' => $type));
$navbar['options'][$type]['text'] = ucfirst($type);
foreach (['basic', 'traffic'] as $type) {
if ($vars['view'] == $type) {
$navbar['options'][$type]['class'] = 'active';
}
$navbar['options'][$type]['url'] = generate_url(['page' => 'locations', 'view' => $type]);
$navbar['options'][$type]['text'] = ucfirst($type);
}
print_navbar($navbar);
unset($navbar);
echo generate_box_open();
echo('<table class="table table-hover table-striped table-condensed ">'. PHP_EOL);
echo('<table class="table table-hover table-striped table-condensed ">' . PHP_EOL);
//$location_where = generate_query_values_and($vars['location'], 'location');
$cols = array(
array(NULL, 'class="state-marker"'),
'location' => array('Location', 'style="width: 300px;"'),
'total' => array('Devices:&nbsp;Total', 'style="width: 50px; text-align: right;"')
);
$cols = [
[NULL, 'class="state-marker"'],
'location' => ['Location', 'style="width: 300px;"'],
'total' => ['Devices:&nbsp;Total', 'style="width: 50px; text-align: right;"']
];
foreach (array_keys($cache['device_types']) as $type)
{
$cols[$type] = array(nicecase($type), 'style="width: 40px;"');
foreach (array_keys($cache['devices']['types']) as $type) {
$cols[$type] = [nicecase($type), 'style="width: 40px;"'];
}
echo get_table_header($cols); //, $vars); // Currently sorting is not available
@ -48,56 +50,57 @@ echo('<tr class="success">
<td class="state-marker"></td>
<td class="entity">ALL</td>
<td style="text-align: right;"><strong class="label label-success">' . $devices['count'] . '</strong></td>' . PHP_EOL);
foreach ($cache['device_types'] as $type => $type_count)
{
echo('<td><strong class="label label-info">' . $type_count . '</strong></td>' . PHP_EOL);
foreach ($cache['devices']['types'] as $type => $type_data) {
echo('<td><strong class="label label-info">' . $type_data['count'] . '</strong></td>' . PHP_EOL);
}
echo(' </tr>');
foreach (get_locations() as $location)
{
$location_where = ' WHERE 1 ' . generate_query_values_and($location, 'location');
$location_where .= $GLOBALS['cache']['where']['devices_permitted'];
foreach (get_locations() as $location) {
$num = dbFetchCell('SELECT COUNT(*) FROM `devices`' . $location_where);
$location_where = generate_where_clause($GLOBALS['cache']['where']['devices_permitted'], generate_query_values($location, 'location'));
$hostalerts = dbFetchCell('SELECT COUNT(*) FROM `devices`' . $location_where . ' AND `status` = ?', array(0));
if ($hostalerts) { $row_class = 'error'; } else { $row_class = ''; }
$num = dbFetchCell('SELECT COUNT(*) FROM `devices`' . $location_where);
if ($location === '') { $location = OBS_VAR_UNSET; }
$value = var_encode($location);
echo('<tr class="'.$row_class.'">
<td class="state-marker"></td>
<td class="entity">' . generate_link($location, array('page' => 'devices', 'location' => $value)) . '</td>
<td style="text-align: right;"><strong class="label label-success">' . $num . '</strong></td>' . PHP_EOL);
foreach (array_keys($cache['device_types']) as $type)
{
$location_count = dbFetchCell('SELECT COUNT(*) FROM `devices`' . $location_where . ' AND `type` = ?', array($type));
if ($location_count > 0)
{
$location_count = '<span class="label">' . $location_count . '</span>';
$hostalerts = dbFetchCell('SELECT COUNT(*) FROM `devices`' . $location_where . ' AND `status` = ?', [0]);
if ($hostalerts) {
$row_class = 'error';
} else {
$row_class = '';
}
echo('<td>' . $location_count . '</td>' . PHP_EOL);
}
echo(' </tr>');
if ($vars['view'] == 'traffic')
{
echo('<tr></tr><tr class="locations"><td colspan="'.count($cols).'">');
if ($location === '') {
$location = OBS_VAR_UNSET;
}
$value = var_encode($location);
$graph_array['type'] = 'location_bits';
$graph_array['height'] = 100;
$graph_array['width'] = 220;
$graph_array['to'] = $config['time']['now'];
$graph_array['legend'] = 'no';
$graph_array['id'] = $value;
echo('<tr class="' . $row_class . '">
<td class="state-marker"></td>
<td class="entity">' . generate_link($location, ['page' => 'devices', 'location' => $value]) . '</td>
<td style="text-align: right;"><strong class="label label-success">' . $num . '</strong></td>' . PHP_EOL);
foreach (array_keys($cache['devices']['types']) as $type) {
$location_count = dbFetchCell('SELECT COUNT(*) FROM `devices`' . $location_where . ' AND `type` = ?', [$type]);
if ($location_count > 0) {
$location_count = '<span class="label">' . $location_count . '</span>';
}
echo('<td>' . $location_count . '</td>' . PHP_EOL);
}
echo(' </tr>');
print_graph_row($graph_array);
if ($vars['view'] == 'traffic') {
echo('<tr></tr><tr class="locations"><td colspan="' . count($cols) . '">');
echo('</tr></td>');
}
$done = 'yes';
$graph_array['type'] = 'location_bits';
$graph_array['height'] = 100;
$graph_array['width'] = 220;
$graph_array['to'] = get_time();
$graph_array['legend'] = 'no';
$graph_array['id'] = $value;
print_graph_row($graph_array);
echo('</tr></td>');
}
$done = 'yes';
}
echo('</table>');