#10194 added acl
This commit is contained in:
parent
f48e83da01
commit
5ea3e47264
|
@ -47,8 +47,13 @@ class Agents extends Element
|
|||
*/
|
||||
public function getTotalAgents():string
|
||||
{
|
||||
$value = $this->valueMonitoring('total_agents');
|
||||
$total = round($value[0]['datos']);
|
||||
$agents = agents_get_agents();
|
||||
if (is_array($agents) === true) {
|
||||
$total = count($agents);
|
||||
} else {
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $total,
|
||||
|
@ -67,8 +72,39 @@ class Agents extends Element
|
|||
*/
|
||||
public function getAlerts():string
|
||||
{
|
||||
$value = $this->valueMonitoring('triggered_alerts_24h');
|
||||
$total = round($value[0]['datos']);
|
||||
global $config;
|
||||
$id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false));
|
||||
if (in_array(0, $id_groups) === false) {
|
||||
foreach ($id_groups as $key => $id_group) {
|
||||
if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) {
|
||||
unset($id_groups[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (users_can_manage_group_all() === true) {
|
||||
$id_groups[] = 0;
|
||||
}
|
||||
|
||||
$id_groups = implode(',', $id_groups);
|
||||
|
||||
$group_query = ' AND (
|
||||
t3.id_grupo IN ('.$id_groups.')
|
||||
OR tasg.id_group IN ('.$id_groups.')
|
||||
)';
|
||||
$sql = 'SELECT count(t0.id)
|
||||
FROM talert_template_modules t0
|
||||
INNER JOIN talert_templates t1
|
||||
ON t0.id_alert_template = t1.id
|
||||
INNER JOIN tagente_modulo t2
|
||||
ON t0.id_agent_module = t2.id_agente_modulo
|
||||
INNER JOIN tagente t3
|
||||
ON t2.id_agente = t3.id_agente
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = t3.id_agente
|
||||
WHERE last_fired >=UNIX_TIMESTAMP(NOW() - INTERVAL 1 DAY) '.$group_query;
|
||||
|
||||
$total = db_get_value_sql($sql);
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $total,
|
||||
|
|
|
@ -40,7 +40,7 @@ class Alerts extends Element
|
|||
$this->ajaxMethods = [
|
||||
'getUsers',
|
||||
'getCurrentlyTriggered',
|
||||
'getActiveCorrelation',
|
||||
'getActiveAlerts',
|
||||
];
|
||||
$this->interval = 300000;
|
||||
$this->refreshConfig = [
|
||||
|
@ -50,7 +50,7 @@ class Alerts extends Element
|
|||
],
|
||||
'active-correlation' => [
|
||||
'id' => 'active-correlation',
|
||||
'method' => 'getActiveCorrelation',
|
||||
'method' => 'getActiveAlerts',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -63,8 +63,7 @@ class Alerts extends Element
|
|||
*/
|
||||
public function getCurrentlyTriggered():string
|
||||
{
|
||||
$value = $this->valueMonitoring('triggered_alerts');
|
||||
$total = round($value[0]['datos']);
|
||||
$total = alerts_get_alerts(0, '', 'fired', -1, 'AR', true);
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $total,
|
||||
|
@ -82,10 +81,9 @@ class Alerts extends Element
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getActiveCorrelation():string
|
||||
public function getActiveAlerts():string
|
||||
{
|
||||
$value = $this->valueMonitoring('triggered_correlative_alerts');
|
||||
$total = round($value[0]['datos']);
|
||||
$total = alerts_get_alerts(0, '', 'all', -1, 'AR', true);
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $total,
|
||||
|
@ -178,9 +176,28 @@ class Alerts extends Element
|
|||
);
|
||||
}
|
||||
|
||||
$id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false));
|
||||
if (in_array(0, $id_groups) === false) {
|
||||
foreach ($id_groups as $key => $id_group) {
|
||||
if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) {
|
||||
unset($id_groups[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (users_can_manage_group_all() === true) {
|
||||
$id_groups[] = 0;
|
||||
}
|
||||
|
||||
$id_groups = implode(',', $id_groups);
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT id_user, is_admin ,last_connect
|
||||
FROM tusuario u %s %s',
|
||||
'SELECT DISTINCT id_user, is_admin ,last_connect
|
||||
FROM tusuario u
|
||||
LEFT JOIN tusuario_perfil p ON p.id_usuario = u.id_user
|
||||
WHERE id_grupo IN ('.$id_groups.')
|
||||
GROUP BY id_user
|
||||
%s %s',
|
||||
$order,
|
||||
$pagination
|
||||
);
|
||||
|
@ -202,7 +219,11 @@ class Alerts extends Element
|
|||
}
|
||||
|
||||
$sql_count = sprintf(
|
||||
'SELECT count(*) as total FROM tusuario %s',
|
||||
'SELECT DISTINCT id_user, count(*) as total
|
||||
FROM tusuario u
|
||||
LEFT JOIN tusuario_perfil p ON p.id_usuario = u.id_user
|
||||
WHERE id_grupo IN ('.$id_groups.')
|
||||
%s',
|
||||
$order,
|
||||
);
|
||||
|
||||
|
|
|
@ -51,30 +51,45 @@ class Events extends Element
|
|||
*/
|
||||
public function getEventsGraph():string
|
||||
{
|
||||
global $config;
|
||||
$id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false));
|
||||
if (in_array(0, $id_groups) === false) {
|
||||
foreach ($id_groups as $key => $id_group) {
|
||||
if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) {
|
||||
unset($id_groups[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (users_can_manage_group_all() === true) {
|
||||
$id_groups[] = 0;
|
||||
}
|
||||
|
||||
$id_groups = implode(',', $id_groups);
|
||||
$interval24h = (time() - 86400);
|
||||
$sql = 'SELECT
|
||||
utimestamp,
|
||||
DATE_FORMAT(FROM_UNIXTIME(utimestamp), "%Y-%m-%d %H:00:00") AS hour,
|
||||
COUNT(*) AS number_of_events
|
||||
FROM tevento
|
||||
WHERE utimestamp >= '.$interval24h.'
|
||||
WHERE utimestamp >= '.$interval24h.' AND id_grupo IN ('.$id_groups.')
|
||||
GROUP BY hour
|
||||
ORDER BY hour
|
||||
LIMIT 24;';
|
||||
|
||||
$sqlTest = 'SELECT
|
||||
utimestamp,
|
||||
DATE_FORMAT(FROM_UNIXTIME(utimestamp), "%Y-%m-%d %H:00:00") AS hour,
|
||||
COUNT(*) AS number_of_events
|
||||
FROM tevento
|
||||
WHERE utimestamp >= 1693296001
|
||||
GROUP BY hour
|
||||
ORDER BY hour
|
||||
LIMIT 24;';
|
||||
|
||||
$rows = db_process_sql($sql);
|
||||
|
||||
$graph_values = [];
|
||||
for ($i = 1; $i <= 24; $i++) {
|
||||
$timestamp = strtotime('-'.$i.' hours');
|
||||
$hour = date('d-m-Y H:00:00', $timestamp);
|
||||
$graph_values[$hour] = [
|
||||
'y' => 0,
|
||||
'x' => $hour,
|
||||
];
|
||||
}
|
||||
|
||||
$graph_values = array_reverse($graph_values);
|
||||
$colors = [];
|
||||
$max_value = 0;
|
||||
foreach ($rows as $key => $row) {
|
||||
|
@ -82,7 +97,7 @@ class Events extends Element
|
|||
$max_value = $row['number_of_events'];
|
||||
}
|
||||
|
||||
$graph_values[] = [
|
||||
$graph_values[date('d-m-Y H:00:00', $row['utimestamp'])] = [
|
||||
'y' => $row['number_of_events'],
|
||||
'x' => date('d-m-Y H:00:00', $row['utimestamp']),
|
||||
];
|
||||
|
@ -144,14 +159,25 @@ class Events extends Element
|
|||
*/
|
||||
public function getEventsCriticalityGraph():string
|
||||
{
|
||||
global $config;
|
||||
$id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false));
|
||||
if (in_array(0, $id_groups) === false) {
|
||||
foreach ($id_groups as $key => $id_group) {
|
||||
if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) {
|
||||
unset($id_groups[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (users_can_manage_group_all() === true) {
|
||||
$id_groups[] = 0;
|
||||
}
|
||||
|
||||
$id_groups = implode(',', $id_groups);
|
||||
$interval8h = (time() - 86400);
|
||||
$sql = 'SELECT criticity, count(*) AS total
|
||||
FROM tevento
|
||||
WHERE utimestamp >= '.$interval8h.'
|
||||
group by criticity';
|
||||
|
||||
$sqlTest = 'SELECT criticity, count(*) AS total
|
||||
FROM tevento
|
||||
WHERE utimestamp >= '.$interval8h.' AND id_grupo IN ('.$id_groups.')
|
||||
group by criticity';
|
||||
|
||||
$rows = db_process_sql($sql);
|
||||
|
@ -233,15 +259,25 @@ class Events extends Element
|
|||
*/
|
||||
public function getEventsStatusValidateGraph():string
|
||||
{
|
||||
global $config;
|
||||
$id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false));
|
||||
if (in_array(0, $id_groups) === false) {
|
||||
foreach ($id_groups as $key => $id_group) {
|
||||
if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) {
|
||||
unset($id_groups[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (users_can_manage_group_all() === true) {
|
||||
$id_groups[] = 0;
|
||||
}
|
||||
|
||||
$id_groups = implode(',', $id_groups);
|
||||
$interval8h = (time() - 86400);
|
||||
$sql = 'SELECT estado, count(*) AS total
|
||||
FROM tevento
|
||||
WHERE utimestamp >= '.$interval8h.'
|
||||
group by estado';
|
||||
|
||||
$sqlTest = 'SELECT estado, count(*) AS total
|
||||
FROM tevento
|
||||
WHERE utimestamp <= 1688981702
|
||||
WHERE utimestamp >= '.$interval8h.' AND id_grupo IN ('.$id_groups.')
|
||||
group by estado';
|
||||
|
||||
$rows = db_process_sql($sql);
|
||||
|
|
|
@ -44,7 +44,7 @@ class Groups extends Element
|
|||
global $config;
|
||||
parent::__construct();
|
||||
include_once $config['homedir'].'/include/functions_users.php';
|
||||
include_once 'include/functions_groupview.php';
|
||||
include_once $config['homedir'].'/include/functions_groupview.php';
|
||||
$this->ajaxMethods = ['getStatusHeatMap'];
|
||||
ui_require_css_file('heatmap');
|
||||
$this->title = __('Groups');
|
||||
|
@ -70,6 +70,363 @@ class Groups extends Element
|
|||
* @return string
|
||||
*/
|
||||
public function getStatusHeatMap():string
|
||||
{
|
||||
global $config;
|
||||
|
||||
$groups = users_get_groups($config['id_group'], 'AR', false);
|
||||
if (is_array($groups) === true && count($groups) >= 10) {
|
||||
return $this->getStatusHeatMapGroup();
|
||||
}
|
||||
|
||||
$agents = agents_get_agents();
|
||||
if (is_array($agents) === true && count($agents) >= 10) {
|
||||
$this->title = __('My monitored agents');
|
||||
return $this->getStatusHeatMapAgents();
|
||||
}
|
||||
|
||||
$this->title = __('My monitored modules');
|
||||
return $this->getStatusHeatMapModules();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the status modules in heatmap.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusHeatMapModules():string
|
||||
{
|
||||
global $config;
|
||||
$width = get_parameter('width', 350);
|
||||
$height = get_parameter('height', 275);
|
||||
|
||||
$id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false));
|
||||
|
||||
if (in_array(0, $id_groups) === false) {
|
||||
foreach ($id_groups as $key => $id_group) {
|
||||
if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) {
|
||||
unset($id_groups[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$id_groups = implode(',', $id_groups);
|
||||
|
||||
$modules = modules_get_modules_in_group($id_groups);
|
||||
$total_groups = count($modules);
|
||||
if ($total_groups === 0) {
|
||||
return graph_nodata_image(['width' => '400']);
|
||||
}
|
||||
|
||||
$groups = $modules;
|
||||
// Best square.
|
||||
$high = (float) max($width, $height);
|
||||
$low = 0.0;
|
||||
|
||||
while (abs($high - $low) > 0.000001) {
|
||||
$mid = (($high + $low) / 2.0);
|
||||
$midval = (floor($width / $mid) * floor($height / $mid));
|
||||
if ($midval >= $total_groups) {
|
||||
$low = $mid;
|
||||
} else {
|
||||
$high = $mid;
|
||||
}
|
||||
}
|
||||
|
||||
$square_length = min(($width / floor($width / $low)), ($height / floor($height / $low)));
|
||||
// Print starmap.
|
||||
$heatmap = sprintf(
|
||||
'<svg id="svg" style="width: %spx; height: %spx;">',
|
||||
$width,
|
||||
$height
|
||||
);
|
||||
|
||||
$heatmap .= '<g>';
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
$x = 0;
|
||||
$y = 0;
|
||||
$cont = 1;
|
||||
foreach ($groups as $key => $value) {
|
||||
$module_id = $value['id_agente_modulo'];
|
||||
$db_status = modules_get_agentmodule_status($module_id);
|
||||
$module_value = modules_get_last_value($module_id);
|
||||
$status = '';
|
||||
$title = '';
|
||||
modules_get_status($module_id, $db_status, $module_value, $status, $title);
|
||||
switch ($status) {
|
||||
case STATUS_MODULE_NO_DATA:
|
||||
// Not init status.
|
||||
$status = 'notinit';
|
||||
break;
|
||||
|
||||
case STATUS_MODULE_CRITICAL:
|
||||
// Critical status.
|
||||
$status = 'critical';
|
||||
break;
|
||||
|
||||
case STATUS_MODULE_WARNING:
|
||||
// Warning status.
|
||||
$status = 'warning';
|
||||
break;
|
||||
|
||||
case STATUS_MODULE_OK:
|
||||
// Normal status.
|
||||
$status = 'normal';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case -1:
|
||||
default:
|
||||
// Unknown status.
|
||||
$status = 'unknown';
|
||||
break;
|
||||
}
|
||||
|
||||
$heatmap .= sprintf(
|
||||
'<rect id="%s" x="%s" style="stroke-width:1;stroke:#ffffff" y="%s" row="%s" rx="3" ry="3" col="%s" width="%s" height="%s" class="scuare-status %s_%s"></rect>',
|
||||
'rect_'.$cont,
|
||||
$x,
|
||||
$y,
|
||||
$row,
|
||||
$column,
|
||||
$square_length,
|
||||
$square_length,
|
||||
$status,
|
||||
random_int(1, 10)
|
||||
);
|
||||
|
||||
$y += $square_length;
|
||||
$row++;
|
||||
if ((int) ($y + $square_length) > (int) $height) {
|
||||
$y = 0;
|
||||
$x += $square_length;
|
||||
$row = 0;
|
||||
$column++;
|
||||
}
|
||||
|
||||
if ((int) ($x + $square_length) > (int) $width) {
|
||||
$x = 0;
|
||||
$y += $square_length;
|
||||
$column = 0;
|
||||
$row++;
|
||||
}
|
||||
|
||||
$cont++;
|
||||
}
|
||||
|
||||
$heatmap .= '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
const total_groups = "'.$total_groups.'";
|
||||
function getRandomInteger(min, max) {
|
||||
return Math.floor(Math.random() * max) + min;
|
||||
}
|
||||
|
||||
function oneSquare(solid, time) {
|
||||
var randomPoint = getRandomInteger(1, total_groups);
|
||||
let target = $(`#rect_${randomPoint}`);
|
||||
let class_name = target.attr("class");
|
||||
class_name = class_name.split("_")[0];
|
||||
setTimeout(function() {
|
||||
target.removeClass();
|
||||
target.addClass(`${class_name}_${solid}`);
|
||||
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
|
||||
}, time);
|
||||
}
|
||||
|
||||
let cont = 0;
|
||||
while (cont < Math.ceil(total_groups / 3)) {
|
||||
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
|
||||
cont ++;
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
$heatmap .= '</g>';
|
||||
$heatmap .= '</svg>';
|
||||
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $heatmap,
|
||||
'style' => 'margin: 0 auto; width: fit-content; min-height: 285px;',
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the status agents in heat map.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusHeatMapAgents():string
|
||||
{
|
||||
global $config;
|
||||
$width = get_parameter('width', 350);
|
||||
$height = get_parameter('height', 275);
|
||||
|
||||
$id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false));
|
||||
|
||||
if (in_array(0, $id_groups) === false) {
|
||||
foreach ($id_groups as $key => $id_group) {
|
||||
if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) {
|
||||
unset($id_groups[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$id_groups = implode(',', $id_groups);
|
||||
|
||||
$sql = 'SELECT * FROM tagente a
|
||||
LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente
|
||||
WHERE g.id_group IN ('.$id_groups.') OR a.id_grupo IN ('.$id_groups.')';
|
||||
$all_agents = db_get_all_rows_sql($sql);
|
||||
if (empty($all_agents)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$total_agents = count($all_agents);
|
||||
|
||||
// Best square.
|
||||
$high = (float) max($width, $height);
|
||||
$low = 0.0;
|
||||
|
||||
while (abs($high - $low) > 0.000001) {
|
||||
$mid = (($high + $low) / 2.0);
|
||||
$midval = (floor($width / $mid) * floor($height / $mid));
|
||||
if ($midval >= $total_agents) {
|
||||
$low = $mid;
|
||||
} else {
|
||||
$high = $mid;
|
||||
}
|
||||
}
|
||||
|
||||
$square_length = min(($width / floor($width / $low)), ($height / floor($height / $low)));
|
||||
// Print starmap.
|
||||
$heatmap = sprintf(
|
||||
'<svg id="svg" style="width: %spx; height: %spx;">',
|
||||
$width,
|
||||
$height
|
||||
);
|
||||
|
||||
$heatmap .= '<g>';
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
$x = 0;
|
||||
$y = 0;
|
||||
$cont = 1;
|
||||
|
||||
foreach ($all_agents as $key => $value) {
|
||||
// Colour by status.
|
||||
$status = agents_get_status_from_counts($value);
|
||||
|
||||
switch ($status) {
|
||||
case 5:
|
||||
// Not init status.
|
||||
$status = 'notinit';
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// Critical status.
|
||||
$status = 'critical';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// Warning status.
|
||||
$status = 'warning';
|
||||
break;
|
||||
|
||||
case 0:
|
||||
// Normal status.
|
||||
$status = 'normal';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case -1:
|
||||
default:
|
||||
// Unknown status.
|
||||
$status = 'unknown';
|
||||
break;
|
||||
}
|
||||
|
||||
$heatmap .= sprintf(
|
||||
'<rect id="%s" x="%s" style="stroke-width:1;stroke:#ffffff" y="%s" row="%s" rx="3" ry="3" col="%s" width="%s" height="%s" class="scuare-status %s_%s"></rect>',
|
||||
'rect_'.$cont,
|
||||
$x,
|
||||
$y,
|
||||
$row,
|
||||
$column,
|
||||
$square_length,
|
||||
$square_length,
|
||||
$status,
|
||||
random_int(1, 10)
|
||||
);
|
||||
|
||||
$y += $square_length;
|
||||
$row++;
|
||||
if ((int) ($y + $square_length) > (int) $height) {
|
||||
$y = 0;
|
||||
$x += $square_length;
|
||||
$row = 0;
|
||||
$column++;
|
||||
}
|
||||
|
||||
if ((int) ($x + $square_length) > (int) $width) {
|
||||
$x = 0;
|
||||
$y += $square_length;
|
||||
$column = 0;
|
||||
$row++;
|
||||
}
|
||||
|
||||
$cont++;
|
||||
}
|
||||
|
||||
$heatmap .= '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
const total_agents = "'.$total_agents.'";
|
||||
|
||||
function getRandomInteger(min, max) {
|
||||
return Math.floor(Math.random() * max) + min;
|
||||
}
|
||||
|
||||
function oneSquare(solid, time) {
|
||||
var randomPoint = getRandomInteger(1, total_agents);
|
||||
let target = $(`#rect_${randomPoint}`);
|
||||
let class_name = target.attr("class");
|
||||
class_name = class_name.split("_")[0];
|
||||
setTimeout(function() {
|
||||
target.removeClass();
|
||||
target.addClass(`${class_name}_${solid}`);
|
||||
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
|
||||
}, time);
|
||||
}
|
||||
|
||||
let cont = 0;
|
||||
while (cont < Math.ceil(total_agents / 3)) {
|
||||
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
|
||||
cont ++;
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
$heatmap .= '</g>';
|
||||
$heatmap .= '</svg>';
|
||||
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $heatmap,
|
||||
'style' => 'margin: 0 auto; width: fit-content; min-height: 285px;',
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the status groups in heat map.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusHeatMapGroup():string
|
||||
{
|
||||
global $config;
|
||||
$width = get_parameter('width', 350);
|
||||
|
|
|
@ -71,15 +71,11 @@ class LogStorage extends Element
|
|||
*/
|
||||
public function isEnabled():bool
|
||||
{
|
||||
if (empty($this->monitoringAgent) === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$existModule = modules_get_agentmodule_id(io_safe_input('Log server connection'), $this->monitoringAgent['id_agente']);
|
||||
if ($existModule === false) {
|
||||
return false;
|
||||
} else {
|
||||
global $config;
|
||||
if ((bool) $config['log_collector'] === true) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,9 +87,30 @@ class LogStorage extends Element
|
|||
*/
|
||||
public function getStatus():string
|
||||
{
|
||||
$value = $this->valueMonitoring('Log server connection');
|
||||
$status = ((int) $value[0]['datos'] === 1) ? true : false;
|
||||
if ($status === true) {
|
||||
$classDisabled = '';
|
||||
if ($this->isEnabled() === true) {
|
||||
$value = $this->valueMonitoring('Log server connection');
|
||||
$status = ((int) $value[0]['datos'] === 1) ? true : false;
|
||||
if ($status === true) {
|
||||
$image_status = html_print_image('images/status_check@svg.svg', true);
|
||||
$text = html_print_div(
|
||||
[
|
||||
'content' => __('Everything’s OK!'),
|
||||
'class' => 'status-text',
|
||||
],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$image_status = html_print_image('images/status_error@svg.svg', true);
|
||||
$text = html_print_div(
|
||||
[
|
||||
'content' => __('Something’s wrong'),
|
||||
'class' => 'status-text',
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$image_status = html_print_image('images/status_check@svg.svg', true);
|
||||
$text = html_print_div(
|
||||
[
|
||||
|
@ -102,15 +119,7 @@ class LogStorage extends Element
|
|||
],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$image_status = html_print_image('images/status_error@svg.svg', true);
|
||||
$text = html_print_div(
|
||||
[
|
||||
'content' => __('Something’s wrong'),
|
||||
'class' => 'status-text',
|
||||
],
|
||||
true
|
||||
);
|
||||
$classDisabled = 'alpha50';
|
||||
}
|
||||
|
||||
$output = $image_status.$text;
|
||||
|
@ -118,7 +127,7 @@ class LogStorage extends Element
|
|||
return html_print_div(
|
||||
[
|
||||
'content' => $output,
|
||||
'class' => 'flex_center margin-top-5',
|
||||
'class' => 'flex_center margin-top-5 '.$classDisabled,
|
||||
'style' => 'margin: 0px 10px 10px 10px;',
|
||||
'id' => 'status-log-storage',
|
||||
],
|
||||
|
@ -134,8 +143,13 @@ class LogStorage extends Element
|
|||
*/
|
||||
public function getTotalSources():string
|
||||
{
|
||||
$data = $this->valueMonitoring('Total sources');
|
||||
$value = round($data[0]['datos']);
|
||||
if ($this->isEnabled() === true) {
|
||||
$data = $this->valueMonitoring('Total sources');
|
||||
$value = round($data[0]['datos']);
|
||||
} else {
|
||||
$value = __('N/A');
|
||||
}
|
||||
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $value,
|
||||
|
@ -155,8 +169,13 @@ class LogStorage extends Element
|
|||
*/
|
||||
public function getStoredData():string
|
||||
{
|
||||
$data = $this->valueMonitoring('Total lines of data');
|
||||
$value = round($data[0]['datos']);
|
||||
if ($this->isEnabled() === true) {
|
||||
$data = $this->valueMonitoring('Total lines of data');
|
||||
$value = round($data[0]['datos']);
|
||||
} else {
|
||||
$value = __('N/A');
|
||||
}
|
||||
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $value,
|
||||
|
|
|
@ -34,46 +34,31 @@ class Overview extends Element
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $config;
|
||||
parent::__construct();
|
||||
if (is_ajax() === true) {
|
||||
include_once $config['homedir'].'/include/functions_servers.php';
|
||||
}
|
||||
|
||||
$this->title = __('General overview');
|
||||
$this->ajaxMethods = [
|
||||
'getLogSizeStatus',
|
||||
'getWuxServerStatus',
|
||||
'getServerStatus',
|
||||
];
|
||||
$this->interval = 300000;
|
||||
$this->refreshConfig = [
|
||||
'logSizeStatus' => [
|
||||
'logSizeStatus' => [
|
||||
'id' => 'status-log-size',
|
||||
'method' => 'getLogSizeStatus',
|
||||
],
|
||||
'wuxServerStatus' => [
|
||||
'id' => 'status-wux',
|
||||
'method' => 'getWuxServerStatus',
|
||||
'ServerStatus' => [
|
||||
'id' => 'status-servers',
|
||||
'method' => 'getServerStatus',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if module WUX connection exist.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function wuxIsEnabled():bool
|
||||
{
|
||||
if (empty($this->monitoringAgent) === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$existModule = modules_get_agentmodule_id(io_safe_input('WUX connection'), $this->monitoringAgent['id_agente']);
|
||||
if ($existModule === false) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the html log size status.
|
||||
*
|
||||
|
@ -106,11 +91,10 @@ class Overview extends Element
|
|||
|
||||
$output = $image_status.$text;
|
||||
|
||||
$align = ($this->wuxIsEnabled() === true) ? 'flex_center' : 'flex_justify';
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $output,
|
||||
'class' => 'margin-top-5 '.$align,
|
||||
'class' => 'margin-top-5 flex_center',
|
||||
'id' => 'status-log-size',
|
||||
],
|
||||
true
|
||||
|
@ -120,14 +104,13 @@ class Overview extends Element
|
|||
|
||||
|
||||
/**
|
||||
* Return the html Wix server status.
|
||||
* Return the html Servers status.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWuxServerStatus():string
|
||||
public function getServerStatus():string
|
||||
{
|
||||
$wux = $this->valueMonitoring('WUX connection');
|
||||
$status = ($wux[0]['datos'] > 0) ? true : false;
|
||||
$status = check_all_servers_up();
|
||||
|
||||
if ($status === true) {
|
||||
$image_status = html_print_image('images/status_check@svg.svg', true);
|
||||
|
@ -155,7 +138,7 @@ class Overview extends Element
|
|||
[
|
||||
'content' => $output,
|
||||
'class' => 'flex_center margin-top-5',
|
||||
'id' => 'status-wux',
|
||||
'id' => 'status-servers',
|
||||
],
|
||||
true
|
||||
);
|
||||
|
|
|
@ -248,4 +248,22 @@ class ScheduledDowntime extends Element
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check permission acl for this section.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkAcl():bool
|
||||
{
|
||||
global $config;
|
||||
$read_permisson = (bool) check_acl($config['id_user'], 0, 'AR');
|
||||
$manage_permisson = (bool) check_acl($config['id_user'], 0, 'AW');
|
||||
if ($read_permisson === true && $manage_permisson === true) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -81,8 +81,13 @@ class SnmpTraps extends Element
|
|||
*/
|
||||
public function getQueues():string
|
||||
{
|
||||
$value = $this->valueMonitoring('snmp_trap_queue');
|
||||
$total = round($value[0]['data']);
|
||||
if ($this->isEnabled() === true) {
|
||||
$value = $this->valueMonitoring('snmp_trap_queue');
|
||||
$total = round($value[0]['data']);
|
||||
} else {
|
||||
$total = __('N/A');
|
||||
}
|
||||
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $total,
|
||||
|
@ -102,8 +107,13 @@ class SnmpTraps extends Element
|
|||
*/
|
||||
public function getTotalSources():string
|
||||
{
|
||||
$value = $this->valueMonitoring('total_trap');
|
||||
$total = round($value[0]['data']);
|
||||
if ($this->isEnabled() === true) {
|
||||
$value = $this->valueMonitoring('total_trap');
|
||||
$total = round($value[0]['data']);
|
||||
} else {
|
||||
$total = __('N/A');
|
||||
}
|
||||
|
||||
return html_print_div(
|
||||
[
|
||||
'content' => $total,
|
||||
|
|
|
@ -14,24 +14,22 @@
|
|||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="row">
|
||||
<div class="<?php echo ($Overview->wuxIsEnabled() === true) ? 'col-6' : 'col-12'; ?>">
|
||||
<div class="padding10 <?php echo ($Overview->wuxIsEnabled() === true) ? '' : 'center'; ?>">
|
||||
<div class="col-6">
|
||||
<div class="padding10">
|
||||
<span class="subtitle">
|
||||
<?php echo __('Pandora FMS log size'); ?>
|
||||
</span>
|
||||
<?php echo $Overview->getLogSizeStatus(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($Overview->wuxIsEnabled() === true) : ?>
|
||||
<div class="col-6 br-l">
|
||||
<div class="padding10">
|
||||
<span class="subtitle">
|
||||
<?php echo __('Wux server status'); ?>
|
||||
</span>
|
||||
<?php echo $Overview->getWuxServerStatus(); ?>
|
||||
</div>
|
||||
<div class="col-6 br-l">
|
||||
<div class="padding10">
|
||||
<span class="subtitle">
|
||||
<?php echo __('Server status'); ?>
|
||||
</span>
|
||||
<?php echo $Overview->getServerStatus(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="br-t">
|
||||
<div class="padding10">
|
||||
|
@ -53,7 +51,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="<?php echo ($Database->checkAcl() === true) ? 'col-7 pdd_5px' : 'col-12 pdd_5px'; ?>">
|
||||
<div class="col-7 pdd_5px">
|
||||
<div class="container">
|
||||
<div class="title">
|
||||
<?php echo $MonitoringElements->title; ?>
|
||||
|
@ -91,7 +89,6 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<?php if ($Database->checkAcl() === true) : ?>
|
||||
<div class="col-5 pdd_5px">
|
||||
<div class="container" id="database">
|
||||
<div class="title">
|
||||
|
@ -140,9 +137,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-6">
|
||||
|
@ -153,83 +148,75 @@
|
|||
<?php echo $NewsBoard->getNews(); ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php if ($Groups->total < 200) : ?>
|
||||
<div class="<?php echo (($SnmpTraps->isEnabled() === true && $LogStorage->isEnabled() === true)) ? 'col-6 pdd_5px' : 'col-12 pdd_5px'; ?>">
|
||||
<div class="container">
|
||||
<div class="title br-b">
|
||||
<?php echo $Groups->title; ?>
|
||||
<div class="col-6 pdd_5px">
|
||||
<div class="container">
|
||||
<div class="title br-b">
|
||||
<?php echo $Groups->title; ?>
|
||||
</div>
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Status'); ?> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="heatmap-group">
|
||||
<?php echo $Groups->loading(); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="container mrgn_5px" id="logStorage">
|
||||
<div class="title br-b">
|
||||
<?php echo $LogStorage->title; ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 br-r br-b">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Log storage status'); ?>
|
||||
</div>
|
||||
<?php echo $LogStorage->getStatus(); ?>
|
||||
</div>
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Status'); ?> <a href=""><?php echo __('Info'); ?></a>
|
||||
<div class="col-6 br-b">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Total sources'); ?>
|
||||
</div>
|
||||
<?php echo $LogStorage->getTotalSources(); ?>
|
||||
</div>
|
||||
<div id="heatmap-group">
|
||||
<?php echo $Groups->loading(); ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 br-r">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Stored data'); ?>
|
||||
</div>
|
||||
<?php echo $LogStorage->getStoredData(); ?>
|
||||
<span class="indicative-text"><?php echo __('Lines'); ?></span>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Age of stored data'); ?>
|
||||
</div>
|
||||
<?php echo $LogStorage->getAgeOfStoredData(); ?>
|
||||
<span class="indicative-text"><?php echo __('Days'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($LogStorage->isEnabled() === true && $SnmpTraps->isEnabled() === true) : ?>
|
||||
<div class="col-6">
|
||||
<?php if ($LogStorage->isEnabled() === true) : ?>
|
||||
<div class="container mrgn_5px" id="logStorage">
|
||||
<div class="title br-b">
|
||||
<?php echo $LogStorage->title; ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 br-r br-b">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Log storage status'); ?>
|
||||
</div>
|
||||
<?php echo $LogStorage->getStatus(); ?>
|
||||
</div>
|
||||
<div class="col-6 br-b">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Total sources'); ?>
|
||||
</div>
|
||||
<?php echo $LogStorage->getTotalSources(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 br-r">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Stored data'); ?>
|
||||
</div>
|
||||
<?php echo $LogStorage->getStoredData(); ?>
|
||||
<span class="indicative-text"><?php echo __('Lines'); ?></span>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Age of stored data'); ?>
|
||||
</div>
|
||||
<?php echo $LogStorage->getAgeOfStoredData(); ?>
|
||||
<span class="indicative-text"><?php echo __('Days'); ?></span>
|
||||
</div>
|
||||
<div class="container mrgn_5px" id="SNMPTraps">
|
||||
<div class="title br-b">
|
||||
<?php echo $SnmpTraps->title; ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 br-r">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Trap queues'); ?>
|
||||
</div>
|
||||
<?php echo $SnmpTraps->getQueues(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($SnmpTraps->isEnabled() === true) : ?>
|
||||
<div class="container mrgn_5px" id="SNMPTraps">
|
||||
<div class="title br-b">
|
||||
<?php echo $SnmpTraps->title; ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 br-r">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Trap queues'); ?>
|
||||
</div>
|
||||
<?php echo $SnmpTraps->getQueues(); ?>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Total sources'); ?>
|
||||
</div>
|
||||
<?php echo $SnmpTraps->getTotalSources(); ?>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Total sources'); ?>
|
||||
</div>
|
||||
<?php echo $SnmpTraps->getTotalSources(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -249,9 +236,9 @@
|
|||
</div>
|
||||
<div class="col-6 br-l">
|
||||
<div class="subtitle">
|
||||
<?php echo __('Active correlation'); ?>
|
||||
<?php echo __('Active alerts'); ?>
|
||||
</div>
|
||||
<?php echo $Alerts->getActiveCorrelation(); ?>
|
||||
<?php echo $Alerts->getActiveAlerts(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($Alerts->checkAclUserList() === true) : ?>
|
||||
|
@ -265,47 +252,47 @@
|
|||
</div>
|
||||
</div>
|
||||
<?php if ($Events->checkAcl() === true) : ?>
|
||||
<div class="col-md-9 pdd_5px">
|
||||
<div class="container overflow_hidden" id="Events">
|
||||
<div class="title br-b">
|
||||
<?php echo $Events->title; ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8 br-r">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Number of events per hour (24 hrs)'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="events-last-24"><?php echo $Events->loading(); ?></div>
|
||||
<div class="row br-t h100p">
|
||||
<div class="col-4 br-r">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Criticality'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="events-criticality"><?php echo $Events->loading(); ?></div>
|
||||
</div>
|
||||
<div class="col-4 br-r">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Status'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="events-status-validate"><?php echo $Events->loading(); ?></div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Pending validation'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="events-status-pending-validate"><?php echo $Events->loading(); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9 pdd_5px">
|
||||
<div class="container overflow_hidden" id="Events">
|
||||
<div class="title br-b">
|
||||
<?php echo $Events->title; ?>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Active events (8 hrs)'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
<div class="row">
|
||||
<div class="col-8 br-r">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Number of events per hour (24 hrs)'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="events-last-24"><?php echo $Events->loading(); ?></div>
|
||||
<div class="row br-t h100p">
|
||||
<div class="col-4 br-r">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Criticality'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="events-criticality"><?php echo $Events->loading(); ?></div>
|
||||
</div>
|
||||
<div class="col-4 br-r">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Status'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="events-status-validate"><?php echo $Events->loading(); ?></div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Pending validation'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<div id="events-status-pending-validate"><?php echo $Events->loading(); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="subtitle link padding10 padding2">
|
||||
<?php echo __('Active events (8 hrs)'); ?></b> <a href=""><?php echo __('Info'); ?></a>
|
||||
</div>
|
||||
<?php echo $Events->getDataTableEvents(); ?>
|
||||
</div>
|
||||
<?php echo $Events->getDataTableEvents(); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
@ -368,7 +355,7 @@
|
|||
<?php echo $Configurations->getTotalRemotePlugins(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row flex-nowrap">
|
||||
<div class="row flex-nowrap br-b">
|
||||
<div class="col-4 flex flex-column center pdd_20px br-r">
|
||||
<?php echo $Configurations->getTotalModuleTemplate(); ?>
|
||||
</div>
|
||||
|
@ -380,12 +367,14 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container mrgn_5px">
|
||||
<div class="title br-b">
|
||||
<?php echo $ScheduledDowntime->title; ?>
|
||||
<?php if ($ScheduledDowntime->checkAcl() === true) : ?>
|
||||
<div class="container mrgn_5px">
|
||||
<div class="title br-b">
|
||||
<?php echo $ScheduledDowntime->title; ?>
|
||||
</div>
|
||||
<?php echo $ScheduledDowntime->list(); ?>
|
||||
</div>
|
||||
<?php echo $ScheduledDowntime->list(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
|
Loading…
Reference in New Issue