-
-
-
-
-
-
-
-
-
- load_tables();
-}
-
-$hack_metaconsole = (is_metaconsole() === true) ? '../../' : '';
-?>
-
-
-
-
-
Pandora FMS Graph
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ;'>
- 0,
- 'height' => 0,
- ];
-
- $style = 'width:100%;';
- if (isset($params['options']['viewport']) === true) {
- $viewport = $params['options']['viewport'];
- if (empty($viewport['width']) === false) {
- $style .= 'width:'.$viewport['width'].'px;';
- }
-
- if (empty($viewport['height']) === false) {
- $style .= 'height:'.$viewport['height'].'px;';
- }
- }
-
- echo '
';
- switch ($type_graph_pdf) {
- case 'combined':
- $params['pdf'] = true;
- $result = graphic_combined_module(
- $module_list,
- $params,
- $params_combined
- );
-
- echo $result;
- break;
-
- case 'sparse':
- $params['pdf'] = true;
- echo grafico_modulo_sparse($params);
- break;
-
- case 'pie_graph':
- $params['pdf'] = true;
- $chart = get_build_setup_charts(
- 'PIE',
- $params['options'],
- $params['chart_data']
- );
-
- echo $chart->render(true);
- break;
-
- case 'vbar_graph':
- $params['pdf'] = true;
- $chart = get_build_setup_charts(
- 'BAR',
- $params['options'],
- $params['chart_data']
- );
-
- echo $chart->render(true);
- break;
-
- case 'ring_graph':
- $params['pdf'] = true;
- $params['options']['width'] = 500;
- $params['options']['height'] = 500;
-
- $chart = get_build_setup_charts(
- 'DOUGHNUT',
- $params['options'],
- $params['chart_data']
- );
-
- echo $chart->render(true);
- break;
-
- case 'line_graph':
- $params['pdf'] = true;
- $params['options']['width'] = '100%';
- $params['options']['height'] = 200;
- $chart = get_build_setup_charts(
- 'LINE',
- $params['options'],
- $params['chart_data']
- );
- echo $chart->render(true);
- break;
-
- case 'slicebar':
- // TO-DO Cambiar esto para que se pase por POST, NO SE PUEDE PASAR POR GET.
- $params['graph_data'] = json_decode(io_safe_output($config[$params['tokem_config']]), true);
- delete_config_token($params['tokem_config']);
- echo flot_slicesbar_graph(
- $params['graph_data'],
- $params['period'],
- $params['width'],
- $params['height'],
- $params['legend'],
- $params['colors'],
- $params['fontpath'],
- $params['round_corner'],
- $params['homeurl'],
- $params['watermark'],
- $params['adapt_key'],
- $params['stat_winalse'],
- $params['id_agent'],
- $params['full_legend_daterray'],
- $params['not_interactive'],
- $params['ttl'],
- $params['sizeForTicks'],
- $params['show'],
- $params['date_to'],
- $params['server_id']
- );
- break;
-
- default:
- // Code...
- break;
- }
-
- echo '
';
- ?>
-
-
diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php
index 154d611bb8..83208256fb 100644
--- a/pandora_console/include/class/ConsoleSupervisor.php
+++ b/pandora_console/include/class/ConsoleSupervisor.php
@@ -2383,7 +2383,7 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
- 'title' => __('This instance is not registered in the Update manager section'),
+ 'title' => __('This instance is not registered in the Warp Update section'),
'message' => __('Click here to start the registration process'),
'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online',
]
@@ -2404,13 +2404,17 @@ class ConsoleSupervisor
{
global $config;
include_once $config['homedir'].'/include/functions_update_manager.php';
-
+ $server_name = db_get_value_filter(
+ 'name',
+ 'tserver',
+ [ 'server_type' => '1' ]
+ );
if (update_manager_verify_api() === false) {
$this->notify(
[
'type' => 'NOTIF.API.ACCESS',
'title' => __('Cannot access the Pandora FMS API '),
- 'message' => __('Please check the configuration, some components may fail due to this misconfiguration.'),
+ 'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'),
]
);
} else {
diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php
index aa5d5995af..ea3caaf276 100644
--- a/pandora_console/include/class/Diagnostics.class.php
+++ b/pandora_console/include/class/Diagnostics.class.php
@@ -737,7 +737,7 @@ class Diagnostics extends Wizard
$cpuModelName = 'cat /proc/cpuinfo | grep "model name" | tail -1 | cut -f 2 -d ":"';
$cpuProcessor = 'cat /proc/cpuinfo | grep "processor" | wc -l';
$ramMemTotal = 'cat /proc/meminfo | grep "MemTotal"';
-
+ $distroInfo = 'cat /etc/os-release | grep "PRETTY_NAME" | cut -f 2 -d "="';
exec(
"ifconfig | awk '{ print $2}' | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}'",
$output
@@ -756,6 +756,10 @@ class Diagnostics extends Wizard
'name' => __('RAM'),
'value' => exec($ramMemTotal),
],
+ 'distroInfo' => [
+ 'name' => __('Distro'),
+ 'value' => str_replace('"', '', exec($distroInfo)),
+ ],
'osInfo' => [
'name' => __('Os'),
'value' => exec('uname -a'),
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index a6f02aa7b6..fe3237294c 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
-$build_version = 'PC231128';
+$build_version = 'PC231205';
$pandora_version = 'v7.0NG.774';
// Do not overwrite default timezone set if defined.
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index babb318558..62245826c8 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -990,6 +990,70 @@ function get_parameter($name, $default='')
}
+function get_parameter_date($name, $default='', $date_format='Y/m/d')
+{
+ $date_end = get_parameter('date_end', 0);
+ $time_end = get_parameter('time_end');
+ $datetime_end = strtotime($date_end.' '.$time_end);
+
+ $custom_date = get_parameter('custom_date', 0);
+ $range = get_parameter('range', SECONDS_1DAY);
+ $date_text = get_parameter('range_text', SECONDS_1DAY);
+ $date_init_less = (strtotime(date('Y/m/d')) - SECONDS_1DAY);
+ $date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less));
+ $time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less));
+ $datetime_init = strtotime($date_init.' '.$time_init);
+ if ($custom_date === '1') {
+ if ($datetime_init >= $datetime_end) {
+ $datetime_init = $date_init_less;
+ }
+
+ $date_init = date('Y/m/d H:i:s', $datetime_init);
+ $date_end = date('Y/m/d H:i:s', $datetime_end);
+ $period = ($datetime_end - $datetime_init);
+ } else if ($custom_date === '2') {
+ $date_units = get_parameter('range_units');
+ $date_end = date('Y/m/d H:i:s');
+ $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - ((int) $date_text * (int) $date_units)));
+ $period = (strtotime($date_end) - strtotime($date_init));
+ } else if (in_array($range, ['this_week', 'this_month', 'past_week', 'past_month'])) {
+ if ($range === 'this_week') {
+ $monday = date('Y/m/d', strtotime('last monday'));
+
+ $sunday = date('Y/m/d', strtotime($monday.' +6 days'));
+ $period = (strtotime($sunday) - strtotime($monday));
+ $date_init = $monday;
+ $date_end = $sunday;
+ } else if ($range === 'this_month') {
+ $date_end = date('Y/m/d', strtotime('last day of this month'));
+ $first_of_month = date('Y/m/d', strtotime('first day of this month'));
+ $date_init = $first_of_month;
+ $period = (strtotime($date_end) - strtotime($first_of_month));
+ } else if ($range === 'past_month') {
+ $date_end = date('Y/m/d', strtotime('last day of previous month'));
+ $first_of_month = date('Y/m/d', strtotime('first day of previous month'));
+ $date_init = $first_of_month;
+ $period = (strtotime($date_end) - strtotime($first_of_month));
+ } else if ($range === 'past_week') {
+ $date_end = date('Y/m/d', strtotime('sunday', strtotime('last week')));
+ $first_of_week = date('Y/m/d', strtotime('monday', strtotime('last week')));
+ $date_init = $first_of_week;
+ $period = (strtotime($date_end) - strtotime($first_of_week));
+ }
+ } else {
+ $date_end = date('Y/m/d H:i:s');
+ $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range));
+ $period = (strtotime($date_end) - strtotime($date_init));
+ }
+
+ return [
+ 'date_init' => date($date_format, strtotime($date_init)),
+ 'date_end' => date($date_format, strtotime($date_end)),
+ 'period' => $period,
+ ];
+}
+
+
/**
* Get a parameter from a get request.
*
@@ -4311,48 +4375,22 @@ function generator_chart_to_pdf(
$module_list=false
) {
global $config;
-
- if (is_metaconsole()) {
+ $hack_metaconsole = '';
+ if (is_metaconsole() === true) {
$hack_metaconsole = '../..';
- } else {
- $hack_metaconsole = '';
}
- $url = ui_get_full_url(false).$hack_metaconsole.'/include/chart_generator.php';
-
if (!$params['return_img_base_64']) {
$img_file = 'img_'.uniqid().'.png';
$img_path = $config['homedir'].'/attachment/'.$img_file;
$img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file;
}
- $session_id = session_id();
- if ($type_graph_pdf === 'combined') {
- $data = [
- 'data' => $params,
- 'session_id' => $session_id,
- 'type_graph_pdf' => $type_graph_pdf,
- 'data_module_list' => $module_list,
- 'data_combined' => $params_combined,
- 'id_user' => $config['id_user'],
- 'slicebar' => $_SESSION['slicebar'],
- 'slicebar_value' => $config[$_SESSION['slicebar']],
- 'apipass' => get_parameter('apipass', null),
-
- ];
- } else {
- $data = [
- 'data' => $params,
- 'session_id' => $session_id,
- 'type_graph_pdf' => $type_graph_pdf,
- 'id_user' => $config['id_user'],
- 'slicebar' => $_SESSION['slicebar'],
- 'slicebar_value' => $config[$_SESSION['slicebar']],
- 'apipass' => get_parameter('apipass', null),
- ];
+ if ($type_graph_pdf !== 'combined') {
+ $params_combined = [];
+ $module_list = [];
}
- unset($data['data']['graph_data']);
// If not install chromium avoid 500 convert tu images no data to show.
$chromium_dir = io_safe_output($config['chromium_path']);
$result_ejecution = exec($chromium_dir.' --version');
@@ -4372,22 +4410,16 @@ function generator_chart_to_pdf(
// Creates a new page.
$page = $browser->createPage();
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, ['data' => json_encode($data)]);
+ // Generate Html.
+ $html = chart_generator(
+ $type_graph_pdf,
+ $params,
+ $params_combined,
+ $module_list
+ );
- $response = curl_exec($curl);
-
- curl_close($curl);
-
- $page->setHtml($response);
- /*
- //For debug url with parameters.
- $navigation = $page->navigate($url.'?data='.urlencode(json_encode($data)));
- $navigation->waitForNavigation(Page::DOM_CONTENT_LOADED);
- */
+ $page->setHtml($html);
// Dynamic.
$dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue();
@@ -4434,6 +4466,211 @@ function generator_chart_to_pdf(
}
+/**
+ * Html print chart for chromium
+ *
+ * @param string $type_graph_pdf Chart mode.
+ * @param array $params Params.
+ * @param array $params_combined Params Combined charts.
+ * @param array $module_list Module list Combined charts.
+ *
+ * @return string Output Html.
+ */
+function chart_generator(
+ string $type_graph_pdf,
+ array $params,
+ array $params_combined=[],
+ array $module_list=[]
+) : string {
+ global $config;
+
+ include_once $config['homedir'].'/include/graphs/functions_d3.php';
+
+ if (isset($params['backgroundColor']) === false) {
+ $params['backgroundColor'] = 'inherit';
+ }
+
+ $hack_metaconsole = (is_metaconsole() === true) ? '../../' : '';
+
+ $output = '';
+ $output .= '';
+ $output .= '';
+ $output .= '
';
+ $output .= '
Pandora FMS Graph ';
+ $output .= '';
+
+ $css_files = [
+ 'pandora' => 'include/styles/',
+ 'pandora_minimal' => 'include/styles/',
+ 'jquery-ui.min' => 'include/styles/js/',
+ 'jquery-ui_custom' => 'include/styles/js/',
+ ];
+
+ foreach ($css_files as $name => $path) {
+ $output .= ui_require_css_file($name, $path, true, true);
+ }
+
+ $js_files = [
+ 'pandora_ui' => 'include/javascript/',
+ 'jquery.current' => 'include/javascript/',
+ 'jquery.pandora' => 'include/javascript/',
+ 'jquery-ui.min' => 'include/javascript/',
+ 'date' => 'include/javascript/timezone/src/',
+ 'pandora' => 'include/javascript/',
+ 'jquery.flot' => 'include/graphs/flot/',
+ 'jquery.flot.min' => 'include/graphs/flot/',
+ 'jquery.flot.time' => 'include/graphs/flot/',
+ 'jquery.flot.pie' => 'include/graphs/flot/',
+ 'jquery.flot.crosshair.min' => 'include/graphs/flot/',
+ 'jquery.flot.stack.min' => 'include/graphs/flot/',
+ 'jquery.flot.selection.min' => 'include/graphs/flot/',
+ 'jquery.flot.resize.min' => 'include/graphs/flot/',
+ 'jquery.flot.threshold' => 'include/graphs/flot/',
+ 'jquery.flot.threshold.multiple' => 'include/graphs/flot/',
+ 'jquery.flot.symbol.min' => 'include/graphs/flot/',
+ 'jquery.flot.exportdata.pandora' => 'include/graphs/flot/',
+ 'jquery.flot.axislabels' => 'include/graphs/flot/',
+ 'pandora.flot' => 'include/graphs/flot/',
+ 'chart' => 'include/graphs/chartjs/',
+ 'chartjs-plugin-datalabels.min' => 'include/graphs/chartjs/',
+ ];
+
+ foreach ($js_files as $name => $path) {
+ $output .= ui_require_javascript_file($name, $path, true, true);
+ }
+
+ $output .= include_javascript_d3(true, true);
+
+ $output .= '';
+ $output .= '';
+ $params['only_image'] = false;
+ $params['menu'] = false;
+ $params['disable_black'] = true;
+
+ $viewport = [
+ 'width' => 0,
+ 'height' => 0,
+ ];
+
+ $style = 'width:100%;';
+ if (isset($params['options']['viewport']) === true) {
+ $viewport = $params['options']['viewport'];
+ if (empty($viewport['width']) === false) {
+ $style .= 'width:'.$viewport['width'].'px;';
+ }
+
+ if (empty($viewport['height']) === false) {
+ $style .= 'height:'.$viewport['height'].'px;';
+ }
+ }
+
+ $output .= '
';
+ switch ($type_graph_pdf) {
+ case 'combined':
+ $params['pdf'] = true;
+ $result = graphic_combined_module(
+ $module_list,
+ $params,
+ $params_combined
+ );
+
+ $output .= $result;
+ break;
+
+ case 'sparse':
+ $params['pdf'] = true;
+ $output .= grafico_modulo_sparse($params);
+ break;
+
+ case 'pie_graph':
+ $params['pdf'] = true;
+ $chart = get_build_setup_charts(
+ 'PIE',
+ $params['options'],
+ $params['chart_data']
+ );
+
+ $output .= $chart->render(true);
+ break;
+
+ case 'vbar_graph':
+ $params['pdf'] = true;
+ $chart = get_build_setup_charts(
+ 'BAR',
+ $params['options'],
+ $params['chart_data']
+ );
+
+ $output .= $chart->render(true);
+ break;
+
+ case 'ring_graph':
+ $params['pdf'] = true;
+ $params['options']['width'] = 500;
+ $params['options']['height'] = 500;
+
+ $chart = get_build_setup_charts(
+ 'DOUGHNUT',
+ $params['options'],
+ $params['chart_data']
+ );
+
+ $output .= $chart->render(true);
+ break;
+
+ case 'line_graph':
+ $params['pdf'] = true;
+ $params['options']['width'] = '100%';
+ $params['options']['height'] = 200;
+ $chart = get_build_setup_charts(
+ 'LINE',
+ $params['options'],
+ $params['chart_data']
+ );
+ $output .= $chart->render(true);
+ break;
+
+ case 'slicebar':
+ $output .= flot_slicesbar_graph(
+ $params['graph_data'],
+ $params['period'],
+ $params['width'],
+ $params['height'],
+ $params['legend'],
+ $params['colors'],
+ $params['fontpath'],
+ $params['round_corner'],
+ $params['homeurl'],
+ $params['watermark'],
+ $params['adapt_key'],
+ $params['stat_winalse'],
+ $params['id_agent'],
+ $params['full_legend_daterray'],
+ $params['not_interactive'],
+ $params['ttl'],
+ $params['sizeForTicks'],
+ $params['show'],
+ $params['date_to'],
+ $params['server_id']
+ );
+ break;
+
+ default:
+ // Code...
+ break;
+ }
+
+ $output .= '
';
+ $output .= '';
+ $output .= '';
+
+ return $output;
+}
+
+
/**
* Get the product name.
*
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 195b509106..2d6803ccd4 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -4752,7 +4752,7 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
$secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]);
$secondaryLinks = [];
if (empty($secondary_groups['for_select']) === true) {
- $secondaryLinks[] = '
'.__('N/A').' ';
+ $secondaryLinks = [];
} else {
foreach ($secondary_groups['for_select'] as $id => $name) {
$secondaryLinks[] = html_print_anchor(
@@ -4811,22 +4811,22 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
'content' => groups_get_name($agent['id_grupo']),
],
true
- );
+ ).' '.ui_print_group_icon($agent['id_grupo'], true, '', 'margin-left: 2%;', true, false, false, '', true);
$table_contact->data[] = $data;
// Secondary groups.
$data = [];
- $data[0] = '
'.__('Secondary groups').' ';
- $data[1] = implode(', ', $secondaryLinks);
- $table_contact->data[] = $data;
+ if (!empty($secondaryLinks) === true) {
+ $data[0] = '
'.__('Secondary groups').' ';
+ $data[1] = implode(', ', $secondaryLinks);
+ $table_contact->data[] = $data;
+ }
// Parent agent line.
if (enterprise_installed() === true) {
- $data = [];
- $data[0] = '
'.__('Parent').' ';
- if ((int) $agent['id_parent'] === 0) {
- $data[1] = '
'.__('N/A').' ';
- } else {
+ if ((int) $agent['id_parent'] !== 0) {
+ $data = [];
+ $data[0] = '
'.__('Parent').' ';
$data[1] = html_print_anchor(
[
'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_parent'],
@@ -4834,9 +4834,9 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
],
true
);
- }
- $table_contact->data[] = $data;
+ $table_contact->data[] = $data;
+ }
}
// Last status change line.
@@ -4845,6 +4845,44 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
$data[1] = $time_elapsed;
$table_contact->data[] = $data;
+ $has_remote_conf = enterprise_hook(
+ 'config_agents_has_remote_configuration',
+ [$agent['id_agente']]
+ );
+
+ if ((bool) $has_remote_conf) {
+ $data = [];
+ $data[0] = __('Remote configuration');
+ $data[1] = '
'.__('Enabled').' ';
+ $data[1] .= html_print_menu_button(
+ [
+ 'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1'),
+ 'image' => 'images/remote-configuration@svg.svg',
+ 'title' => __('Edit remote config'),
+ ],
+ true
+ );
+
+ $satellite_server = (int) db_get_value_filter(
+ 'satellite_server',
+ 'tagente',
+ ['id_agente' => $id_agente]
+ );
+
+ if (empty($satellite_server) === false) {
+ $satellite_name = db_get_value_filter(
+ 'name',
+ 'tserver',
+ ['id_server' => $satellite_server]
+ );
+
+ $data[0] = __('Satellite server');
+ $data[1] = $satellite_name;
+ }
+
+ $table_contact->data[] = $data;
+ }
+
if (enterprise_installed() === true) {
// SecurityMon line.
$id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security');
@@ -4887,6 +4925,43 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
}
}
+ // Optional data
+ // Position Information.
+ if ((bool) $config['activate_gis'] === true) {
+ $data = [];
+
+ $dataPositionAgent = gis_get_data_last_position_agent(
+ $agent['id_agente']
+ );
+ if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_latitude'] !== '') {
+ $data[0] = __('Position (Long, Lat)');
+
+ $dataOptionalOutput = html_print_anchor(
+ [
+ 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=gis&id_agente='.$id_agente,
+ 'content' => $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'],
+ ],
+ true
+ );
+
+ if (empty($dataPositionAgent['description']) === false) {
+ $dataOptionalOutput .= ' ('.$dataPositionAgent['description'].')';
+ }
+
+ $data[1] = $dataOptionalOutput;
+ }
+
+ $table_contact->data[] = $data;
+ }
+
+ // Timezone Offset.
+ if ((int) $agent['timezone_offset'] !== 0) {
+ $data = [];
+ $data[0] = __('Timezone Offset');
+ $data[1] = $agent['timezone_offset'];
+ $table_contact->data[] = $data;
+ }
+
$agent_contact = html_print_div(
[
'class' => 'agent_details_header',
diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php
index 94dcb97f6c..c461eb1402 100644
--- a/pandora_console/include/functions_alerts.php
+++ b/pandora_console/include/functions_alerts.php
@@ -2169,13 +2169,16 @@ function get_group_alerts(
$strict_user=false,
$tag=false,
$action_filter=false,
- $alert_action=true
+ $alert_action=true,
+ $search_sg=false
) {
global $config;
-
$group_query = '';
if (!empty($idGroup)) {
$group_query = ' AND id_grupo = '.$idGroup;
+ if ((bool) $search_sg === true) {
+ $group_query .= ' OR tasg.id_group = '.$idGroup;
+ }
}
if (is_array($filter)) {
diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index 210b933328..8f5fb66f54 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -82,7 +82,7 @@ function parseOtherParameter($other, $otherType, $rawDecode)
case 'url_encode':
$returnVar = [
'type' => 'string',
- 'data' => urldecode($other),
+ 'data' => $rawDecode ? rawurldecode($other) : urldecode($other),
];
break;
@@ -13132,7 +13132,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][18] != '') {
$values['id_extra'] = $other['data'][18];
- $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario
+ $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario,event_custom_id
FROM tevento
WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";';
@@ -13147,6 +13147,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['status'] = 2;
$ack_utimestamp = $val['ack_utimestamp'];
$values['id_usuario'] = $val['id_usuario'];
+ $values['event_custom_id'] = $val['event_custom_id'];
}
api_set_validate_event_by_id($val['id_evento']);
@@ -13177,7 +13178,8 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$custom_data,
$values['server_id'],
$values['id_extra'],
- $ack_utimestamp
+ $ack_utimestamp,
+ $values['event_custom_id'] ?? null
);
if ($other['data'][12] != '') {
@@ -17787,6 +17789,48 @@ function api_token_check(string $token)
}
+/**
+ * Set custom field value in tevento
+ *
+ * @param mixed $id_event Event id.
+ * @param mixed $custom_field Custom field to set.
+ * @return void
+ */
+function api_set_event_custom_id($id, $value)
+{
+ // Get the event
+ $event = events_get_event($id, false, is_metaconsole());
+ // If event not exists, end the execution.
+ if ($event === false) {
+ returnError(
+ 'event_not_exists',
+ 'Event not exists'
+ );
+ $result = false;
+ }
+
+ // Safe custom fields for hacks.
+ if (preg_match('/script/i', io_safe_output($value))) {
+ $result = false;
+ }
+
+ $result = events_event_custom_id(
+ $id,
+ $value
+ );
+
+ // If update results failed
+ if (empty($result) === true || $result === false) {
+ returnError(
+ 'The event could not be updated'
+ );
+ return false;
+ } else {
+ returnData('string', ['data' => 'Event updated.']);
+ }
+}
+
+
/**
* Extract info Agents for inventories ITSM.
*
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index bfdd131748..e47e84adeb 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -249,10 +249,6 @@ function config_update_config()
$error_update[] = __('Enable Netflow');
}
- if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) {
- $error_update[] = __('Enable Sflow');
- }
-
if (config_update_value('activate_feedback', (bool) get_parameter('activate_feedback'), true) === false) {
$error_update[] = __('Enable Feedback');
}
@@ -371,6 +367,10 @@ function config_update_config()
$error_update[] = __('show_experimental_features');
}
+ if (config_update_value('number_modules_queue', get_parameter('number_modules_queue'), true) === false) {
+ $error_update[] = __('number_modules_queue');
+ }
+
if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) {
$error_update[] = __('Console log enabled');
}
@@ -1619,6 +1619,10 @@ function config_update_config()
if (config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'), true) === false) {
$error_update[] = __('Name resolution for IP address');
}
+
+ if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) {
+ $error_update[] = __('Enable Sflow');
+ }
break;
case 'sflow':
@@ -2441,6 +2445,10 @@ function config_process_config()
config_update_value('show_experimental_features', 0);
}
+ if (!isset($config['number_modules_queue'])) {
+ config_update_value('number_modules_queue', 500);
+ }
+
if (!isset($config['agent_vulnerabilities'])) {
config_update_value('agent_vulnerabilities', 1);
}
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 2a91641315..013698b33d 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -219,6 +219,7 @@ function events_get_all_fields()
$columns['module_status'] = __('Module status');
$columns['module_custom_id'] = __('Module custom id');
$columns['custom_data'] = __('Custom data');
+ $columns['event_custom_id'] = __('Event Custom ID');
return $columns;
}
@@ -322,6 +323,9 @@ function events_get_column_name($field, $table_alias=false)
case 'custom_data':
return __('Custom data');
+ case 'event_custom_id':
+ return __('Event Custom ID');
+
default:
return __($field);
}
@@ -2356,7 +2360,8 @@ function events_create_event(
$custom_data='',
$server_id=0,
$id_extra='',
- $ack_utimestamp=0
+ $ack_utimestamp=0,
+ $event_custom_id=null
) {
if ($source === false) {
$source = get_product_name();
@@ -2388,6 +2393,7 @@ function events_create_event(
'custom_data' => $custom_data,
'data' => '',
'module_status' => 0,
+ 'event_custom_id' => $event_custom_id,
];
return (int) db_process_sql_insert('tevento', $values);
@@ -2611,7 +2617,6 @@ function events_print_type_img(
$urlImage = ui_get_full_url(false);
$icon = '';
$style = 'main_menu_icon';
-
switch ($type) {
case 'alert_recovered':
$icon = 'images/alert_recovered@svg.svg';
@@ -2677,16 +2682,6 @@ function events_print_type_img(
if ($only_url) {
$output = $urlImage.'/'.$icon;
} else {
- /*
- $output .= html_print_div(
- [
- 'title' => events_print_type_description($type, true),
- 'class' => $style,
- 'style' => ((empty($icon) === false) ? 'background-image: url('.$icon.'); background-repeat: no-repeat;' : ''),
- ],
- true
- );
- */
$output .= html_print_image(
$icon,
true,
@@ -4658,6 +4653,30 @@ function events_page_details($event, $server_id=0)
$data[1] = '
'.__('N/A').' ';
}
+ $table_details->data[] = $data;
+ $readonly = true;
+ if (check_acl($config['id_user'], 0, 'EW')) {
+ $readonly = false;
+ }
+
+ $data = [];
+ $data[0] = __('Event Custom ID');
+ $data[1] = '
'.html_print_input_text('event_custom_id', $event['event_custom_id'], '', false, 255, true, $readonly, false, '', 'w60p');
+ if ($readonly === false) {
+ $data[1] .= html_print_button(
+ __('Update'),
+ 'update_event_custom_id',
+ false,
+ 'update_event_custom_id('.$event['id_evento'].', '.$event['server_id'].');',
+ [
+ 'icon' => 'next',
+ 'mode' => 'link',
+ ],
+ true
+ );
+ }
+
+ $data[1] .= '
';
$table_details->data[] = $data;
$details = '
'.html_print_table($table_details, true).'
';
@@ -6260,6 +6279,63 @@ function event_get_counter_extraId(array $event, ?array $filters)
}
+/**
+ * Update event detail custom field
+ *
+ * @param mixed $id_event Event ID or array of events.
+ * @param string $event_custom_id Event custom ID to be update.
+ *
+ * @return boolean Whether or not it was successful
+ */
+function events_event_custom_id(
+ $id_event,
+ $event_custom_id,
+) {
+ global $config;
+ // Cleans up the selection for all unwanted values also casts any single
+ // values as an array.
+ if (![$id_event]) {
+ $id_event = (array) safe_int($id_event, 1);
+ }
+
+ // Check ACL.
+ foreach ($id_event as $k => $id) {
+ $event_group = events_get_group($id);
+ if (check_acl($config['id_user'], $event_group, 'EW') == 0) {
+ db_pandora_audit(
+ AUDIT_LOG_ACL_VIOLATION,
+ 'Attempted updating event #'.$id
+ );
+
+ unset($id_event[$k]);
+ }
+ }
+
+ if (empty($id_event) === true) {
+ return false;
+ }
+
+ // Get the current event comments.
+ $first_event = $id_event;
+ if (is_array($id_event) === true) {
+ $first_event = reset($id_event);
+ }
+
+ // Update comment.
+ $ret = db_process_sql_update(
+ 'tevento',
+ ['event_custom_id' => $event_custom_id],
+ ['id_evento' => $first_event]
+ );
+
+ if (($ret === false) || ($ret === 0)) {
+ return false;
+ }
+
+ return true;
+}
+
+
function event_print_graph(
$filter,
$graph_height=100,
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 0db7534f7c..06ab07598d 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -1745,20 +1745,37 @@ function html_print_select_multiple_modules_filtered(array $data):string
}
}
- $output .= html_print_input(
- [
- 'label' => __('Agents'),
- 'label_class' => 'font-title-font',
- 'type' => 'select_from_sql',
- 'sql' => 'SELECT `id_agente`,`alias` FROM tagente',
- 'name' => 'filtered-module-agents-'.$uniqId,
- 'selected' => explode(',', $data['mAgents']),
- 'return' => true,
- 'multiple' => true,
- 'style' => 'min-width: 200px;max-width:200px;',
- 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
- ]
- );
+ if (is_metaconsole() === true) {
+ $output .= html_print_input(
+ [
+ 'label' => __('Agents'),
+ 'label_class' => 'font-title-font',
+ 'type' => 'select',
+ 'fields' => $agents,
+ 'name' => 'filtered-module-agents-'.$uniqId,
+ 'selected' => explode(',', $data['mAgents']),
+ 'return' => true,
+ 'multiple' => true,
+ 'style' => 'min-width: 200px;max-width:200px;',
+ 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
+ ]
+ );
+ } else {
+ $output .= html_print_input(
+ [
+ 'label' => __('Agents'),
+ 'label_class' => 'font-title-font',
+ 'type' => 'select_from_sql',
+ 'sql' => 'SELECT `id_agente`,`alias` FROM tagente',
+ 'name' => 'filtered-module-agents-'.$uniqId,
+ 'selected' => explode(',', $data['mAgents']),
+ 'return' => true,
+ 'multiple' => true,
+ 'style' => 'min-width: 200px;max-width:200px;',
+ 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
+ ]
+ );
+ }
$commonModules = 0;
if (empty($data['mShowCommonModules']) === false) {
diff --git a/pandora_console/include/functions_macros.php b/pandora_console/include/functions_macros.php
new file mode 100644
index 0000000000..bba0bd1898
--- /dev/null
+++ b/pandora_console/include/functions_macros.php
@@ -0,0 +1,61 @@
+ ($agente['nombre']) ?: '',
+ '_agentalias_' => ($agente['alias']) ?: '',
+ '_agent_' => ($agente['alias']) ?: (($agente['nombre']) ?: ''),
+ '_agentcustomid_' => ($agente['custom_id']) ?: '',
+ '_agentdescription_' => ($agente['comentarios']) ?: '',
+ '_agentgroup_' => ($grupo['nombre']) ?: '',
+ '_agentos_' => ($agente['id_os']) ?: '',
+ '_address_' => ($agente['direccion']) ?: '',
+ '_homeurl_' => ($config['public_url']) ?: '',
+ '_groupcontact_' => ($agente['contact']) ?: '',
+ '_groupcustomid_' => ($agente['custom_id']) ?: '',
+ '_groupother_' => ($agente['other']) ?: '',
+ '_server_ip_' => ($server_ip) ?: '',
+ '_server_name_' => ($agente['server_name']) ?: '',
+ ];
+
+ return $array_macros;
+}
diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php
index 346dee04b5..66b14a2776 100644
--- a/pandora_console/include/functions_menu.php
+++ b/pandora_console/include/functions_menu.php
@@ -1003,7 +1003,7 @@ if (is_ajax()) {
$dialogButtons = [];
$dialogButtons[] = html_print_button(
- __('Update manager'),
+ __('Warp update'),
'update_manager',
false,
'location.href="'.ui_get_full_url('/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=history', false, false, false).'"',
@@ -1170,6 +1170,14 @@ if (is_ajax()) {
'.$sys_info->data->ramInfo->value.'