#10194 new sections in general tactical view

This commit is contained in:
Daniel Cebrian 2023-09-28 16:10:57 +02:00
parent 62d501e6d5
commit 9f5836e2cc
14 changed files with 1101 additions and 16 deletions

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="27px" height="27px" viewBox="0 0 27 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>59DFD8E8-D019-4076-8FED-D5B81BE90197</title>
<g id="Welcome-dashboard---v1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Tactical-view-v4" transform="translate(-1185, -1810)" fill="#95A3BF">
<g id="Log-storage" transform="translate(1102, 1739)">
<g id="Card-1/8" transform="translate(15, 71)">
<g id="Groups" transform="translate(68, 0)">
<rect id="Rectangle" x="0" y="0" width="5.4" height="5.4" rx="0.5"></rect>
<rect id="Rectangle-Copy-2" x="0" y="21.6" width="5.4" height="5.4" rx="0.5"></rect>
<rect id="Rectangle-Copy" x="21.6" y="0" width="5.4" height="5.4" rx="0.5"></rect>
<rect id="Rectangle-Copy-3" x="21.6" y="21.6" width="5.4" height="5.4" rx="0.5"></rect>
<path d="M24.3,2.7 L24.3,24.3 L2.7,24.3 L2.7,2.7 L24.3,2.7 Z M19.06875,10.8 L17.55,10.8 L17.55,16.36875 C17.55,17.0211364 17.0211364,17.55 16.36875,17.55 L10.8,17.549 L10.8,19.06875 C10.8,19.7211364 11.3288636,20.25 11.98125,20.25 L19.06875,20.25 C19.7211364,20.25 20.25,19.7211364 20.25,19.06875 L20.25,11.98125 C20.25,11.3288636 19.7211364,10.8 19.06875,10.8 Z M15.01875,6.75 L7.93125,6.75 C7.27886364,6.75 6.75,7.27886364 6.75,7.93125 L6.75,15.01875 C6.75,15.6711364 7.27886364,16.2 7.93125,16.2 L15.01875,16.2 C15.6711364,16.2 16.2,15.6711364 16.2,15.01875 L16.2,7.93125 C16.2,7.27886364 15.6711364,6.75 15.01875,6.75 Z" id="Rectangle-2"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="27px" height="27px" viewBox="0 0 27 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>04A64774-B33A-4338-8092-D83F51BBE8C1</title>
<g id="Welcome-dashboard---v1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Tactical-view-v4" transform="translate(-1218, -1942)" fill="#95A3BF">
<g id="Log-storage" transform="translate(1102, 1739)">
<g id="Card-1/8" transform="translate(49, 203)">
<g id="Module-template" transform="translate(67, 0)">
<path d="M1,0 L26,0 C26.5522847,-1.01453063e-16 27,0.44771525 27,1 L27,8.45 C27,9.00228475 26.5522847,9.45 26,9.45 L1,9.45 C0.44771525,9.45 6.76353751e-17,9.00228475 0,8.45 L0,1 C-6.76353751e-17,0.44771525 0.44771525,1.01453063e-16 1,0 Z M11.8,10.8 L26,10.8 C26.5522847,10.8 27,11.2477153 27,11.8 L27,26 C27,26.5522847 26.5522847,27 26,27 L11.8,27 C11.2477153,27 10.8,26.5522847 10.8,26 L10.8,11.8 C10.8,11.2477153 11.2477153,10.8 11.8,10.8 Z" id="Rectangle-2"></path>
<path d="M8.45,10.8 C9.00228475,10.8 9.45,11.2477153 9.45,11.8 L9.45,26 C9.45,26.5522847 9.00228475,27 8.45,27 L1,27 C0.44771525,27 0,26.5522847 0,26 L0,11.8 C0,11.2477153 0.44771525,10.8 1,10.8 L8.45,10.8 Z M7.45,12.8 L2,12.8 L2,25 L7.45,25 L7.45,12.8 Z" id="Rectangle" fill-rule="nonzero"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="27px" height="27px" viewBox="0 0 27 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>CD5F043F-0CA1-4012-8590-20C64D7E7E0D</title>
<g id="Welcome-dashboard---v1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Tactical-view-v4" transform="translate(-1378, -1810)" fill="#95A3BF">
<g id="Log-storage" transform="translate(1102, 1739)">
<g id="Card-1/8" transform="translate(208, 71)">
<g id="Modules" transform="translate(68, 0)">
<path d="M25.3705078,4.29521484 L14.6865234,0.218847656 C14.3015625,0.0729316406 13.9007813,0 13.5,0 C13.0992187,0 12.6984375,0.0729316406 12.3134766,0.218583984 L1.62896484,4.29521484 C0.648105469,4.66962891 0,5.6109375 0,6.66035156 L0,20.3396484 C0,21.3895898 0.648105469,22.3303711 1.62896484,22.7047852 L12.3129492,26.7811523 C12.6984375,26.9261719 13.0992188,27 13.5,27 C13.9007813,27 14.3031445,26.9270684 14.6849414,26.781416 L25.3689258,22.7050488 C26.3513672,22.3330078 27,21.3890625 27,20.3396484 L27,6.66035156 C27,5.6109375 26.3513672,4.66962891 25.3705078,4.29521484 Z M13.0008122,3 L22,6.5303428 L13.0008122,10 L4,6.5314563 L13.0008122,3 Z M15,23 L15,13.1237485 L23,10 L23,19.8137765 L15,23 Z"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="27px" height="27px" viewBox="0 0 27 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>E1DA8ECF-DB7D-48B5-96B0-3C6199FCC8EB</title>
<g id="Welcome-dashboard---v1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Tactical-view-v4" transform="translate(-1476, -1942)" fill="#95A3BF">
<g id="Log-storage" transform="translate(1102, 1739)">
<g id="Card-1/8" transform="translate(306, 203)">
<g id="Not-init-module" transform="translate(68, 0)">
<path d="M1.51937106,7.28411239 C4.95205428,0.667087472 13.0993581,-1.91380755 19.7156094,1.51964932 C20.0173327,1.67592653 20.3097722,1.84226119 20.5937016,2.017106 L18.0128066,3.66652692 L18.009712,3.66575327 L12.8138814,6.98548365 L12.710986,2.70797508 C11.8669343,2.76986705 11.0344873,2.93078616 10.2322127,3.18531688 C7.59329397,4.02163208 5.27234521,5.86523905 3.8960226,8.51730983 C2.52047363,11.1693806 2.34872342,14.1285903 3.18503863,16.767509 C3.79544815,18.6923492 4.94122319,20.4477601 6.54499878,21.7908158 L4.20161418,23.2878278 C-0.0495902992,19.2532452 -1.31528102,12.7468521 1.51937106,7.28411239 Z M22.8349645,3.74853378 C27.0567703,7.78621097 28.3062144,14.2693945 25.4800724,19.7158876 C22.0473892,26.3329125 13.9008591,28.9138076 7.28383414,25.4803507 C6.99990474,25.3333573 6.72371184,25.17708 6.45448178,25.0122927 L6.50167441,24.9821203 L6.47769127,24.980573 L14.2312074,20.0261211 L14.2025824,24.2982141 C15.0760328,24.240964 15.9378784,24.077724 16.7672308,23.8146831 C19.4069232,22.9783679 21.7270983,21.134761 23.1034209,18.4826902 C24.4797435,15.8306194 24.6507201,12.8714097 23.8144049,10.232491 C23.2101845,8.32389744 22.0783352,6.58241222 20.4954481,5.24399843 Z M19.2403271,12.073777 C19.4297542,12.073777 19.5833153,12.227338 19.5833153,12.4167651 L19.5833153,14.5824612 C19.5833153,14.7718883 19.4297542,14.9254494 19.2403271,14.9254494 L7.75834273,14.9254494 C7.5689156,14.9254494 7.41535457,14.7718883 7.41535457,14.5824612 L7.41535457,12.4167651 C7.41535457,12.227338 7.5689156,12.073777 7.75834273,12.073777 L19.2403271,12.073777 Z"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="27px" height="27px" viewBox="0 0 27 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>E2220716-B06D-4CCD-8005-3668217A51C4</title>
<g id="Welcome-dashboard---v1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Tactical-view-v4" transform="translate(-1764, -1810)" fill="#95A3BF">
<g id="Log-storage" transform="translate(1102, 1739)">
<g id="Card-1/8" transform="translate(594, 71)">
<g id="Plugins" transform="translate(68, 0)">
<path d="M27,18.9 L27,24.3 C27,25.7911688 25.7911688,27 24.3,27 L18.9,27 L18.9,24.3 C18.9,22.8088312 17.6911688,21.6 16.2,21.6 C14.7088312,21.6 13.5,22.8088312 13.5,24.3 L13.5,27 L8.1,27 C6.60883118,27 5.4,25.7911688 5.4,24.3 L5.4,18.9 L2.7,18.9 C1.20883118,18.9 0,17.6911688 0,16.2 C0,14.7088312 1.20883118,13.5 2.7,13.5 L5.4,13.5 L5.4,8.1 C5.4,6.615 6.615,5.4 8.1,5.4 L13.5,5.4 L13.5,2.7 C13.5,1.20883118 14.7088312,0 16.2,0 C17.6911688,0 18.9,1.20883118 18.9,2.7 L18.9,5.4 L24.3,5.4 C25.7911688,5.4 27,6.60883118 27,8.1 L27,13.5 L24.3,13.5 C22.8088312,13.5 21.6,14.7088312 21.6,16.2 C21.6,17.6911688 22.8088312,18.9 24.3,18.9 L27,18.9 Z" id="Path"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="21px" height="27px" viewBox="0 0 21 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>7780B3A6-04AD-41C0-83B2-12DA21E87CFC</title>
<g id="Welcome-dashboard---v1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Tactical-view-v4" transform="translate(-1574, -1810)" fill="#95A3BF">
<g id="Log-storage" transform="translate(1102, 1739)">
<g id="Card-1/8" transform="translate(401, 71)">
<g id="Policies" transform="translate(71, 0)">
<path d="M18,0 C19.6568542,-3.04359188e-16 21,1.34314575 21,3 L21,24 C21,25.6568542 19.6568542,27 18,27 L3,27 C1.34314575,27 2.02906125e-16,25.6568542 0,24 L0,3 C-2.02906125e-16,1.34314575 1.34314575,3.04359188e-16 3,0 L18,0 Z M15.35625,16.605 C14.83125,16.065 14.04375,16.065 13.51875,16.605 L9.1875,21.06 L7.48125,19.305 C7.021875,18.765 6.16875,18.765 5.64375,19.305 C5.11875,19.845 5.11875,20.655 5.64375,21.195 L8.26875,23.895 C8.53125,24.165 8.859375,24.3 9.1875,24.3 C9.515625,24.3 9.84375,24.165 10.10625,23.895 L15.35625,18.495 C15.88125,17.955 15.88125,17.145 15.35625,16.605 Z M16.0625,9.45 L4.9375,9.45 C4.38521525,9.45 3.9375,9.89771525 3.9375,10.45 L3.9375,11.15 C3.9375,11.7022847 4.38521525,12.15 4.9375,12.15 L16.0625,12.15 C16.6147847,12.15 17.0625,11.7022847 17.0625,11.15 L17.0625,10.45 C17.0625,9.89771525 16.6147847,9.45 16.0625,9.45 Z M16.0625,4.05 L4.9375,4.05 C4.38521525,4.05 3.9375,4.49771525 3.9375,5.05 L3.9375,5.75 C3.9375,6.30228475 4.38521525,6.75 4.9375,6.75 L16.0625,6.75 C16.6147847,6.75 17.0625,6.30228475 17.0625,5.75 L17.0625,5.05 C17.0625,4.49771525 16.6147847,4.05 16.0625,4.05 Z" id="Rectangle-2"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="27px" height="27px" viewBox="0 0 27 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>A8855F06-D8BF-417A-841F-4FBE78913DFF</title>
<g id="Welcome-dashboard---v1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Tactical-view-v4" transform="translate(-1734, -1942)" fill="#95A3BF">
<g id="Log-storage" transform="translate(1102, 1739)">
<g id="Card-1/8" transform="translate(564, 203)">
<g id="Unknown-agent" transform="translate(68, 0)">
<path d="M17.4053571,0.0521205975 C18.4487143,-0.201907204 19.5132857,0.496117015 19.7948571,1.67348065 L21.5151429,8.89670596 C21.5252191,8.9391051 21.5342228,8.98182907 21.5421429,9.02482433 C24.8535,9.62786424 27,10.5953788 27,11.6865939 C27,13.5155941 20.9558571,15 13.5,15 C6.04414286,15 0,13.5155941 0,11.6865939 C0,10.5953788 2.1465,9.62786424 5.45785714,9.02482433 L5.48485714,8.89670596 L7.20514286,1.67568959 C7.48671429,0.493908078 8.55128571,-0.201907204 9.59464286,0.0521205975 C10.7787857,0.341491397 12.3042857,0.641906884 13.5,0.641906884 C14.6957143,0.641906884 16.2212143,0.33928246 17.4053571,0.0521205975 Z M7.7625,9.72284855 C7.63511282,9.70805077 7.50781825,9.75189759 7.40868802,9.84471966 C7.30955779,9.93754173 7.24673418,10.0717149 7.23407143,10.2176505 C7.22115184,10.3635566 7.25943347,10.5093566 7.34047424,10.6228979 C7.42151502,10.7364392 7.53865846,10.8083958 7.66607143,10.8228994 C9.4365,11.0283306 11.4152143,11.1431953 13.5,11.1431953 C15.5847857,11.1431953 17.5635,11.0283306 19.3339286,10.8228994 C19.5991436,10.7924003 19.7925566,10.5214212 19.7659286,10.2176505 C19.7393005,9.91387988 19.502715,9.69234949 19.2375,9.72284855 C17.3308445,9.93842752 15.4159177,10.0438538 13.5,10.0387266 C11.4460714,10.0387266 9.49821429,9.92607079 7.7625,9.72284855 Z M1.92582418,20 C1.92582418,19.65 1.98351648,19.312 2.08928571,19 L1.92582418,19 C1.39478115,19 0.964285714,18.5522847 0.964285714,18 C0.964285714,17.4477153 1.39478115,17 1.92582418,17 L8.65659341,17 C10.1098077,17.0001733 11.3359957,18.1245745 11.5181319,19.624 C12.7872537,19.2253356 14.1413177,19.2253356 15.4104396,19.624 C15.5925757,18.1245745 16.8187637,17.0001733 18.271978,17 L25.0027473,17 C25.5337903,17 25.9642857,17.4477153 25.9642857,18 C25.9642857,18.5522847 25.5337903,19 25.0027473,19 L24.8392857,19 C24.9450549,19.312 25.0027473,19.65 25.0027473,20 L25.0027473,22 C25.0027473,24.7614237 22.8502701,27 20.1950549,27 C17.5398398,27 15.3873626,24.7614237 15.3873626,22 L15.3873626,21.72 L14.9835165,21.58 C13.9973271,21.2383946 12.9312443,21.2383946 11.9450549,21.58 L11.5412088,21.72 L11.5412088,22 C11.5412088,24.7614237 9.38873163,27 6.73351648,27 C4.07830134,27 1.92582418,24.7614237 1.92582418,22 L1.92582418,20 L1.92582418,20 Z" id="Shape"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -134,8 +134,9 @@ function render_counter() {
$(".counter-tips img:eq(0)").after(
"<span class='count-round-tip active'></span>"
);
if (totalTips > 1) {
for (let i = 1; i <= totalTips - 1; i++) {
var limitRound = totalTips > 28 ? 28 : totalTips;
if (limitRound > 1) {
for (let i = 1; i <= limitRound - 1; i++) {
$(".count-round-tip:eq(0)").after(
"<span class='count-round-tip'></span>"
);

View File

@ -0,0 +1,309 @@
<?php
/**
* Agents element for tactical view.
*
* @category General
* @package Pandora FMS
* @subpackage TacticalView
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
use PandoraFMS\TacticalView\Element;
/**
* Agents, this class contain all logic for this section.
*/
class Agents extends Element
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->title = __('Agents');
$this->ajaxMethods = ['getGroups'];
}
/**
* Get total number of agents.
*
* @return string
*/
public function getTotalAgents():string
{
// TODO connect to automonitorization.
return html_print_div(
[
'content' => '9.999.999',
'class' => 'text-l',
'style' => 'margin: 0px 10px 10px 10px;',
],
true
);
}
/**
* Get total alerts of agents.
*
* @return string
*/
public function getAlerts():string
{
// TODO connect to automonitorization.
return html_print_div(
[
'content' => '9.999.999',
'class' => 'text-l',
'style' => 'margin: 0px 10px 10px 10px;',
],
true
);
}
/**
* Get a datatable with the top groups with more agents.
*
* @return string
*/
public function getDataTableGroups():string
{
$columns = [
'nombre',
'total',
];
$columnNames = [
__('Group alias'),
__('Agents'),
];
return ui_print_datatable(
[
'id' => 'list_groups',
'class' => 'info_table',
'style' => 'width: 90%',
'dom_elements' => 'tfp',
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
'columns' => $columns,
'column_names' => $columnNames,
'ajax_url' => $this->ajaxController,
'no-filtered' => [-1],
'ajax_data' => [
'method' => 'getGroups',
'class' => static::class,
],
'order' => [
'field' => 'title',
'direction' => 'asc',
],
'default_pagination' => 8,
'search_button_class' => 'sub filter float-right',
'return' => true,
]
);
}
/**
* Return top 20 groups with more agents for ajax datatable.
*
* @return void
*/
public function getGroups():void
{
global $config;
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$pagination = '';
$order = '';
try {
ob_start();
if (isset($length) && $length > 0
&& isset($start) && $start >= 0
) {
$pagination = sprintf(
' LIMIT %d OFFSET %d ',
$length,
$start
);
}
$sql = sprintf(
'SELECT gr.nombre, count(*) +
IFNULL((SELECT count(*) AS total
FROM tagente second_a
LEFT JOIN tagent_secondary_group second_g ON second_g.id_agent = second_a.id_agente
WHERE a.id_grupo = second_g.id_group
GROUP BY second_g.id_group
), 0) AS total
FROM tagente a
LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente
LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo
INNER JOIN(
SELECT gr.id_grupo, count(*) AS total
FROM tagente a LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente
LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo
GROUP BY a.id_grupo ORDER BY total DESC LIMIT 20
) top_groups ON top_groups.id_grupo = gr.id_grupo
GROUP BY a.id_grupo
ORDER BY total DESC
%s',
$pagination
);
$rows = db_process_sql($sql);
$sql_count = 'SELECT gr.nombre,
IFNULL((SELECT count(*) AS total
FROM tagente second_a
LEFT JOIN tagent_secondary_group second_g ON second_g.id_agent = second_a.id_agente
WHERE a.id_grupo = second_g.id_group
GROUP BY second_g.id_group
), 0) AS total
FROM tagente a
LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente
LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo
INNER JOIN(
SELECT gr.id_grupo, count(*) AS total
FROM tagente a LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente
LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo
GROUP BY a.id_grupo ORDER BY total DESC LIMIT 20
) top_groups ON top_groups.id_grupo = gr.id_grupo
GROUP BY a.id_grupo
ORDER BY total DESC';
$total = db_get_num_rows($sql_count);
echo json_encode(
[
'data' => $rows,
'recordsTotal' => $total,
'recordsFiltered' => $total,
]
);
// Capture output.
$response = ob_get_clean();
} catch (Exception $e) {
echo json_encode(['error' => $e->getMessage()]);
exit;
}
json_decode($response);
if (json_last_error() === JSON_ERROR_NONE) {
echo $response;
} else {
echo json_encode(
[
'success' => false,
'error' => $response,
]
);
}
}
/**
* Return the html graph of number agents by os.
*
* @return string
*/
public function getOperatingSystemGraph():string
{
$sql = 'SELECT name, count(*) AS total
FROM tagente a
LEFT JOIN tconfig_os os ON os.id_os = a.id_os
GROUP BY a.id_os
ORDER BY total DESC';
$rows = db_process_sql($sql);
$labels = [];
$data = [];
foreach ($rows as $key => $row) {
$labels[] = $this->controlSizeText($row['name']);
$data[] = $row['total'];
}
$options = [
'labels' => $labels,
'legend' => [
'position' => 'bottom',
'align' => 'right',
'display' => false,
],
'cutout' => 80,
'nodata_image' => ['width' => '100%'],
];
$pie = ring_graph($data, $options);
$output = html_print_div(
[
'content' => $pie,
'style' => 'margin: 0 auto; max-width: 80%; max-height: 220px;',
],
true
);
return $output;
}
/**
* Return the html graph of number agents by status.
*
* @return string
*/
public function getStatusGraph():string
{
// TODO Find the method for calculate status in agents.
$labels = [];
$data = [];
foreach ([] as $key => $row) {
$labels[] = $this->controlSizeText($row['alias']);
$data[] = $row['status'];
}
$options = [
'labels' => $labels,
'legend' => [
'position' => 'bottom',
'align' => 'right',
'display' => false,
],
'cutout' => 80,
'nodata_image' => ['width' => '80%'],
];
$pie = ring_graph($data, $options);
$output = html_print_div(
[
'content' => $pie,
'style' => 'margin: 0 auto; max-width: 80%; max-height: 220px;',
],
true
);
return $output;
}
}

View File

@ -0,0 +1,224 @@
<?php
/**
* Configurations element for tactical view.
*
* @category General
* @package Pandora FMS
* @subpackage TacticalView
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
use PandoraFMS\TacticalView\Element;
/**
* Configurations, this class contain all logic for this section.
*/
class Configurations extends Element
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->title = __('Configurations');
}
/**
* Get total groups from automonitorization.
*
* @return string
*/
public function getTotalGroups():string
{
// TODO connect to automonitorization.
$image = html_print_image('images/Tactical_Groups.svg', true);
$text = '<span class="subtitle">'.__('Groups').'</span>';
$number = html_print_div(
[
'content' => '999.999',
'class' => 'text-l text_center',
'style' => '',
],
true
);
$output = $image.$text.$number;
return $output;
}
/**
* Get total modules from automonitorization.
*
* @return string
*/
public function getTotalModules():string
{
// TODO connect to automonitorization.
$image = html_print_image('images/Tactical_Modules.svg', true);
$text = '<span class="subtitle">'.__('Modules').'</span>';
$number = html_print_div(
[
'content' => '999.999',
'class' => 'text-l text_center',
'style' => '',
],
true
);
$output = $image.$text.$number;
return $output;
}
/**
* Get total policies from automonitorization.
*
* @return string
*/
public function getTotalPolicies():string
{
$totalPolicies = db_get_value(
'count(*)',
'tpolicies'
);
$image = html_print_image('images/Tactical_Policies.svg', true);
$text = '<span class="subtitle">'.__('Policies').'</span>';
$number = html_print_div(
[
'content' => $totalPolicies,
'class' => 'text-l text_center',
'style' => '',
],
true
);
$output = $image.$text.$number;
return $output;
}
/**
* Get total remote plugins from automonitorization.
*
* @return string
*/
public function getTotalRemotePlugins():string
{
$totalPLugins = db_get_value(
'count(*)',
'tplugin',
'plugin_type',
1,
);
$sql = 'SELECT count(*) AS total FROM tplugin WHERE plugin_type = 1;';
$rows = db_process_sql($sql);
$totalPLugins = 0;
if (is_array($rows) === true && count($rows) > 0) {
$totalPLugins = $rows[0]['total'];
}
$image = html_print_image('images/Tactical_Plugins.svg', true);
$text = '<span class="subtitle">'.__('Remote plugins').'</span>';
$number = html_print_div(
[
'content' => $totalPLugins,
'class' => 'text-l text_center',
'style' => '',
],
true
);
$output = $image.$text.$number;
return $output;
}
/**
* Get total module templates from automonitorization.
*
* @return string
*/
public function getTotalModuleTemplate():string
{
$countModuleTemplates = db_get_value(
'count(*)',
'tnetwork_profile'
);
$image = html_print_image('images/Tactical_Module_template.svg', true);
$text = '<span class="subtitle">'.__('Module templates').'</span>';
$number = html_print_div(
[
'content' => $countModuleTemplates,
'class' => 'text-l text_center',
'style' => '',
],
true
);
$output = $image.$text.$number;
return $output;
}
/**
* Get total not unit modules from automonitorization.
*
* @return string
*/
public function getNotInitModules():string
{
// TODO connect to automonitorization.
$image = html_print_image('images/Tactical_Not_init_module.svg', true);
$text = '<span class="subtitle">'.__('Not-init modules').'</span>';
$number = html_print_div(
[
'content' => '999.999',
'class' => 'text-l text_center',
'style' => '',
],
true
);
$output = $image.$text.$number;
return $output;
}
/**
* Get total unknow agents from automonitorization.
*
* @return string
*/
public function getTotalUnknowAgents():string
{
// TODO connect to automonitorization.
$image = html_print_image('images/Tactical_Unknown_agent.svg', true);
$text = '<span class="subtitle">'.__('Unknown agents').'</span>';
$number = html_print_div(
[
'content' => '999.999',
'class' => 'text-l text_center',
'style' => '',
],
true
);
$output = $image.$text.$number;
return $output;
}
}

View File

@ -137,9 +137,14 @@ class MonitoringElements extends Element
*/
public function getAgentGroupsGraph():string
{
$sql = 'SELECT gr.nombre, count(*) AS total
$sql = 'SELECT gr.nombre, count(*) +
IFNULL((SELECT count(*) AS total
FROM tagente second_a
LEFT JOIN tagent_secondary_group second_g ON second_g.id_agent = second_a.id_agente
WHERE a.id_grupo = second_g.id_group
GROUP BY second_g.id_group
), 0) AS total
FROM tagente a
LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente
LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo
GROUP BY a.id_grupo
ORDER BY total DESC

View File

@ -0,0 +1,251 @@
<?php
/**
* ScheduledDowntime element for tactical view.
*
* @category General
* @package Pandora FMS
* @subpackage TacticalView
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
use PandoraFMS\TacticalView\Element;
/**
* ScheduledDowntime, this class contain all logic for this section.
*/
class ScheduledDowntime extends Element
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
ui_require_javascript_file('pandora_planned_downtimes');
$this->title = __('Scheduled Downtime');
$this->ajaxMethods = ['getScheduleDowntime'];
}
/**
* List all schedule downtime.
*
* @return string
*/
public function list():string
{
$columns = [
'name',
'configuration',
'running',
'affected',
];
$columnNames = [
__('Name #Ag.'),
__('Configuration'),
__('Running'),
__('Affected'),
];
return ui_print_datatable(
[
'id' => 'list_downtime',
'class' => 'info_table',
'style' => 'width: 90%',
'dom_elements' => 'tfp',
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
'columns' => $columns,
'column_names' => $columnNames,
'ajax_url' => $this->ajaxController,
'no_sortable_columns' => [
1,
2,
],
'ajax_data' => [
'method' => 'getScheduleDowntime',
'class' => static::class,
],
'order' => [
'field' => 'name',
'direction' => 'asc',
],
'default_pagination' => 5,
'search_button_class' => 'sub filter float-right',
'return' => true,
]
);
}
/**
* Return the schedule downtime for datatable by ajax.
*
* @return void
*/
public function getScheduleDowntime():void
{
global $config;
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$orderDatatable = get_datatable_order(true);
$pagination = '';
$order = '';
try {
ob_start();
if (isset($orderDatatable)) {
$order = sprintf(
' ORDER BY %s %s',
$orderDatatable['field'],
$orderDatatable['direction']
);
}
if (isset($length) && $length > 0
&& isset($start) && $start >= 0
) {
$pagination = sprintf(
' LIMIT %d OFFSET %d ',
$length,
$start
);
}
$columns = [
'id',
'name',
'description',
'date_from',
'date_to',
'executed',
'id_group',
'only_alerts',
'monday',
'tuesday',
'wednesday',
'thursday',
'friday',
'saturday',
'sunday',
'periodically_time_from',
'periodically_time_to',
'periodically_day_from',
'periodically_day_to',
'type_downtime',
'type_execution',
'type_periodicity',
'id_user',
'cron_interval_from',
'cron_interval_to',
];
$columns_str = implode(',', $columns);
$sql = sprintf(
'SELECT %s
FROM tplanned_downtime
%s %s',
$columns_str,
$order,
$pagination,
);
$sql_count = 'SELECT COUNT(id) AS num
FROM tplanned_downtime';
$downtimes = db_get_all_rows_sql($sql);
foreach ($downtimes as $key => $downtime) {
if ((int) $downtime['executed'] === 0) {
$downtimes[$key]['running'] = html_print_div(
[
'content' => '',
'class' => 'square stop',
'title' => 'Not running',
],
true
);
} else {
$downtimes[$key]['running'] = html_print_div(
[
'content' => '',
'class' => 'square running',
'title' => 'Running',
],
true
);
}
$downtimes[$key]['configuration'] = reporting_format_planned_downtime_dates($downtime);
$settings = [
'url' => ui_get_full_url('ajax.php', false, false, false),
'loadingText' => __('Loading, this operation might take several minutes...'),
'title' => __('Elements affected'),
'id' => $downtime['id'],
];
$downtimes[$key]['affected'] = '<a style="margin-left: 22px;" href="javascript:" onclick=\'dialogAgentModulesAffected('.json_encode($settings).')\'>';
$downtimes[$key]['affected'] .= html_print_image(
'images/details.svg',
true,
[
'title' => __('Agents and modules affected'),
'class' => 'main_menu_icon invert_filter',
]
);
$downtimes[$key]['affected'] .= '</a>';
}
$downtimes_number_res = db_get_all_rows_sql($sql_count);
$downtimes_number = ($downtimes_number_res !== false) ? $downtimes_number_res[0]['num'] : 0;
if (empty($downtimes) === true) {
$downtimes = [];
}
echo json_encode(
[
'data' => $downtimes,
'recordsTotal' => $downtimes_number,
'recordsFiltered' => $downtimes_number,
]
);
// Capture output.
$response = ob_get_clean();
} catch (Exception $e) {
echo json_encode(['error' => $e->getMessage()]);
exit;
}
json_decode($response);
if (json_last_error() === JSON_ERROR_NONE) {
echo $response;
} else {
echo json_encode(
[
'success' => false,
'error' => $response,
]
);
}
exit;
}
}

