Merge branch 'develop' into 'ent-10563-mejoras-personalizacion-interfaz'

# Conflicts:
#   pandora_console/godmode/agentes/module_manager.php
This commit is contained in:
Miguel Angel Rasteu 2023-07-03 07:45:32 +00:00
commit 82f6c6c0da
52 changed files with 668 additions and 165 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.772-230630
Version: 7.0NG.772-230703
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-230630"
pandora_version="7.0NG.772-230703"
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 => '230630';
use constant AGENT_BUILD => '230703';
# 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 230630
%define release 230703
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 230630
%define release 230703
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

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

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{230630}
{230703}
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 230630")
#define PANDORA_VERSION ("7.0NG.772 Build 230703")
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 230630))"
VALUE "ProductVersion", "(7.0NG.772(Build 230703))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.772-230630
Version: 7.0NG.772-230703
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-230630"
pandora_version="7.0NG.772-230703"
package_pear=0
package_pandora=1

View File

@ -929,7 +929,7 @@ if ($agents !== false) {
[
'href' => ui_get_full_url(
sprintf(
'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&%s_agent=%s&group_id=%s&recursion=%s&search=%s&offset=%s&sort_field=%s&sort=%s&disabled=%s',
'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&%s_agent=%s&group_id=%s&recursion=%s&search=%s&offset=%s&sort_field=%s&sort=%s&disabled=%s&os=%s',
$agentDisableEnableAction,
$agent['id_agente'],
$ag_group,
@ -938,7 +938,8 @@ if ($agents !== false) {
'',
$sortField,
$sort,
$disabled
$disabled,
$os
)
),
'onClick' => ($agent['id_os'] === CLUSTER_OS_ID) ? sprintf('if (!confirm(\'%s\')) return false', $agentDisableEnableCaption) : 'return true;',

View File

@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_categories.php';
require_once $config['homedir'].'/include/graphs/functions_d3.php';
use PandoraFMS\Agent;
use Psr\Log\NullLogger;
include_javascript_d3();
@ -950,6 +951,15 @@ $table_advanced->data['tags_module_parent'][0] .= html_print_div(
if ((bool) $in_policies_page === false) {
// Cannot select the current module to be itself parent.
if ($id_agent_module !== 0) {
$module_parent_filter['tagente_modulo.id_agente_modulo'] = '<>'.$id_agent_module;
$array_parent_module_id = [];
get_agent_module_childs($array_parent_module_id, $id_agent_module, $id_agente);
} else {
$module_parent_filter = [];
$array_parent_module_id = [];
}
$module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => '<>'.$id_agent_module] : [];
$table_advanced->data['caption_tags_module_parent'][1] = __('Module parent');
// TODO. Review cause dont know not works.
@ -965,6 +975,13 @@ if ((bool) $in_policies_page === false) {
false,
$module_parent_filter
);
if (empty($array_parent_module_id) === false) {
foreach ($array_parent_module_id as $key => $value) {
unset($modules_can_be_parent[$value]);
}
}
// If the user cannot have access to parent module, only print the name.
if ((int) $parent_module_id !== 0
&& in_array($parent_module_id, array_keys($modules_can_be_parent)) === true

View File

@ -240,7 +240,7 @@ $snmp_versions['3'] = 'v. 3';
$snmpVersionsInput = html_print_select(
$snmp_versions,
'snmp_version',
($id_module_type >= 15 && $id_module_type <= 18) ? $snmp_version : 0,
($id_module_type >= 15 && $id_module_type <= 18) ? $snmp_version : '2c',
'',
'',
'',

View File

@ -107,6 +107,8 @@ if (is_ajax() === true) {
// Ids of agents to be include in the SQL clause as id_agent IN ().
$filter_agents_json = (string) get_parameter('filter_agents_json', '');
$status_agents = (int) get_parameter('status_agents', AGENT_STATUS_ALL);
$os_agent = (int) get_parameter('os_agent', 0);
$os_agent_version = (string) get_parameter('os_agent_version', '');
// Juanma (22/05/2014) Fix: If setted remove void agents from result
// (by default and for compatibility show void agents).
$show_void_agents = (int) get_parameter('show_void_agents', 1);
@ -152,6 +154,14 @@ if (is_ajax() === true) {
$filter['status'] = $status_agents;
}
if ($os_agent !== 0) {
$filter['id_os'] = $os_agent;
}
if ($os_agent_version !== '') {
$filter['os_version'] = $os_agent_version;
}
if ($id_os !== 0) {
$filter['id_os'] = $id_os;
}

View File

@ -592,13 +592,13 @@ if ((bool) $id !== false || $new_component
$search_id_group = (int) get_parameter('search_id_group');
$group_recursive = (bool) get_parameter_switch('group_recursive', false);
$search_string = (string) get_parameter('search_string');
$offset = (int) get_parameter('offset');
$url = ui_get_url_refresh(
[
'offset' => $offset,
'search_string' => $search_string,
'search_string' => urlencode(io_safe_output($search_string)),
'search_id_group' => $search_id_group,
'id' => $id,
],
@ -662,7 +662,15 @@ $table->data[0][] = html_print_label_input_block(
'width: 100%'
)
);
$table->data[0][] = html_print_label_input_block(
__('Recursive'),
html_print_checkbox_switch(
'group_recursive',
1,
$group_recursive,
true
)
);
$table->data[0][] = html_print_label_input_block(
__('Free Search'),
html_print_input_text(
@ -678,7 +686,8 @@ $table->data[0][] = html_print_label_input_block(
)
);
$toggleFilters = '<form class="filters_form" method="POST" action="'.$url.'">';
$filter_action_url = 'index.php?sec='.$sec.'&sec2=godmode/modules/manage_network_components&id='.$component['id_nc'].'&search_string='.urlencode(io_safe_output($search_string)).'&search_id_group'.$search_id_group.'&pure='.$pure;
$toggleFilters = '<form class="filters_form" method="POST" action="'.$filter_action_url.'">';
$toggleFilters .= html_print_table($table, true);
$toggleFilters .= html_print_div(
[
@ -712,7 +721,11 @@ ui_toggle(
$filter = [];
if ($search_id_group) {
$filter['id_group'] = $search_id_group;
if ($group_recursive === true) {
$filter['id_group'] = network_component_get_groups_recursive($search_id_group);
} else {
$filter['id_group'] = $search_id_group;
}
}
if ($search_string != '') {
@ -725,7 +738,7 @@ $total_components = network_components_get_network_components(
'COUNT(*) AS total'
);
$total_components = $total_components[0]['total'];
$offset_delete = ($offset >= ($total_components - 1)) ? ($offset - $config['block_size']) : $offset;
$offset_delete = ($offset > 0 && $offset >= ($total_components - 1)) ? ($offset - $config['block_size']) : $offset;
$filter['offset'] = (int) get_parameter('offset');
$filter['limit'] = (int) $config['block_size'];
$components = network_components_get_network_components(

View File

@ -1954,7 +1954,7 @@ $class = 'databox filters';
$modulegroup,
$id_agents,
!$selection_a_m,
true
false
);
}

View File

@ -1252,7 +1252,10 @@ if (check_login()) {
'content' => html_print_image(
'images/event-history.svg',
true,
[ 'class' => 'main_menu_icon' ]
[
'title' => __('Event history'),
'class' => 'main_menu_icon forced_title',
]
),
],
true
@ -1267,7 +1270,10 @@ if (check_login()) {
'content' => html_print_image(
'images/module-graph.svg',
true,
[ 'class' => 'main_menu_icon' ]
[
'title' => __('Module graph'),
'class' => 'main_menu_icon forced_title',
]
),
],
true
@ -1284,7 +1290,10 @@ if (check_login()) {
'content' => html_print_image(
'images/simple-value.svg',
true,
[ 'class' => 'main_menu_icon' ]
[
'title' => __('Module detail'),
'class' => 'main_menu_icon forced_title',
]
),
],
true
@ -1320,7 +1329,10 @@ if (check_login()) {
'content' => html_print_image(
$imgaction,
true,
[ 'class' => 'main_menu_icon' ]
[
'title' => __('Force remote check'),
'class' => 'main_menu_icon forced_title',
]
),
],
true
@ -1337,7 +1349,10 @@ if (check_login()) {
'content' => html_print_image(
'images/edit.svg',
true,
[ 'class' => 'main_menu_icon' ]
[
'title' => __('Edit configuration'),
'class' => 'main_menu_icon forced_title',
]
),
],
true

View File

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

View File

@ -2843,7 +2843,7 @@ function config_process_config()
}
if (!isset($config['email_from_dir'])) {
config_update_value('email_from_dir', 'pandora@pandorafms.com/community/');
config_update_value('email_from_dir', 'pandora@pandorafms.com');
}
if (!isset($config['email_from_name'])) {

View File

@ -4353,7 +4353,7 @@ function events_page_details($event, $server_id=0)
} else if (can_user_access_node() && is_metaconsole()) {
// Workaround to pass login hash data in POST body instead of directly in the URL.
parse_str($hashstring, $url_hash_array);
$redirection_form = "<form id='agent-redirection' method='POST' action='".$serverstring."index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event['id_agente']."'>";
$redirection_form = "<form id='agent-redirection' method='POST' action='".$serverstring.'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$event['id_agente']."'>";
$redirection_form .= html_print_input_hidden(
'loginhash',
$url_hash_array['loginhash'],

View File

@ -214,10 +214,33 @@ function get_table_inputs_masive_agents($params)
);
}
$table->data[3][0] = __('Agents');
$table->data[3][0] .= '<span id="agent_loading" class="invisible">';
$table->data[3][0] .= html_print_image('images/spinner.png', true);
$table->data[3][0] .= '</span>';
$os_list = os_get_os(true);
$table->data[3][0] = __('OS');
$table->data[3][1] = html_print_select(
$os_list,
'os_agent',
'selected',
'',
__('All'),
'',
true
);
$table->data[3][2] = __('OS Version');
$table->data[3][3] = html_print_input_text(
'os_agent_version',
'',
__('Select OS version'),
35,
255,
true
);
$table->data[4][0] = __('Agents');
$table->data[4][0] .= '<span id="agent_loading" class="invisible">';
$table->data[4][0] .= html_print_image('images/spinner.png', true);
$table->data[4][0] .= '</span>';
$agents = [];
if (is_metaconsole() === false) {
@ -228,7 +251,7 @@ function get_table_inputs_masive_agents($params)
);
}
$table->data[3][1] = html_print_select(
$table->data[4][1] = html_print_select(
$agents,
'id_agents[]',
0,

View File

@ -3676,6 +3676,10 @@ function get_modules_agents(
implode(',', $id_agents)
)
);
if ($rows === false) {
$rows = [];
}
} else {
$rows = [];
}
@ -4655,3 +4659,26 @@ function policies_type_modules_availables(string $sec2): array
return $modules;
}
function get_agent_module_childs(
&$array_parent_module_id=[],
$id_agent_module=false,
$id_agente=false
) {
if ($array_parent_module_id !== false && $id_agent_module !== false && $id_agente !== false) {
$parent['parent_module_id'] = $id_agent_module;
$module_childs_id = agents_get_modules(
$id_agente,
'parent_module_id',
$parent
);
foreach ($module_childs_id as $key => $value) {
if ($value !== 0) {
$array_parent_module_id[] = $key;
get_agent_module_childs($array_parent_module_id, $key, $id_agente);
}
}
}
}

View File

@ -594,3 +594,26 @@ function network_components_duplicate_network_component($id_local_component)
return network_components_create_network_component($name, $network['type'], $network['id_group'], $network);
}
/**
* Return all children groups recursive include parent.
*
* @param integer $id_parent Id of parent.
* @param array $groups NO setting, array for recursive.
*
* @return array $groups All children ids include first parent.
*/
function network_component_get_groups_recursive($id_parent, $groups=[])
{
$groups[] = $id_parent;
$ids = db_get_all_rows_filter('tnetwork_component_group', ['parent' => $id_parent], 'id_sg');
if ($ids !== false) {
foreach ($ids as $key => $id) {
$groups = network_component_get_groups_recursive($id['id_sg'], $groups);
}
}
return $groups;
}

View File

@ -7735,7 +7735,7 @@ function reporting_sql_auxiliary($report, $content, $pdf=false)
}
$result = db_get_all_rows_sql($sql, $historical_db);
if ($result !== false) {
foreach ($result as $row) {
$data_row = [];
@ -12346,29 +12346,29 @@ function reporting_get_stats_modules_status($data, $graph_width=250, $graph_heig
$tdata = [];
$tdata[0] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_CRITICAL, 'title' => __('Monitor critical')], true);
$tdata[1] = $data['monitor_critical'] <= 0 ? '-' : $data['monitor_critical'];
$tdata[1] = '<a style="color: '.COL_CRITICAL.';" class="big_data line_heigth_initial" href="'.$urls['monitor_critical'].'">'.$tdata[1].'</a>';
$tdata[1] = '<a style="color: '.COL_CRITICAL.' !important;" class="big_data line_heigth_initial" href="'.$urls['monitor_critical'].'">'.$tdata[1].'</a>';
$tdata[2] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_WARNING_DARK, 'title' => __('Monitor warning')], true);
$tdata[3] = $data['monitor_warning'] <= 0 ? '-' : $data['monitor_warning'];
$tdata[3] = '<a style="color: '.COL_WARNING_DARK.';" class="big_data line_heigth_initial" href="'.$urls['monitor_warning'].'">'.$tdata[3].'</a>';
$tdata[3] = '<a style="color: '.COL_WARNING_DARK.' !important;" class="big_data line_heigth_initial" href="'.$urls['monitor_warning'].'">'.$tdata[3].'</a>';
$table_mbs->rowclass[] = '';
$table_mbs->data[] = $tdata;
$tdata = [];
$tdata[0] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_NORMAL, 'title' => __('Monitor normal')], true);
$tdata[1] = $data['monitor_ok'] <= 0 ? '-' : $data['monitor_ok'];
$tdata[1] = '<a style="color: '.COL_NORMAL.';" class="big_data" href="'.$urls['monitor_ok'].'">'.$tdata[1].'</a>';
$tdata[1] = '<a style="color: '.COL_NORMAL.' !important;" class="big_data" href="'.$urls['monitor_ok'].'">'.$tdata[1].'</a>';
$tdata[2] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_UNKNOWN, 'title' => __('Monitor unknown')], true);
$tdata[3] = $data['monitor_unknown'] <= 0 ? '-' : $data['monitor_unknown'];
$tdata[3] = '<a style="color: '.COL_UNKNOWN.';" class="big_data line_heigth_initial" href="'.$urls['monitor_unknown'].'">'.$tdata[3].'</a>';
$tdata[3] = '<a style="color: '.COL_UNKNOWN.' !important;" class="big_data line_heigth_initial" href="'.$urls['monitor_unknown'].'">'.$tdata[3].'</a>';
$table_mbs->rowclass[] = '';
$table_mbs->data[] = $tdata;
$tdata = [];
$tdata[0] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_NOTINIT, 'title' => __('Monitor not init')], true);
$tdata[1] = $data['monitor_not_init'] <= 0 ? '-' : $data['monitor_not_init'];
$tdata[1] = '<a style="color: '.COL_NOTINIT.';" class="big_data line_heigth_initial" href="'.$urls['monitor_not_init'].'">'.$tdata[1].'</a>';
$tdata[1] = '<a style="color: '.COL_NOTINIT.' !important;" class="big_data line_heigth_initial" href="'.$urls['monitor_not_init'].'">'.$tdata[1].'</a>';
$tdata[2] = $tdata[3] = '';
$table_mbs->rowclass[] = '';
@ -14861,7 +14861,13 @@ function reporting_get_stats_servers($filter=[])
'class' => 'main_menu_icon invert_filter',
]
);
$tdata[1] = '<span class="big_data" id="total_events">'.html_print_image('images/spinner.gif', true).'</span>';
$sql_count_event = 'SELECT SQL_NO_CACHE COUNT(id_evento) FROM tevento ';
if ($config['event_view_hr']) {
$sql_count_event .= 'WHERE utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')';
}
$system_events = db_get_value_sql($sql_count_event);
$tdata[1] = '<span class="big_data" id="total_events">'.$system_events.'</span>';
if (isset($system_events) && $system_events > 50000 && !enterprise_installed()) {
$tdata[2] = "<div id='monitoreventsmodal' class='publienterprise left' title='Community version'><img data-title='".__('Enterprise version not installed')."' class='img_help forced_title main_menu_icon' data-use_title_for_force_title='1' src='images/alert-yellow@svg.svg'></div>";

View File

@ -1446,13 +1446,22 @@ function ui_format_alert_row(
$actionText .= '</ul></div>';
if ($actionDefault != '') {
$actionText .= db_get_sql(
if ($actionDefault !== '') {
$actionDefault_name = db_get_sql(
sprintf(
'SELECT name FROM talert_actions WHERE id = %d',
$actionDefault
)
).' <i>('.__('Default').')</i>';
);
foreach ($actions as $action) {
if ($actionDefault_name === $action['name']) {
$hide_actionDefault = true;
}
}
if ($hide_actionDefault !== true) {
$actionText .= $actionDefault_name.' <i>('.__('Default').')</i>';
}
}
}

View File

@ -22,7 +22,9 @@
privilege: "",
serialized: false,
serialized_separator: "",
nodes: []
nodes: [],
id_os: -1,
os_agent_version: ""
};
/* public methods */
@ -53,7 +55,7 @@
} else {
recursion_value = config.recursion;
}
var opts = {
page: "godmode/groups/group_list",
get_group_agents: 1,
@ -74,7 +76,9 @@
nodes:
typeof config.nodes === "function"
? config.nodes()
: config.disabled
: config.disabled,
os_agent: config.os_agent,
os_agent_version: config.os_agent_version
};
jQuery.post(
@ -319,7 +323,6 @@
let href = $("a", config.spanPreview).attr("href");
let hrefPosition = href.search("group_id=");
let hrefNew = href.slice(0, hrefPosition) + "group_id=" + id_group;
jQuery.post(
"ajax.php",
{

View File

@ -110,6 +110,18 @@ function form_controls_massive_operations_agents(metaconsole) {
$("#id_group").trigger("change");
});
var os_agent;
$("#os_agent").change(function() {
os_agent = this.value;
$("#id_group").trigger("change");
});
var os_agent_version;
$("#text-os_agent_version").keyup(function() {
os_agent_version = this.value;
$("#id_group").trigger("change");
});
if (metaconsole == 1) {
$("#nodes").change(function() {
disabled = $("#disabled").val();
@ -142,6 +154,13 @@ function form_controls_massive_operations_agents(metaconsole) {
},
disabled: function() {
return disabled;
},
os_agent: function() {
return os_agent;
},
os_agent_version: function() {
console.log(os_agent_version);
return os_agent_version;
}
};

View File

@ -496,7 +496,7 @@ function configure_modules_form() {
data["unit"] == "" ? "" : data["unit"]
);
$("#checkbox-critical_inverse").prop(
$("#checkbox-critical_inverse_string").prop(
"checked",
data["critical_inverse"]
);

View File

@ -292,6 +292,10 @@ class AgentModuleWidget extends Widget
}
}
if (is_metaconsole() === true) {
$this->values['mAgents'] = $this->getIdCacheAgent($this->values['mAgents']);
}
$inputs[] = [
'class' => 'flex flex-row',
'id' => 'select_multiple_modules_filtered',
@ -315,6 +319,65 @@ class AgentModuleWidget extends Widget
}
/**
* Return array with the real id agent and server.
*
* @param string $id_agents_cache String with the agents cache id.
*
* @return string $agents_servers with the real id agent and server.
*/
public function getRealIdAgentNode($id_agents_cache)
{
$agents_servers = [];
$target_agents = explode(',', $id_agents_cache);
foreach ($target_agents as $agent_id) {
$id_agente = $agent_id;
$tmeta_agent = db_get_row_filter(
'tmetaconsole_agent',
['id_agente' => $id_agente]
);
$id_agente = $tmeta_agent['id_tagente'];
$tserver = $tmeta_agent['id_tmetaconsole_setup'];
$agents_servers[] = $tserver.'|'.$id_agente;
}
return implode(',', $agents_servers);
}
/**
* Return string with the cache id agent in metaconsole.
*
* @param string $id_agents String with the agents and server id.
*
* @return string $cache_id_agents with the cache id agent.
*/
public function getIdCacheAgent($id_agents)
{
$target_agents = explode(',', $id_agents);
$cache_id_agents = [];
foreach ($target_agents as $agent_id) {
if (str_contains($agent_id, '|') === false) {
$cache_id_agents[] = $agent_id;
continue;
}
$server_agent = explode('|', $agent_id);
$tmeta_agent = db_get_row_filter(
'tmetaconsole_agent',
[
'id_tagente' => $server_agent[1],
'id_tmetaconsole_setup' => $server_agent[0],
]
);
$cache_id_agents[] = $tmeta_agent['id_agente'];
}
return implode(',', $cache_id_agents);
}
/**
* Get Post for widget.
*
@ -341,6 +404,10 @@ class AgentModuleWidget extends Widget
$values['mAgents'] = \get_parameter(
'filtered-module-agents-'.$this->cellId
);
if (is_metaconsole() === true) {
$values['mAgents'] = $this->getRealIdAgentNode($values['mAgents']);
}
$values['mShowCommonModules'] = \get_parameter(
'filtered-module-show-common-modules-'.$this->cellId
);
@ -697,15 +764,24 @@ class AgentModuleWidget extends Widget
$target_agents = explode(',', $this->values['mAgents']);
foreach ($target_agents as $agent_id) {
try {
$id_agente = $agent_id;
if ((bool) is_metaconsole() === true) {
$tmeta_agent = db_get_row_filter(
'tmetaconsole_agent',
[ 'id_agente' => $id_agente ]
);
if (is_metaconsole() === true && str_contains($agent_id, '|') === true) {
$server_agent = explode('|', $agent_id);
} else {
$id_agente = $agent_id;
}
$id_agente = $tmeta_agent['id_tagente'];
$tserver = $tmeta_agent['id_tmetaconsole_setup'];
if ((bool) is_metaconsole() === true) {
if (isset($server_agent) === true) {
$id_agente = $server_agent[1];
$tserver = $server_agent[0];
} else {
$tmeta_agent = db_get_row_filter(
'tmetaconsole_agent',
[ 'id_agente' => $id_agente ]
);
$id_agente = $tmeta_agent['id_tagente'];
$tserver = $tmeta_agent['id_tmetaconsole_setup'];
}
if (metaconsole_connect(null, $tserver) !== NOERR) {
continue;

View File

@ -201,6 +201,25 @@ class TopNWidget extends Widget
$values['period'] = SECONDS_1DAY;
}
// Type graph.
$fields = [
'bar_vertical' => __('Vertical bars'),
'bar_horizontal' => __('Horizontal bars'),
'pie' => __('Pie'),
];
$inputs[] = [
'label' => __('Type of graph'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'type_graph',
'selected' => $values['type_graph'],
'return' => true,
'sort' => false,
],
];
// Agent.
$inputs[] = [
'label' => __('Agent').ui_print_help_tip(
@ -294,6 +313,25 @@ class TopNWidget extends Widget
],
];
// Legend.
$fields = [
'agent_module' => __('Agent & module'),
'agent' => __('Agent'),
'module' => __('Module'),
];
$inputs[] = [
'label' => __('Legend'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'legend',
'selected' => $values['legend'],
'return' => true,
'sort' => false,
],
];
return $inputs;
}
@ -314,6 +352,8 @@ class TopNWidget extends Widget
$values['quantity'] = \get_parameter('quantity', 5);
$values['order'] = \get_parameter('order', 1);
$values['display'] = \get_parameter('display', REPORT_TOP_N_AVG);
$values['type_graph'] = \get_parameter('type_graph', 'bar_horizontal');
$values['legend'] = \get_parameter('legend', 'agent_module');
return $values;
}
@ -476,13 +516,28 @@ class TopNWidget extends Widget
foreach ($modules as $module) {
$module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20, false, true, false);
$item_name = $module['aliasAgent'].' - '.$module['nameModule'];
switch ($this->values['legend']) {
case 'agent_module':
$item_name = $module['aliasAgent'].' - '.$module['nameModule'];
break;
case 'agent':
$item_name = $module['aliasAgent'];
break;
case 'module':
$item_name = $module['nameModule'];
break;
default:
$item_name = $module['aliasAgent'].' - '.$module['nameModule'];
break;
}
$labels[] = io_safe_output($item_name);
$data_hbar[] = [
'x' => $module[$display],
'y' => io_safe_output($item_name),
];
$data[] = $module[$display];
// Calculation of max-min values for show in graph.
$calc = (ceil((5 * (float) $module[$display]) / 100) + $module[$display]);
// Set of max-min values for graph.
@ -502,27 +557,65 @@ class TopNWidget extends Widget
$valueMax += 10;
}
$height = (count($data_hbar) * 25 + 35);
$height = (count($data) * 25 + 35);
$output .= '<div class="container-center">';
$options = [
'height' => $height,
'axis' => 'y',
'legend' => ['display' => false],
'scales' => [
'labels' => $labels,
];
if ($this->values['type_graph'] !== 'pie') {
$options['scales'] = [
'x' => [
'grid' => ['display' => false],
],
'y' => [
'grid' => ['display' => false],
],
],
'labels' => $labels,
];
];
}
switch ($this->values['type_graph']) {
case 'bar_horizontal':
$options['axis'] = 'y';
$output .= vbar_graph(
$data,
$options
);
break;
case 'pie':
$empty = true;
foreach ($data as $key => $value) {
if ($value > 0) {
$empty = false;
break;
}
}
if ($empty === true) {
$output .= html_print_image(
'images/no_data_toshow.png',
true,
[ 'style' => 'width: 60%;' ]
);
} else {
$output .= pie_graph(
$data,
$options
);
}
break;
default:
$output .= vbar_graph(
$data,
$options
);
break;
}
$output .= vbar_graph(
$data_hbar,
$options
);
$output .= '</div>';
return $output;

View File

@ -385,33 +385,81 @@ class TopNEventByGroupWidget extends Widget
$all_group = true;
}
if ($all_group === false) {
$sql = sprintf(
'SELECT id_agente, COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
AND id_grupo IN (%s)
GROUP BY id_agente
ORDER BY count DESC
LIMIT %d',
$timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow']
);
} else {
$sql = sprintf(
'SELECT id_agente, COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
GROUP BY id_agente
ORDER BY count DESC
LIMIT %d',
$timestamp,
$this->values['amountShow']
);
}
if (is_metaconsole() === true) {
$servers = metaconsole_get_connection_names();
$result = [];
foreach ($servers as $key => $server) {
$connection = metaconsole_get_connection($server);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
$result = db_get_all_rows_sql($sql);
if ($all_group === false) {
$sql = sprintf(
'SELECT id_agente,
COUNT(*) AS count,
"'.$connection['id'].'" AS id_server
FROM tevento
WHERE utimestamp >= %d
AND id_grupo IN (%s)
GROUP BY id_agente
ORDER BY count DESC
LIMIT %d',
$timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow']
);
} else {
$sql = sprintf(
'SELECT id_agente,
COUNT(*) AS count,
"'.$connection['id'].'" AS id_server
FROM tevento
WHERE utimestamp >= %d
GROUP BY id_agente
ORDER BY count DESC
LIMIT %d',
$timestamp,
$this->values['amountShow']
);
}
$rows = db_get_all_rows_sql($sql);
if ($rows !== false) {
$result = array_merge($result, $rows);
}
metaconsole_restore_db();
}
} else {
if ($all_group === false) {
$sql = sprintf(
'SELECT id_agente, COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
AND id_grupo IN (%s)
GROUP BY id_agente
ORDER BY count DESC
LIMIT %d',
$timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow']
);
} else {
$sql = sprintf(
'SELECT id_agente, COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
GROUP BY id_agente
ORDER BY count DESC
LIMIT %d',
$timestamp,
$this->values['amountShow']
);
}
$result = db_get_all_rows_sql($sql);
}
if (empty($result) === true) {
$output .= '<div class="container-center">';
@ -430,11 +478,13 @@ class TopNEventByGroupWidget extends Widget
$name = __('System');
} else {
if (is_metaconsole() === true) {
$name = (string) db_get_value(
$name = (string) db_get_value_filter(
'alias',
'tmetaconsole_agent',
'id_tagente',
(int) $row['id_agente']
[
'id_tagente' => $row['id_agente'],
'id_tmetaconsole_setup' => $row['id_server'],
]
);
} else {
$name = io_safe_output(

View File

@ -383,39 +383,91 @@ class TopNEventByModuleWidget extends Widget
$all_group = true;
}
if ($all_group === false) {
$sql = sprintf(
'SELECT id_agente,
id_agentmodule,
event_type,
COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
AND id_grupo IN (%s)
GROUP BY id_agentmodule, event_type
ORDER BY count DESC
LIMIT %d',
$timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow']
);
} else {
$sql = sprintf(
'SELECT id_agente,
id_agentmodule,
event_type,
COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
GROUP BY id_agentmodule, event_type
ORDER BY count DESC
LIMIT %d',
$timestamp,
$this->values['amountShow']
);
}
if (is_metaconsole() === true) {
$servers = metaconsole_get_connection_names();
$result = [];
foreach ($servers as $key => $server) {
$connection = metaconsole_get_connection($server);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
$result = db_get_all_rows_sql($sql);
if ($all_group === false) {
$sql = sprintf(
'SELECT id_agente,
id_agentmodule,
event_type,
"'.$server.'" AS name_server,
COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
AND id_grupo IN (%s)
GROUP BY id_agentmodule, event_type
ORDER BY count DESC
LIMIT %d',
$timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow']
);
} else {
$sql = sprintf(
'SELECT id_agente,
id_agentmodule,
event_type,
"'.$server.'" AS name_server,
COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
GROUP BY id_agentmodule, event_type
ORDER BY count DESC
LIMIT %d',
$timestamp,
$this->values['amountShow']
);
}
$rows = db_get_all_rows_sql($sql);
if ($rows !== false) {
$result = array_merge($result, $rows);
}
metaconsole_restore_db();
}
} else {
if ($all_group === false) {
$sql = sprintf(
'SELECT id_agente,
id_agentmodule,
event_type,
COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
AND id_grupo IN (%s)
GROUP BY id_agentmodule, event_type
ORDER BY count DESC
LIMIT %d',
$timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow']
);
} else {
$sql = sprintf(
'SELECT id_agente,
id_agentmodule,
event_type,
COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
GROUP BY id_agentmodule, event_type
ORDER BY count DESC
LIMIT %d',
$timestamp,
$this->values['amountShow']
);
}
$result = db_get_all_rows_sql($sql);
}
if (empty($result) === true) {
$output = '<div class="container-center">';
@ -433,13 +485,30 @@ class TopNEventByModuleWidget extends Widget
if ($row['id_agentmodule'] == 0) {
$name = __('System');
} else {
$name_agent = io_safe_output(
agents_get_alias($row['id_agente'])
);
if (is_metaconsole() === true) {
$connection = metaconsole_get_connection($row['name_server']);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
$name_agent = io_safe_output(
agents_get_alias($row['id_agente'])
);
$name_module = io_safe_output(
modules_get_agentmodule_name($row['id_agentmodule'])
);
metaconsole_restore_db();
} else {
$name_agent = io_safe_output(
agents_get_alias($row['id_agente'])
);
$name_module = io_safe_output(
modules_get_agentmodule_name($row['id_agentmodule'])
);
}
$name_module = io_safe_output(
modules_get_agentmodule_name($row['id_agentmodule'])
);
if ($size['width'] < 400) {
$name_agent = ui_print_truncate_text(
$name_agent,

View File

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

View File

@ -1708,7 +1708,7 @@ if (empty($result) === false) {
// TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view
if (is_metaconsole() === true) {
echo "<form id='agent-redirection-".$inc_id."' method='POST' action='".$row['server_url']."index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$row['id_agent']."'>";
echo "<form id='agent-redirection-".$inc_id."' method='POST' action='".$row['server_url'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row['id_agent']."'>";
html_print_input_hidden(
'loginhash',
'auto',

View File

@ -67,6 +67,7 @@ if (is_ajax()) {
$agents_inserted = get_parameter('agents_inserted', []);
$id_group = (int) get_parameter('id_group');
$pendingdelete = (bool) get_parameter('pendingdelete');
$get_node_agent = (bool) get_parameter('get_node_agent', false);
$refresh_contact = get_parameter('refresh_contact', 0);
@ -1309,6 +1310,18 @@ if (is_ajax()) {
return;
}
if ($get_node_agent === true) {
$id = get_parameter('id', 0);
if (empty($id) === false) {
$result = db_get_value_sql(
'SELECT id_tmetaconsole_setup FROM tmetaconsole_agent WHERE id_agente = '.$id
);
echo json_encode($result);
return;
}
}
return;
}

View File

@ -203,21 +203,27 @@ try {
switch ($key) {
case 'module_status':
echo csv_format_delimiter(events_translate_module_status(
$row[$key]
));
echo csv_format_delimiter(
events_translate_module_status(
$row[$key]
)
);
break;
case 'event_type':
echo csv_format_delimiter(events_translate_event_type(
$row[$key]
));
echo csv_format_delimiter(
events_translate_event_type(
$row[$key]
)
);
break;
case 'criticity':
echo csv_format_delimiter(events_translate_event_criticity(
$row[$key]
));
echo csv_format_delimiter(
events_translate_event_criticity(
$row[$key]
)
);
break;
case 'custom_data':

View File

@ -628,6 +628,27 @@ if ($favorite_menu !== false) {
}
// Links.
$rows = db_get_all_rows_in_table('tlink', 'name');
// $rows = [];
if (!empty($rows)) {
$menu_operation['links']['text'] = __('Links');
$menu_operation['links']['sec2'] = '';
$menu_operation['links']['id'] = 'god-links';
$sub = [];
foreach ($rows as $row) {
// Audit //meter en extensiones.
$sub[$row['link']]['text'] = $row['name'];
$sub[$row['link']]['id'] = $row['name'];
$sub[$row['link']]['type'] = 'direct';
$sub[$row['link']]['subtype'] = 'new_blank';
}
$menu_operation['links']['sub'] = $sub;
}
// Links.
$rows = db_get_all_rows_in_table('tlink', 'name');
@ -804,6 +825,8 @@ if ($access_console_node === true) {
// ~ }
}
// Save operation menu array to use in operation/extensions.php view
$operation_menu_array = $menu_operation;

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.772
%define release 230630
%define release 230703
# 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 230630
%define release 230703
# 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 230630
%define release 230703
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -2094,7 +2094,7 @@ class Client
sprintf(
'UPDATE `tconfig` SET `value` = \'%s\'
WHERE `token` = "progress_update"',
$updates
mysqli_real_escape_string($this->dbh, $updates)
)
);
}

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.772-230630
Version: 7.0NG.772-230703
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-230630"
pandora_version="7.0NG.772-230703"
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 = "230630";
my $pandora_build = "230703";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

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 = "230630";
my $pandora_build = "230703";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -774,9 +774,16 @@ sub pandora_sendmail {
$mail{Message} = encode("UTF-8", $mail{Message});
$mail{'Content-Type'} = 'text/plain; charset="UTF-8"';
}
if ($pa_config->{"mta_user"} ne ""){
$mail{auth} = {user=>$pa_config->{"mta_user"}, password=>$pa_config->{"mta_pass"}, method=>$pa_config->{"mta_auth"}, required=>1 };
$mail{auth} = {
user=>$pa_config->{"mta_user"},
password=>PandoraFMS::Core::pandora_output_password(
$pa_config,
safe_output($pa_config->{"mta_pass"})
),
method=>$pa_config->{"mta_auth"}, required=>1
};
}
eval {

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.772
%define release 230630
%define release 230703
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 230630
%define release 230703
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.772"
PI_BUILD="230630"
PI_BUILD="230703"
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 230630";
my $version = "7.0NG.772 Build 230703";
# 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 230630";
my $version = "7.0NG.772 Build 230703";
# save program name for logging
my $progname = basename($0);