Merge remote-tracking branch 'origin/develop' into ent-11471-integracion-pandora-integria

This commit is contained in:
daniel 2023-07-18 15:13:29 +02:00
commit 5707ec9e4b
33 changed files with 615 additions and 48 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.772-230717
Version: 7.0NG.772-230718
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.772-230717"
pandora_version="7.0NG.772-230718"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1031,7 +1031,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.772';
use constant AGENT_BUILD => '230717';
use constant AGENT_BUILD => '230718';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.772
%define release 230717
%define release 230718
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.772
%define release 230717
%define release 230718
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.772"
PI_BUILD="230717"
PI_BUILD="230718"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{230717}
{230718}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.772 Build 230717")
#define PANDORA_VERSION ("7.0NG.772 Build 230718")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.772(Build 230717))"
VALUE "ProductVersion", "(7.0NG.772(Build 230718))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.772-230717
Version: 7.0NG.772-230718
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.772-230717"
pandora_version="7.0NG.772-230718"
package_pear=0
package_pandora=1

View File

@ -212,7 +212,7 @@ if (isset($_GET['server']) === true) {
false,
'servers',
true,
[],
$buttons,
[
[
'link' => '',

View File

@ -255,17 +255,7 @@ foreach ($servers as $server) {
if (($names_servers[$safe_server_name] === true) && ($server['type'] === 'data' || $server['type'] === 'enterprise satellite')) {
$data[8] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext.'&tab=agent_editor').'">';
$data[8] .= html_print_image(
'images/agents@svg.svg',
true,
[
'title' => __('Manage server conf'),
'class' => 'main_menu_icon invert_filter',
]
);
$data[8] .= '</a>';
$data[8] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext).'">';
$data[8] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext).'&tab=standard_editor">';
$data[8] .= html_print_image(
'images/remote-configuration@svg.svg',
true,

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -98,6 +98,8 @@ if (check_login()) {
}
$id_plugin = get_parameter('id_plugin', 0);
if ($id_plugin !== 0) {
$id_module_plugin = db_get_value(
'id_plugin',
'tagente_modulo',
@ -108,6 +110,7 @@ if (check_login()) {
$get_plugin_macros = true;
$get_module_macros = 0;
}
}
if ($get_plugin_macros) {
if (https_is_running()) {

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC230717';
$build_version = 'PC230718';
$pandora_version = 'v7.0NG.772';
// Do not overwrite default timezone set if defined.

View File

@ -424,6 +424,7 @@ class Widget
case 'ModulesByStatus':
case 'AvgSumMaxMinModule':
case 'BasicChart':
case 'AgentHive':
$className .= '\\'.$name;
break;

View File

@ -0,0 +1,519 @@
<?php
/**
* Widget agent hive Pandora FMS Console
*
* @category Console Class
* @package Pandora FMS
* @subpackage Widget
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
namespace PandoraFMS\Dashboard;
use PandoraFMS\Enterprise\Metaconsole\Node;
global $config;
/**
* URL Widgets
*/
class AgentHive extends Widget
{
/**
* Name widget.
*
* @var string
*/
protected $name;
/**
* Title widget.
*
* @var string
*/
protected $title;
/**
* Page widget;
*
* @var string
*/
protected $page;
/**
* Class name widget.
*
* @var [type]
*/
protected $className;
/**
* Values options for each widget.
*
* @var [type]
*/
protected $values;
/**
* Configuration required.
*
* @var boolean
*/
protected $configurationRequired;
/**
* Error load widget.
*
* @var boolean
*/
protected $loadError;
/**
* Width.
*
* @var integer
*/
protected $width;
/**
* Heigth.
*
* @var integer
*/
protected $height;
/**
* Grid Width.
*
* @var integer
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
*
* @param integer $cellId Cell ID.
* @param integer $dashboardId Dashboard ID.
* @param integer $widgetId Widget ID.
* @param integer|null $width New width.
* @param integer|null $height New height.
* @param integer|null $gridWidth Grid width.
*/
public function __construct(
int $cellId,
int $dashboardId=0,
int $widgetId=0,
?int $width=0,
?int $height=0,
?int $gridWidth=0
) {
global $config;
// WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct(
$cellId,
$dashboardId,
$widgetId
);
// Width.
$this->width = $width;
// Height.
$this->height = $height;
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->decoders($this->getOptionsWidget());
// Page.
$this->page = basename(__FILE__);
// ClassName.
$class = new \ReflectionClass($this);
$this->className = $class->getShortName();
// Title.
$this->title = __('Agent hive');
// Name.
if (empty($this->name) === true) {
$this->name = 'AgentHive';
}
// This forces at least a first configuration.
$this->configurationRequired = false;
if (empty($this->values['groups']) === true) {
$this->configurationRequired = true;
}
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['groups']) === true) {
$values['groups'] = $decoder['groups'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
* @return array Of inputs.
*
* @throws Exception On error.
*/
public function getFormInputs(): array
{
$values = $this->values;
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Filters.
$inputs[] = [
'label' => __('Groups'),
'id' => 'li_groups',
'arguments' => [
'type' => 'select_groups',
'name' => 'groups[]',
'returnAllGroup' => false,
'privilege' => 'AR',
'selected' => explode(',', $values['groups'][0]),
'return' => true,
'multiple' => true,
'required' => true,
],
];
return $inputs;
}
/**
* Get Post for widget.
*
* @return array
*/
public function getPost(): array
{
// Retrieve global - common inputs.
$values = parent::getPost();
$values['groups'] = \get_parameter('groups', 0);
return $values;
}
/**
* Draw widget.
*
* @return string;
*/
public function load()
{
global $config;
$groups = $this->values['groups'];
$groups = explode(',', $groups[0]);
$user_groups = array_keys(
users_get_groups(
false,
'AR',
false,
false,
$groups
)
);
foreach ($groups as $key => $group) {
if (in_array($group, $user_groups) === false) {
unset($groups[$key]);
}
}
$table = 'tagente';
if (is_metaconsole()) {
$table = 'tmetaconsole_agent';
}
$sql = sprintf(
'SELECT * FROM %s WHERE id_grupo IN('.implode(',', $groups).')',
$table
);
$all_agents = db_get_all_rows_sql($sql);
$output = '';
$output .= '<div class="container-tabs">';
foreach ($all_agents as $agent) {
$output .= $this->drawSquare($agent);
}
$output .= '</div>';
$output .= '<script type="text/javascript">
$(document).ready (function () {
$(".widget-agent-hive-square").click(function(e) {
if (typeof e.target.id === "string" && /img_.*/i.test(e.target.id) === false) {
var url = $(this).children("input").first().val();
window.open(url);
}
});
$("div [id*=hiveImg_] svg path").css("fill", "#99A3BE");
});
</script>';
return $output;
}
/**
* Draw square agent.
*
* @param array $data Info agent.
*
* @return string Output.
*/
private function drawSquare(array $data): string
{
global $config;
$id = (is_metaconsole() === true)
? $data['id_tagente']
: $data['id_agente'];
$status = agents_get_status_from_counts($data);
switch ($status) {
case 1:
case 4:
case 100:
// Critical (BAD or ALERT).
$color = '#e63c52';
break;
case 0:
case 300:
// Normal (OK).
$color = '#82b92e';
break;
case 2:
case 200:
// Warning.
$color = '#f3b200';
break;
case 5:
// Not init.
$color = '#4a83f3';
break;
default:
// Default is Grey (Other).
$color = '#b2b2b2';
break;
}
$style_contact = 'flex-grow: 9; font-size: 8pt; display: flex;
justify-content: start;align-items: start; color: #9FA5B1; font-weight: 600;';
// Last contact.
$lastContactDate = ui_print_timestamp(
$data['ultimo_contacto'],
true,
['style' => $style_contact]
);
// Url.
$console_url = ui_get_full_url('/');
if (is_metaconsole()) {
$server = metaconsole_get_servers($data['id_tmetaconsole_setup']);
$console_url = $server['server_url'].'/';
}
$url_view = $console_url.'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id;
$url_manage = $console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id;
$output = '<div class="widget-agent-hive-square">';
$output .= '<input type="hidden" name="test" value="'.$url_view.'" />';
$output .= '<div class="widget-agent-hive-square-status"
style="background-color:'.$color.'"></div>';
$output .= '<div class="widget-agent-hive-square-info">';
// Last contact and img.
$output .= '<div class="widget-agent-hive-square-info-header">';
$output .= $lastContactDate;
$output .= '<a href="'.$url_manage.'" target="_blank">'.html_print_image(
'images/configuration@svg.svg',
true,
[
'title' => __('Operation view'),
'class' => 'main_menu_icon invert_filter',
'style' => 'flex-grow: 1',
'id' => 'img_'.$id,
]
).'</a>';
$output .= '</div>';
// OS and alias.
$output .= '<div class="widget-agent-hive-square-info-body">';
$icon = (string) db_get_value(
'icon_name',
'tconfig_os',
'id_os',
(int) $data['id_os']
);
$output .= '<div id="hiveImg_'.$id.'"
style="width:20px;height:20px;margin-right: 5px;">';
$output .= file_get_contents(
ui_get_full_url('images/'.$icon, false, false, false)
);
$output .= '</div>';
$output .= ui_print_truncate_text(
ucfirst(io_safe_output($data['alias'])),
12,
false,
true,
true,
'&hellip;',
'font-size: 11pt;color: #14524f;white-space: nowrap;
font-weight: 600;text-align: left;width: 80%;
overflow: hidden;',
);
$output .= '</div>';
// OS description.
$output .= html_print_div(
[
'content' => (empty($data['os_version']) === true)
? get_os_name((int) $data['id_os'])
: $data['os_version'],
'style' => 'font-size: 6pt; display:
flex;justify-content: start;align-items: start;
color: #9FA5B1; font-weight: 600;margin-bottom: 5px',
],
true
);
// Description.
$output .= html_print_div(
[
'content' => ui_print_truncate_text(
io_safe_output($data['comentarios']),
38,
false,
true,
true,
'&hellip;',
),
'style' => 'text-align: left;min-height: 42px;
font-size: 8pt;max-height: 42px; margin-bottom: 10px',
],
true
);
// IP.
$output .= html_print_div(
[
'content' => $data['direccion'],
'style' => 'font-size: 10pt;color: #14524f;
font-weight: 600; text-align: left',
],
true
);
$output .= '</div>';
$output .= '</div>';
return $output;
}
/**
* Get description.
*
* @return string.
*/
public static function getDescription()
{
return __('Agents hive');
}
/**
* Get Name.
*
* @return string.
*/
public static function getName()
{
return 'AgentHive';
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => (is_metaconsole() === true) ? 700 : 600,
'height' => 610,
];
return $size;
}
}

View File

@ -654,6 +654,59 @@ form.modal-dashboard
font-style: italic;
}
.widget-agent-hive-square {
flex: 1;
display: flex;
flex-direction: row;
justify-content: center;
align-items: start;
min-width: 150px;
max-width: 150px;
min-height: 150px;
max-height: 150px;
margin: 8px;
padding: 5px;
border: 1px solid #eceef2;
border-radius: 5px;
cursor: pointer;
}
.widget-agent-hive-square-status {
width: 3%;
height: 100%;
margin-left: 3%;
border-radius: 15px;
}
.widget-agent-hive-square-info {
width: 87%;
height: 100%;
display: flex;
flex-direction: column;
margin-left: 6%;
}
.widget-agent-hive-square-info-header {
width: 100%;
display: flex;
flex-direction: row;
margin-bottom: 10px;
}
.widget-agent-hive-square-info-body {
width: 100%;
display: flex;
flex-direction: row;
}
.span-alias {
font-size: 13pt;
justify-content: start;
align-items: start;
color: #14524f;
font-weight: 600;
}
.container-histograms {
min-width: 400px;
}

View File

@ -131,7 +131,7 @@
<div style='padding-bottom: 50px'>
<?php
$version = '7.0NG.772';
$build = '230717';
$build = '230718';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.772
%define release 230717
%define release 230718
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.772
%define release 230717
%define release 230718
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.772
%define release 230717
%define release 230718
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.772-230717
Version: 7.0NG.772-230718
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.772-230717"
pandora_version="7.0NG.772-230718"
package_cpan=0
package_pandora=1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.772";
my $pandora_build = "230717";
my $pandora_build = "230718";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -4864,9 +4864,10 @@ sub on_demand_macro($$$$$$;$) {
return '';
} elsif ($macro eq '_moduletags_') {
return (defined ($module)) ? pandora_get_module_url_tags ($pa_config, $dbh, $module->{'id_agente_modulo'}) : '';
return (defined ($module)) ? pandora_get_module_tags ($pa_config, $dbh, $module->{'id_agente_modulo'}) : '';
} elsif ($macro eq '_policy_') {
return (defined ($alert)) ? enterprise_hook('get_policy_name_policy_alerts_id', [$dbh, $alert->{'id_policy_alerts'}]) : '';
my $policy_name = get_db_value($dbh, 'SELECT p.name FROM tpolicy_modules AS pm, tpolicies AS p WHERE pm.id_policy = p.id AND pm.id = ?;', $module->{'id_policy_module'});
return (defined ($policy_name)) ? $policy_name : '';
} elsif ($macro eq '_email_tag_') {
return (defined ($module)) ? pandora_get_module_email_tags ($pa_config, $dbh, $module->{'id_agente_modulo'}) : '';
} elsif ($macro eq '_phone_tag_') {

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.772";
my $pandora_build = "230717";
my $pandora_build = "230718";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.772
%define release 230717
%define release 230718
Summary: Pandora FMS Server
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.772
%define release 230717
%define release 230718
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.772"
PI_BUILD="230717"
PI_BUILD="230718"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.772 Build 230717";
my $version = "7.0NG.772 Build 230718";
# Pandora server configuration
my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.772 Build 230717";
my $version = "7.0NG.772 Build 230718";
# save program name for logging
my $progname = basename($0);