View File

@ -26,7 +26,7 @@
.col-xl-6 {
width: 50%;
display: flex;
flex-wrap: wrap;
flex-wrap: nowrap;
flex-direction: column;
}
.col-7 {
@ -36,15 +36,17 @@
width: 66.6%;
}
.col-4 {
width: 33.3%;
width: 33%;
}
.col-5 {
width: 42%;
}
.col-3 {
.col-3,
.col-md-3 {
width: 25%;
}
.col-9 {
.col-9,
.col-md-9 {
width: 75%;
}
.container {
@ -121,7 +123,8 @@
#database .subtitle,
#logStorage .subtitle,
#SNMPTraps .subtitle,
#Alerts .subtitle {
#Alerts .subtitle,
#Agents .subtitle {
padding: 10px 10px 5px 10px;
}
@ -200,7 +203,7 @@ a.pandora_pagination:first-child {
margin-left: 7px !important;
}
.datatables_thead_tr th:nth-child(1) {
#datatable_events .datatables_thead_tr th:nth-child(1) {
width: 10.3333px !important;
padding: 20px 0px 20px 15px !important;
}
@ -209,6 +212,26 @@ a.pandora_pagination:first-child {
font-size: 13px !important;
}
table.dataTable thead th {
padding: 0px 18px !important;
}
#list_downtime_wrapper {
margin: 28px 0px;
}
.square {
width: 20px;
height: 20px;
margin-left: 20px;
}
.running {
background-color: #82b92e;
}
.stop {
background-color: #ec7176;
}
@media (max-width: 1636px) {
.col-xl-6 {
width: 100%;
@ -216,7 +239,27 @@ a.pandora_pagination:first-child {
.col-6 {
width: 49%;
}
.col-3 {
width: 21%;
}
.col-4 {
width: 30%;
}
.row {
flex-wrap: wrap;
}
.flex-nowrap {
flex-wrap: nowrap !important;
}
}
@media (max-width: 1300px) {
.col-md-9,
.col-md-3 {
width: 100%;
}
.col-6 {
width: 49%;
}
}

View File

@ -4,7 +4,7 @@
</div>
<div class="row">
<div class="col-6">
<div class="col-xl-6">
<div id="general-overview">
<div class="container">
<div class="title">
@ -60,13 +60,13 @@
<div class="row">
<div class="col-6 br-r br-b">
<div class="subtitle link padding10 padding2">
<?php echo __('Tags'); ?> <a href=""><?php echo __('Info'); ?></a>
<?php echo __('Top-10 Tags'); ?> <a href=""><?php echo __('Info'); ?></a>
</div>
<?php echo $MonitoringElements->getTagsGraph(); ?>
</div>
<div class="col-6 br-b">
<div class="subtitle link padding10 padding2">
<?php echo __('By modules groups'); ?> <a href=""><?php echo __('Info'); ?></a>
<?php echo __('Top-10 module groups'); ?> <a href=""><?php echo __('Info'); ?></a>
</div>
<?php echo $MonitoringElements->getModuleGroupGraph(); ?>
</div>
@ -80,7 +80,7 @@
</div>
<div class="col-6 br-l">
<div class="subtitle link padding10 padding2">
<?php echo __('Groups'); ?> <a href=""><?php echo __('Info'); ?></a>
<?php echo __('Top-10 Groups'); ?> <a href=""><?php echo __('Info'); ?></a>
</div>
<?php echo $MonitoringElements->getAgentGroupsGraph(); ?>
</div>
@ -141,7 +141,7 @@
</div>
</div>
</div>
<div class="col-6">
<div class="col-xl-6">
<div class="container">
<div class="title">
<?php echo $NewsBoard->title; ?>
@ -223,9 +223,151 @@
</div>
<div class="row">
<div class="col-md-3">
<div class="container" id="Alerts">
<div class="title br-b">
<?php echo $Alerts->title; ?>
</div>
<div class="row">
<div class="col-6">
<div class="subtitle">
<?php echo __('Currently triggered'); ?>
</div>
<?php echo $Alerts->getCurrentlyTriggered(); ?>
</div>
<div class="col-6 br-l">
<div class="subtitle">
<?php echo __('Active correlation'); ?>
</div>
<?php echo $Alerts->getActiveCorrelation(); ?>
</div>
</div>
<div class="subtitle link padding10 padding2 br-t">
<b><?php echo __('Logged in users (24 hrs)'); ?></b> <a href=""><?php echo __('More details'); ?></a>
</div>
<?php echo $Alerts->getDataTableUsers(); ?>
</div>
</div>
<div class="col-md-9">
<div class="container" 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>
<?php echo $Events->getEventsGraph(); ?>
<div class="row br-t">
<div class="col-4 br-r">
<div class="subtitle link padding10 padding2">
<?php echo __('Criticality'); ?></b> <a href=""><?php echo __('Info'); ?></a>
</div>
<?php echo $Events->getEventsCriticalityGraph(); ?>
</div>
<div class="col-4 br-r">
<div class="subtitle link padding10 padding2">
<?php echo __('Status'); ?></b> <a href=""><?php echo __('Info'); ?></a>
</div>
<?php echo $Events->getEventsStatusValidateGraph(); ?>
</div>
<div class="col-4">
<div class="subtitle link padding10 padding2">
<?php echo __('Pending validation'); ?></b> <a href=""><?php echo __('Info'); ?></a>
</div>
<?php echo $Events->getEventsStatusValidateGraph(); ?>
</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>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-6">
<div class="container" id="Agents">
<div class="title br-b">
<?php echo $Agents->title; ?>
</div>
<div class="row">
<div class="col-6 br-r">
<div class="row br-b">
<div class="col-6 br-r">
<div class="subtitle">
<?php echo __('Total agents'); ?>
</div>
<?php echo $Agents->getTotalAgents(); ?>
</div>
<div class="col-6">
<div class="subtitle">
<?php echo __('Alerts (24hrs)'); ?>
</div>
<?php echo $Agents->getAlerts(); ?>
</div>
</div>
<div class="subtitle link padding10 padding2">
<?php echo __('Top 20 groups'); ?></b> <a href=""><?php echo __('More details'); ?></a>
</div>
<?php echo $Agents->getDataTableGroups(); ?>
</div>
<div class="col-6">
<div class="subtitle link padding10 padding2">
<?php echo __('Operating system'); ?></b> <a href=""><?php echo __('Info'); ?></a>
</div>
<?php echo $Agents->getOperatingSystemGraph(); ?>
<div class="subtitle link padding10 padding2 br-t">
<?php echo __('Status'); ?></b> <a href=""><?php echo __('Info'); ?></a>
</div>
<?php echo $Agents->getOperatingSystemGraph(); ?>
</div>
</div>
</div>
</div>
<div class="col-xl-6">
<div class="container" id="Agents">
<div class="title br-b">
<?php echo $Configurations->title; ?>
</div>
<div class="row br-b flex-nowrap">
<div class="col-3 flex flex-column center pdd_20px br-r">
<?php echo $Configurations->getTotalGroups(); ?>
</div>
<div class="col-3 flex flex-column center pdd_20px br-r">
<?php echo $Configurations->getTotalModules(); ?>
</div>
<div class="col-3 flex flex-column center pdd_20px br-r">
<?php echo $Configurations->getTotalPolicies(); ?>
</div>
<div class="col-3 flex flex-column center pdd_20px">
<?php echo $Configurations->getTotalRemotePlugins(); ?>
</div>
</div>
<div class="row flex-nowrap">
<div class="col-4 flex flex-column center pdd_20px br-r">
<?php echo $Configurations->getTotalModuleTemplate(); ?>
</div>
<div class="col-4 flex flex-column center pdd_20px br-r">
<?php echo $Configurations->getNotInitModules(); ?>
</div>
<div class="col-4 flex flex-column center pdd_20px">
<?php echo $Configurations->getTotalUnknowAgents(); ?>
</div>
</div>
</div>
<div class="container">
<div class="title br-b">
<?php echo $ScheduledDowntime->title; ?>
</div>
<?php echo $ScheduledDowntime->list(); ?>
</div>
</div>
</div>