From a71c26b4a78bce64f093c55c2feaaf442849a08b Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 5 Jul 2022 17:44:52 +0200 Subject: [PATCH] #9029 Added starmap --- pandora_console/include/functions_agents.php | 144 ++++++++++++++++++ pandora_console/include/graphs/pandora.d3.js | 2 +- pandora_console/include/styles/heatmap.css | 16 ++ pandora_console/include/styles/pandora.css | 21 +-- .../agentes/estado_generalagente.php | 10 +- 5 files changed, 176 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 5b5d66c85f..5c337f912b 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4294,3 +4294,147 @@ function agents_get_offspring(int $id_agent) return $return; } + + +function agents_get_starmap(int $id_agent, float $width=0, float $height=0) +{ + ui_require_css_file('heatmap'); + + // $all_modules = agents_get_modules($id_agent); + // if (empty($all_modules)) { + // return null; + // } + // $total_modules = count($all_modules); + $all_modules = []; + $total_modules = 200; + $contador = 0; + while ($contador < $total_modules) { + $contador++; + $all_modules[$contador] = ''; + } + + // 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_modules) { + $low = $mid; + } else { + $high = $mid; + } + } + + $square_length = min(($width / floor($width / $low)), ($height / floor($height / $low))); + + // Print starmap. + $html = sprintf( + '', + $id_agent, + $width, + $height + ); + + $html .= ''; + $row = 0; + $column = 0; + $x = 0; + $y = 0; + $cont = 1; + foreach ($all_modules as $key => $value) { + // Colour by status. + // $status = modules_get_agentmodule_status($key); + $status = random_int(0, 5); + switch ($status) { + case 0: + case 4: + case 300: + $status = 'normal'; + break; + + case 1: + case 100: + $status = 'critical'; + break; + + case 2: + case 200: + $status = 'warning'; + break; + + case 3: + $status = 'unknown'; + break; + + case 5: + $status = 'notinit'; + break; + } + + $html .= sprintf( + '', + '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++; + } + ?> + + '; + $html .= ''; + + return $html; +} diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index d081cf7fca..896149b892 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -2869,7 +2869,7 @@ function donutNarrowGraph( arc = d3.svg .arc() .outerRadius(radius) - .innerRadius(radius - radius / 6); + .innerRadius(radius - radius / 4); svg = donutbody .append("svg") diff --git a/pandora_console/include/styles/heatmap.css b/pandora_console/include/styles/heatmap.css index bac09b561e..12db5cc399 100644 --- a/pandora_console/include/styles/heatmap.css +++ b/pandora_console/include/styles/heatmap.css @@ -159,10 +159,26 @@ fill: #cccccc; } +.notinit_10, +.notinit_9, +.notinit_8, .notinit { fill: #4a83f3; } +.notinit_7, +.notinit_6, +.notinit_5, +.notinit_4 { + fill: #6695f5; +} + +.notinit_3, +.notinit_2, +.notinit_1 { + fill: #79a3f6; +} + .hover { cursor: pointer; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index ae109ba20d..e886ccc7aa 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5614,12 +5614,12 @@ div#bullets_modules div { } .agent_details_col_left { - width: 40%; - min-width: 300px; + width: 49%; + min-width: 450px; } .agent_details_col_right { - width: 59%; - min-width: 480px; + width: 49%; + min-width: 450px; } .agent_access_rate_events { @@ -5630,14 +5630,15 @@ div#bullets_modules div { } .white_table_graph#table_access_rate { - flex: 1 1 auto; - min-width: 450px; - margin-right: 1%; + margin-left: 1px; + margin-right: 1px; + width: 49%; } .white_table_graph#table_events { - flex: 1 1 auto; - min-width: 450px; + margin-left: 1px; + margin-right: 1px; + width: 49%; } @media screen and (max-width: 1150px) { @@ -5676,7 +5677,7 @@ div#status_pie { justify-content: flex-end; align-items: center; border-bottom: 1px solid #e2e2e2; - padding: 6px 20px; + padding: 8px 20px; } .agent_details_content { diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 57109fa837..3b93f8edef 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -74,9 +74,7 @@ if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') return; } -$alive_animation = agents_get_status_animation( - agents_get_interval_status($agent, false) -); +$alive_animation = agents_get_starmap($id_agente, 200, 50); /* * START: TABLE AGENT BUILD. @@ -170,10 +168,10 @@ $status_img = agents_detail_view_status_img( $table_agent_header .= '
'.$status_img.'
'; // Fixed width non interactive charts. -$status_chart_width = 180; -$graph_width = 180; +$status_chart_width = 150; +$graph_width = 150; -$table_agent_graph = '
'; +$table_agent_graph = '
'; $table_agent_graph .= graph_agent_status( $id_agente, $graph_width,