diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index f866154ec6..87e4bb4b35 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -11,7 +11,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2022020801' +S_VERSION='2022050901' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -82,7 +82,6 @@ check_pre_pandora () { } check_repo_connection () { - execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection" execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo" execute_cmd "ping -c 2 support.pandorafms.com" "Checking Enterprise repo" } diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index 5112e69fe0..c8c7561ffc 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -86,7 +86,6 @@ check_pre_pandora () { } check_repo_connection () { - execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection" execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo" execute_cmd "ping -c 2 support.pandorafms.com" "Checking Enterprise repo" } diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 12bc038128..922a687d99 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.762-220606 +Version: 7.0NG.762-220608 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 613172a1aa..98c9118a78 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.762-220606" +pandora_version="7.0NG.762-220608" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index bcf2e39f6c..8dee5f151e 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.762'; -use constant AGENT_BUILD => '220606'; +use constant AGENT_BUILD => '220608'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 71effc4fb8..a8e4c1b829 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.762 -%define release 220606 +%define release 220608 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 0289274f67..26224284e1 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.762 -%define release 220606 +%define release 220608 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 30c6cf0e86..15fcc47738 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.762" -PI_BUILD="220606" +PI_BUILD="220608" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index cc1aeeb539..9cea4335e5 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220606} +{220608} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 76560d4a5d..c38a63c3ff 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.762 Build 220606") +#define PANDORA_VERSION ("7.0NG.762 Build 220608") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 79b995fcab..8f2689dd2a 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.762(Build 220606))" + VALUE "ProductVersion", "(7.0NG.762(Build 220608))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index a6b3e0bc06..5d7ac0db29 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.762-220606 +Version: 7.0NG.762-220608 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index b90d79665d..449b334f8e 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.762-220606" +pandora_version="7.0NG.762-220608" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/55.sql b/pandora_console/extras/mr/55.sql index 2618a7512c..f53133c456 100644 --- a/pandora_console/extras/mr/55.sql +++ b/pandora_console/extras/mr/55.sql @@ -2,4 +2,6 @@ START TRANSACTION; ALTER TABLE `tservice` ADD COLUMN `enable_sunburst` tinyint(1) NOT NULL default 0; +ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT ''; + COMMIT; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index b1b0a5e48a..7384ac17ff 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -954,7 +954,7 @@ echo sprintf('
', $menuTypeClass); $("a.autorefresh").click (function () { $("a.autorefresh_txt").toggle (); - $("#combo_refr").toggle (); + $("#combo_refr").toggle(); $("select#ref").change (function () { href = $("a.autorefresh").attr ("href"); diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 8b276d7233..068026c953 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -261,7 +261,7 @@ $table->data[2][1] = html_print_select_from_sql( 'id_command', $id_command, '', - __('None'), + '', 0, true, false, diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index e85a12486d..cc87efebed 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -140,7 +140,7 @@ function process_manage_delete($id_agents) } -$id_group = (int) get_parameter('id_group'); +$id_group = (is_metaconsole() === true) ? get_parameter('id_group', '') : (int) get_parameter('id_group'); $id_agents = get_parameter('id_agents'); $recursion = get_parameter('recursion'); $delete = (bool) get_parameter_post('delete'); @@ -282,15 +282,15 @@ $table->data[3][0] .= ''; -$agents = agents_get_group_agents( - array_keys(users_get_groups($config['id_user'], 'AW', false)), - ['disabled' => 2], - 'none', - false, - false, - is_metaconsole(), - '|' -); +$agents = []; +if (is_metaconsole() === false) { + $agents = agents_get_group_agents( + array_keys(users_get_groups($config['id_user'], 'AW', false)), + ['disabled' => 2], + 'none' + ); +} + $table->data[3][1] = html_print_select( $agents, diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 724d695f6a..6a8ea04e0f 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -606,6 +606,7 @@ switch ($action) { $event_graph_by_criticity = $style['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; $filter_search = $style['event_filter_search']; $filter_exclude = $style['event_filter_exclude']; @@ -631,6 +632,7 @@ switch ($action) { $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; break; case 'event_report_module': @@ -665,6 +667,7 @@ switch ($action) { $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; break; case 'general': @@ -2911,6 +2914,23 @@ $class = 'databox filters'; + + + + + + + + + @@ -5974,6 +5994,7 @@ function chooseType() { $("#row_event_graph_by_criticity").hide(); $("#row_event_graph_by_validated").hide(); $("#row_extended_events").hide(); + $("#row_custom_data_events").hide(); $("#row_netflow_filter").hide(); $("#row_max_values").hide(); $("#row_resolution").hide(); @@ -6044,6 +6065,7 @@ function chooseType() { $("#row_event_graph_by_criticity").show(); $("#row_event_graph_by_validated").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_filter_search").show(); $("#row_filter_exclude").show(); @@ -6371,6 +6393,7 @@ function chooseType() { $("#row_event_graph_by_validated").show(); $("#row_event_type").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_filter_search").show(); $("#row_filter_exclude").show(); @@ -6389,7 +6412,7 @@ function chooseType() { $("#row_event_graphs").show(); $("#row_event_type").show(); $("#row_extended_events").show(); - $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); @@ -6414,6 +6437,7 @@ function chooseType() { $("#row_event_graphs").show(); $("#row_event_type").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 608f2f6a54..94c9e0b454 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2224,12 +2224,18 @@ switch ($action) { $filter_event_status ); + $custom_data_events = get_parameter_switch( + 'custom_data_events', + 0 + ); + $style['event_graph_by_agent'] = $event_graph_by_agent; $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_filter_search'] = $event_filter_search; $style['event_filter_exclude'] = $event_filter_exclude; + $style['custom_data_events'] = $custom_data_events; if ($label != '') { @@ -2957,6 +2963,11 @@ switch ($action) { '' ); + $custom_data_events = get_parameter_switch( + 'custom_data_events', + 0 + ); + // Added for events items. $style['show_summary_group'] = $show_summary_group; @@ -2976,6 +2987,7 @@ switch ($action) { $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_filter_search'] = $event_filter_search; $style['event_filter_exclude'] = $event_filter_exclude; + $style['custom_data_events'] = $custom_data_events; if ($label != '') { $style['label'] = $label; diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index 0b29b3a895..b9420eba44 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -523,6 +523,14 @@ class TreeService extends Tree continue 2; } + $title = get_parameter('title', ''); + if (empty($title) === true) { + $tmp['title'] = ''; + } else { + $tmp['title'] = $title.'/'; + } + + $tmp['title'] .= $service->name(); $tmp['id'] = (int) $item->service()->id(); $tmp['name'] = $item->service()->name(); $tmp['alias'] = $item->service()->name(); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index eb7f300d32..9e9f90deb6 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 = 'PC220606'; +$build_version = 'PC220608'; $pandora_version = 'v7.0NG.762'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 592a5cc495..2972e88fc7 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -5988,6 +5988,56 @@ function send_test_email( } +/** + * Return array of ancestors of item, given array. + * + * @param integer $item From index. + * @param array $data Array data. + * @param string $key Pivot key (identifies the parent). + * @param string|null $extract Extract certain column or index. + * @param array $visited Cycle detection. + * + * @return array Array of ancestors. + */ +function get_ancestors( + int $item, + array $data, + string $key, + ?string $extract=null, + array &$visited=[] +) :array { + if (isset($visited[$item]) === true) { + return []; + } + + $visited[$item] = 1; + + if (isset($data[$item]) === false) { + return []; + } + + if (isset($data[$item][$key]) === false) { + if ($extract !== null) { + return [$data[$item][$extract]]; + } + + return [$item]; + } + + if ($extract !== null) { + return array_merge( + get_ancestors($data[$item][$key], $data, $key, $extract, $visited), + [$data[$item][$extract]] + ); + } + + return array_merge( + get_ancestors($data[$item][$key], $data, $key, $extract, $visited), + [$item] + ); +} + + if (function_exists('str_contains') === false) { diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 81b36f7476..070ff52831 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -118,6 +118,9 @@ function alerts_get_alerts($id_group=0, $free_search='', $status='all', $standby $sql .= ' AND t3.id_agente = '.$id_agent; } + // Only enabled agent. + $sql .= ' AND t3.disabled = 0'; + $row_alerts = db_get_all_rows_sql($sql); if ($total) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 1a7faa6516..edc47dc02b 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -810,7 +810,7 @@ function reporting_make_reporting_data( break; } - $report['contents'][] = $report_control; + $report['contents'][] = $report_control; break; case 'event_report_module': @@ -826,7 +826,7 @@ function reporting_make_reporting_data( break; } - $report['contents'][] = $report_control; + $report['contents'][] = $report_control; break; case 'event_report_group': @@ -1943,6 +1943,8 @@ function reporting_event_report_group( $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; + $return['show_custom_data'] = (isset($event_filter['custom_data_events']) === true) ? (bool) $event_filter['custom_data_events'] : false; + // Filter. $show_summary_group = $event_filter['show_summary_group']; $filter_event_severity = json_decode($event_filter['filter_event_severity'], true); @@ -2250,6 +2252,8 @@ function reporting_event_report_module( $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; + $return['show_custom_data'] = (isset($event_filter['custom_data_events']) === true) ? (bool) $event_filter['custom_data_events'] : false; + // Filter. $show_summary_group = $event_filter['show_summary_group']; $filter_event_severity = json_decode( @@ -3783,6 +3787,8 @@ function reporting_event_report_agent( $filter_event_status = json_decode($style['filter_event_status'], true); $filter_event_filter_search = $style['event_filter_search']; $filter_event_filter_exclude = $style['event_filter_exclude']; + $show_custom_data = (isset($style['custom_data_events']) === true) ? (bool) $style['custom_data_events'] : false; + $return['show_custom_data'] = $show_custom_data; // Graph. $event_graph_by_user_validator = $style['event_graph_by_user_validator']; @@ -3804,7 +3810,8 @@ function reporting_event_report_agent( $filter_event_status, $filter_event_filter_search, $filter_event_filter_exclude, - $id_server + $id_server, + $show_custom_data ); reporting_set_conf_charts( @@ -6956,7 +6963,7 @@ function sla_truncate($num, $accurancy=2) * * @param integer $value Value. * @param integer $min Treshold min SLA. - * @param boolean $max Treshold max SLA. + * @param integer $max Treshold max SLA. * @param boolean $inverse_interval Treshold inverse SLA. * * @return boolean Returns the interval in downtime (false if no matches). @@ -10594,7 +10601,8 @@ function reporting_get_agents_detailed_event( $filter_event_status=false, $filter_event_filter_search=false, $filter_event_filter_exclude=false, - $id_server=0 + $id_server=0, + $show_custom_data=false ) { global $config; @@ -10645,6 +10653,7 @@ function reporting_get_agents_detailed_event( 'validated_by' => $e['id_usuario'], 'timestamp' => $e['timestamp_rep'], 'id_evento' => $e['id_evento'], + 'custom_data' => ($show_custom_data === true) ? $e['custom_data'] : '', ]; } else { $return_data[] = [ @@ -10655,6 +10664,7 @@ function reporting_get_agents_detailed_event( 'validated_by' => $e['id_usuario'], 'timestamp' => $e['timestamp'], 'id_evento' => $e['id_evento'], + 'custom_data' => ($show_custom_data === true) ? $e['custom_data'] : '', ]; } } @@ -14657,8 +14667,10 @@ function reporting_module_histogram_graph($report, $content, $pdf=0) if ($modules_is_string === false) { if ($agentmodule_info['max_critical'] == 0) { $max_value_critical = null; - if ((bool) $content['dinamic_proc'] === true) { - $max_value_critical = 0.01; + if ($agentmodule_info['min_critical'] == 0) { + if ((bool) $content['dinamic_proc'] === true) { + $max_value_critical = 0.01; + } } } else { $max_value_critical = $agentmodule_info['max_critical']; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 25620b2de6..e8502376c1 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -1025,6 +1025,7 @@ function reporting_html_event_report_group($table, $item, $pdf=0) global $config; $show_extended_events = $item['show_extended_events']; + $show_custom_data = (bool) $item['show_custom_data']; if ($item['total_events']) { $table1 = new stdClass(); @@ -1060,6 +1061,10 @@ function reporting_html_event_report_group($table, $item, $pdf=0) $table1->head[6] = __('Timestamp'); } + if ($show_custom_data === true) { + $table1->head[8] = __('Custom data'); + } + foreach ($item['data'] as $k => $event) { // First pass along the class of this row. if ($item['show_summary_group']) { @@ -1132,6 +1137,16 @@ function reporting_html_event_report_group($table, $item, $pdf=0) $data[] = ''.date($config['date_format'], strtotime($event['timestamp'])).''; } + if ($show_custom_data === true) { + $custom_data = json_decode($event['custom_data'], true); + $custom_data_text = ''; + foreach ($custom_data as $key => $value) { + $custom_data_text .= $key.' = '.$value.'
'; + } + + $data[] = $custom_data_text; + } + array_push($table1->data, $data); if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) { @@ -1246,10 +1261,10 @@ function reporting_html_event_report_group($table, $item, $pdf=0) function reporting_html_event_report_module($table, $item, $pdf=0) { global $config; - $show_extended_events = $item['show_extended_events']; $show_summary_group = $item['show_summary_group']; + $show_custom_data = (bool) $item['show_custom_data']; if ($item['total_events']) { if (!empty($item['failed'])) { $table->colspan['events']['cell'] = 3; @@ -1279,6 +1294,10 @@ function reporting_html_event_report_module($table, $item, $pdf=0) $table1->style[0] = 'text-align: center;'; } + if ($show_custom_data === true) { + $table1->head[6] = __('Custom data'); + } + if (is_array($item['data']) || is_object($item['data'])) { $item_data = array_reverse($item['data']); } @@ -1331,6 +1350,16 @@ function reporting_html_event_report_module($table, $item, $pdf=0) $data[4] = date($config['date_format'], strtotime($event['timestamp'])); } + if ($show_custom_data === true) { + $custom_data = json_decode($event['custom_data'], true); + $custom_data_text = ''; + foreach ($custom_data as $key => $value) { + $custom_data_text .= $key.' = '.$value.'
'; + } + + $data[6] = $custom_data_text; + } + $table1->data[] = $data; if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) { @@ -2341,6 +2370,13 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) $table1->align[0] = 'center'; $table1->align[1] = 'center'; $table1->align[3] = 'center'; + if ((bool) $item['show_custom_data'] === true) { + if ($item['show_summary_group']) { + $table1->align[7] = 'left'; + } else { + $table1->align[6] = 'left'; + } + } $table1->data = []; @@ -2355,6 +2391,9 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) $table1->head[4] = __('Severity'); $table1->head[5] = __('Val. by'); $table1->head[6] = __('Timestamp'); + if ((bool) $item['show_custom_data'] === true) { + $table1->head[7] = __('Custom data'); + } foreach ($item['data'] as $i => $event) { if ($item['show_summary_group']) { @@ -2420,6 +2459,16 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) $data[] = ''.date($config['date_format'], strtotime($event['timestamp'])).''; } + if ((bool) $item['show_custom_data'] === true) { + $custom_data = json_decode($event['custom_data'], true); + $custom_data_text = ''; + foreach ($custom_data as $key => $value) { + $custom_data_text .= $key.' = '.$value.'
'; + } + + $data[] = $custom_data_text; + } + array_push($table1->data, $data); if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) { diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 7f22c6e9d0..073a862c4c 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -861,7 +861,7 @@ var TreeController = { '' +
                 element.name +
                 ' '; @@ -1314,6 +1314,7 @@ var TreeController = { serverID: element.serverID, rootType: element.rootType, metaID: element.metaID, + title: element.title, filter: controller.filter, auth_class: controller.auth_class, id_user: controller.id_user, diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php index 21a7edc82c..9fafaf6751 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php @@ -272,7 +272,20 @@ class ServiceMapWidget extends Widget $fields = array_reduce( $services_res, function ($carry, $item) { - $carry[$item['id']] = $item['name']; + $parents = ''; + if (class_exists('\PandoraFMS\Enterprise\Service') === true) { + try { + $service = new \PandoraFMS\Enterprise\Service($item['id']); + $ancestors = $service->getAncestors(); + if (empty($ancestors) === false) { + $parents = '('.join('/', $ancestors).')'; + } + } catch (\Exception $e) { + $parents = ''; + } + } + + $carry[$item['id']] = $item['name'].' '.$parents; return $carry; }, [] diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 20e611ca26..83f2a89ac2 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -9021,3 +9021,29 @@ div#err_msg_centralised { #reset-styles var { font-style: italic; } + +.div-col { + width: 33%; + display: flex; + flex-direction: row; + align-items: center; + padding-top: 15px; +} + +.div-span { + width: 25%; +} + +.div-input { + width: 75%; +} + +@media screen and (max-width: 1369px) { + .div-col { + width: 50%; + display: flex; + flex-direction: row; + align-items: center; + padding-top: 15px; + } +} diff --git a/pandora_console/install.php b/pandora_console/install.php index df9b54b2cf..b8969a90fd 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
data[0][5] = html_print_select($rows_select, 'modulegroup', $modulegroup, '', __($is_none), -1, true, false, true, '', false, 'width: 120px;'); -$table->rowspan[0][6] = 3; -$table->data[0][6] = html_print_submit_button( - __('Show'), - 'uptbutton', - false, - 'class="sub search mgn_tp_0"', - true -); - $table->data[1][0] = __('Module name'); $table->data[1][1] = html_print_autocomplete_modules( 'ag_modulename', @@ -579,7 +570,12 @@ if (empty($tags)) { ); } - +$table2 = new StdClass(); +$table2->width = '100%'; +$table2->class = 'filters'; +$table2->style = []; +$table2->style[0] = 'font-weight: bold;'; +$table2->style[1] = 'font-weight: bold;'; $network_available = db_get_sql( 'SELECT count(*) @@ -647,9 +643,9 @@ if (enterprise_installed()) { } -$table->data[2][0] = ''.__('Server type').''; +$table2->data[0][0] = ''.__('Server type').''; -$table->data[2][1] = html_print_select($typemodules, 'moduletype', $moduletype, '', __($is_none), '', true, false, true, '', false, 'width: 150px;'); +$table2->data[0][1] = html_print_select($typemodules, 'moduletype', $moduletype, '', __($is_none), '', true, false, true, '', false, 'width: 150px;'); $monitor_options = [ 0 => __('All'), @@ -657,21 +653,18 @@ $monitor_options = [ 2 => __('Only disabled'), ]; -$table->data[2][2] = ''.__('Show monitors...').''; +$table2->data[0][2] = ''.__('Show monitors...').''; -$table->data[2][3] = html_print_select($monitor_options, 'module_option', $module_option, '', '', '', true, false, true, '', false, 'width: 150px;'); +$table2->data[0][3] = html_print_select($monitor_options, 'module_option', $module_option, '', '', '', true, false, true, '', false, 'width: 150px;'); $min_hours_val = empty($min_hours_status) ? '' : (int) $min_hours_status; -$table->data[2][4] = ''.__('Min. hours in current status').''; -$table->data[2][5] = html_print_input_text('min_hours_status', $min_hours_val, '', 12, 20, true); +$table2->data[0][4] = ''.__('Min. hours in current status').''; +$table2->data[0][5] = html_print_input_text('min_hours_status', $min_hours_val, '', 12, 20, true); -$table->data[3][0] = 'data[3][0] .= '>'.__('Data type').''; - - -$table->data[3][1] .= '
'; +$table2->data[1][0] = 'data[1][0] .= '>'.__('Data type').''; +$table2->data[1][1] .= '
'; switch ($moduletype) { @@ -744,143 +737,349 @@ switch ($moduletype) { } $a = db_get_all_rows_sql($sql); -$table->data[3][1] .= 'data[3][1] .= '>'; +$table2->data[1][1] .= '>'; -$table->data[3][1] .= ''; +$table2->data[1][1] .= ''; foreach ($a as $valor) { - $table->data[3][1] .= ''; + $table2->data[1][1] .= '>'.$valor['descripcion'].''; } - $table->data[3][1] .= ''; - - - - - $table->data[3][1] .= '
'; - $check_not_condition = ''; +$table2->data[1][1] .= ''; +$table2->data[1][1] .= '
'; +$check_not_condition = ''; if ($not_condition !== '') { $check_not_condition = true; } -$table->data[4][0] .= __('Not condition').' '.ui_print_help_tip(__('If you check this option, those elements that do NOT meet any of the requirements will be shown'), true); - $table->data[4][1] = html_print_div( +$table2->data[1][2] .= __('Not condition').' '.ui_print_help_tip(__('If you check this option, those elements that do NOT meet any of the requirements will be shown'), true); +$table2->data[1][3] = html_print_div( + [ + 'class' => 'w120px mrgn_5px mrgn_lft_0px mrgn_right_0px', + 'content' => html_print_input( [ - 'class' => 'w120px mrgn_5px mrgn_lft_0px mrgn_right_0px', - 'content' => html_print_input( - [ - 'type' => 'switch', - 'name' => 'not_condition', - 'return' => false, - 'checked' => $check_not_condition, - 'value' => 'NOT', - 'id' => 'not_condition_switch', - 'onclick' => 'changeNotConditionStatus(this)', - ] - ), - ], - true - ); + 'type' => 'switch', + 'name' => 'not_condition', + 'return' => false, + 'checked' => $check_not_condition, + 'value' => 'NOT', + 'id' => 'not_condition_switch', + 'onclick' => 'changeNotConditionStatus(this)', + ] + ), + ], + true +); - $table_custom_fields = new stdClass(); - $table_custom_fields->class = 'filters'; - $table_custom_fields->width = '100%'; - $table_custom_fields->style = []; - $table_custom_fields->style[0] = 'font-weight: bold;'; - - // Style is different in metaconsole. - if ($is_metaconsole === false) { - $table_custom_fields->style[0] = 'font-weight: bold; width: 150px;'; - } - - if ($is_metaconsole === true) { - $table_custom_fields->styleTable = 'margin-left:0px; margin-top:15px;'; - $table_custom_fields->cellpadding = '0'; - $table_custom_fields->cellspacing = '0'; - } - - $table_custom_fields->colspan = []; - $table_custom_fields->data = []; - - $custom_fields = db_get_all_fields_in_table('tagent_custom_fields'); - if ($custom_fields === false) { - $custom_fields = []; - } - - foreach ($custom_fields as $custom_field) { - $row = []; - $row[0] = $custom_field['name']; +$custom_fields = db_get_all_fields_in_table('tagent_custom_fields'); +if ($custom_fields === false) { + $custom_fields = []; +} +$div_custom_fields = '
'; +foreach ($custom_fields as $custom_field) { + $custom_field_value = ''; + if (empty($ag_custom_fields) === false) { + $custom_field_value = $ag_custom_fields[$custom_field['id_field']]; + if (empty($custom_field_value) === true) { $custom_field_value = ''; - if (empty($ag_custom_fields) === false) { - $custom_field_value = $ag_custom_fields[$custom_field['id_field']]; - if (empty($custom_field_value) === true) { - $custom_field_value = ''; - } - } - - $row[1] = html_print_input_text('ag_custom_fields['.$custom_field['id_field'].']', $custom_field_value, '', 100, 300, true); - - $table_custom_fields->data[] = $row; } + } - $filters = '
'; + $div_custom_fields .= '
'; + $div_custom_fields .= '
'; + $div_custom_fields .= ''.$custom_field['name'].''; + $div_custom_fields .= '
'; - if (is_metaconsole() === true) { - $table->colspan[5][0] = 7; - $table->cellstyle[5][0] = 'padding: 10px;'; - $table->data[5][0] = ui_toggle( - html_print_table($table_custom_fields, true), - __('Advanced Options'), - '', - '', - true, - true - ); + $div_custom_fields .= '
'; + $div_custom_fields .= html_print_input_text( + 'ag_custom_fields['.$custom_field['id_field'].']', + $custom_field_value, + '', + 0, + 300, + true, + false, + false, + '', + 'div-input' + ); + $div_custom_fields .= '
'; - $filters .= html_print_table($table, true); - $filters .= ''; - ui_toggle($filters, __('Show filters'), '', '', false); - } else { - $table->colspan[5][0] = 7; - $table->cellstyle[5][0] = 'padding-left: 10px;'; - $table->data[5][0] = ui_toggle( - html_print_table( - $table_custom_fields, - true - ), - __('Agent custom fields'), - '', - '', - true, - true, - '', - 'white-box-content', - 'white_table_graph' - ); + $div_custom_fields .= '
'; +} - $filters .= html_print_table($table, true); - $filters .= ''; - echo $filters; +$div_custom_fields .= '
'; + +$filters = '
'; + +$table2->colspan[2][0] = 7; +$table2->cellstyle[2][0] = 'padding-left: 10px;'; +$table2->data[2][0] = ui_toggle( + $div_custom_fields, + __('Agent custom fields'), + '', + '', + true, + true, + '', + 'white-box-content', + 'white_table_graph' +); + +$table->colspan[3][0] = 7; +$table->cellstyle[3][0] = 'padding-left: 10px;padding-bottom: 0px;'; +$table->data[3][0] = ui_toggle( + html_print_table( + $table2, + true + ), + __('Advanced options'), + '', + '', + true, + true, + '', + 'white-box-content', + 'white_table_graph' +); + +$table->colspan[4][0] = 7; +$table->cellstyle[4][0] = 'padding-top: 0px;'; +$table->data[4][0] = html_print_submit_button( + __('Show'), + 'uptbutton', + false, + 'class="sub search mgn_tp_0 right"', + true +); + +$filters .= html_print_table($table, true); +$filters .= '
'; + +if (is_metaconsole() === true) { + ui_toggle($filters, __('Show filters'), '', '', false); +} else { + echo $filters; +} + +unset($table); +// End Build Search Form. +// +// Sort functionality. +$selected = true; +$selectAgentNameUp = false; +$selectAgentNameDown = false; +$selectDataTypeUp = false; +$selectDataTypeDown = false; +$selectTypeUp = false; +$selectTypeDown = false; +$selectModuleNameUp = false; +$selectModuleNameDown = false; +$selectIntervalUp = false; +$selectIntervalDown = false; +$selectStatusUp = false; +$selectStatusDown = false; +$selectDataUp = false; +$selectDataDown = false; +$selectTimestampUp = false; +$selectTimestampDown = false; +$order = null; + +switch ($sortField) { + case 'agent_alias': + switch ($sort) { + case 'up': + $selectAgentNameUp = $selected; + $order = [ + 'field' => 'tagente.alias', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectAgentNameDown = $selected; + $order = [ + 'field' => 'tagente.alias', + 'order' => 'DESC', + ]; + break; } + break; - unset($table); - // End Build Search Form. - // - // Sort functionality. - $selected = true; - $selectAgentNameUp = false; + case 'type': + switch ($sort) { + case 'up': + $selectDataTypeUp = $selected; + $order = [ + 'field' => 'tagente_modulo.id_tipo_modulo', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectDataTypeDown = $selected; + $order = [ + 'field' => 'tagente_modulo.id_tipo_modulo', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'moduletype': + switch ($sort) { + case 'up': + $selectTypeUp = $selected; + $order = [ + 'field' => 'tagente_modulo.id_modulo', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectTypeDown = $selected; + $order = [ + 'field' => 'tagente_modulo.id_modulo', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'module_name': + switch ($sort) { + case 'up': + $selectModuleNameUp = $selected; + $order = [ + 'field' => 'tagente_modulo.nombre', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectModuleNameDown = $selected; + $order = [ + 'field' => 'tagente_modulo.nombre', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'interval': + switch ($sort) { + case 'up': + $selectIntervalUp = $selected; + $order = [ + 'field' => 'tagente_modulo.module_interval', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectIntervalDown = $selected; + $order = [ + 'field' => 'tagente_modulo.module_interval', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'status': + switch ($sort) { + case 'up': + $selectStatusUp = $selected; + $order = [ + 'field' => 'tagente_estado.estado', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectStatusDown = $selected; + $order = [ + 'field' => 'tagente_estado.estado', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'last_status_change': + switch ($sort) { + case 'up': + $selectStatusUp = $selected; + $order = [ + 'field' => 'tagente_estado.last_status_change', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectStatusDown = $selected; + $order = [ + 'field' => 'tagente_estado.last_status_change', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'timestamp': + switch ($sort) { + case 'up': + $selectTimestampUp = $selected; + $order = [ + 'field' => 'tagente_estado.utimestamp', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectTimestampDown = $selected; + $order = [ + 'field' => 'tagente_estado.utimestamp', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'data': + switch ($sort) { + case 'up': + $selectDataUp = $selected; + $order = [ + 'field' => 'tagente_estado.datos', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectDataDown = $selected; + $order = [ + 'field' => 'tagente_estado.datos', + 'order' => 'DESC', + ]; + break; + } + break; + + default: + $selectAgentNameUp = $selected; $selectAgentNameDown = false; $selectDataTypeUp = false; $selectDataTypeDown = false; @@ -896,212 +1095,12 @@ $table->data[4][0] .= __('Not condition').' '.ui_print_help_tip(__('If you $selectDataDown = false; $selectTimestampUp = false; $selectTimestampDown = false; - $order = null; - - switch ($sortField) { - case 'agent_alias': - switch ($sort) { - case 'up': - $selectAgentNameUp = $selected; - $order = [ - 'field' => 'tagente.alias', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectAgentNameDown = $selected; - $order = [ - 'field' => 'tagente.alias', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'type': - switch ($sort) { - case 'up': - $selectDataTypeUp = $selected; - $order = [ - 'field' => 'tagente_modulo.id_tipo_modulo', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectDataTypeDown = $selected; - $order = [ - 'field' => 'tagente_modulo.id_tipo_modulo', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'moduletype': - switch ($sort) { - case 'up': - $selectTypeUp = $selected; - $order = [ - 'field' => 'tagente_modulo.id_modulo', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectTypeDown = $selected; - $order = [ - 'field' => 'tagente_modulo.id_modulo', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'module_name': - switch ($sort) { - case 'up': - $selectModuleNameUp = $selected; - $order = [ - 'field' => 'tagente_modulo.nombre', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectModuleNameDown = $selected; - $order = [ - 'field' => 'tagente_modulo.nombre', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'interval': - switch ($sort) { - case 'up': - $selectIntervalUp = $selected; - $order = [ - 'field' => 'tagente_modulo.module_interval', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectIntervalDown = $selected; - $order = [ - 'field' => 'tagente_modulo.module_interval', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'status': - switch ($sort) { - case 'up': - $selectStatusUp = $selected; - $order = [ - 'field' => 'tagente_estado.estado', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectStatusDown = $selected; - $order = [ - 'field' => 'tagente_estado.estado', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'last_status_change': - switch ($sort) { - case 'up': - $selectStatusUp = $selected; - $order = [ - 'field' => 'tagente_estado.last_status_change', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectStatusDown = $selected; - $order = [ - 'field' => 'tagente_estado.last_status_change', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'timestamp': - switch ($sort) { - case 'up': - $selectTimestampUp = $selected; - $order = [ - 'field' => 'tagente_estado.utimestamp', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectTimestampDown = $selected; - $order = [ - 'field' => 'tagente_estado.utimestamp', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'data': - switch ($sort) { - case 'up': - $selectDataUp = $selected; - $order = [ - 'field' => 'tagente_estado.datos', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectDataDown = $selected; - $order = [ - 'field' => 'tagente_estado.datos', - 'order' => 'DESC', - ]; - break; - } - break; - - default: - $selectAgentNameUp = $selected; - $selectAgentNameDown = false; - $selectDataTypeUp = false; - $selectDataTypeDown = false; - $selectTypeUp = false; - $selectTypeDown = false; - $selectModuleNameUp = false; - $selectModuleNameDown = false; - $selectIntervalUp = false; - $selectIntervalDown = false; - $selectStatusUp = false; - $selectStatusDown = false; - $selectDataUp = false; - $selectDataDown = false; - $selectTimestampUp = false; - $selectTimestampDown = false; - $order = [ - 'field' => 'tagente.alias', - 'order' => 'ASC', - ]; - break; - } + $order = [ + 'field' => 'tagente.alias', + 'order' => 'ASC', + ]; + break; +} $sql = 'SELECT (SELECT GROUP_CONCAT(ttag.name SEPARATOR \',\') @@ -1150,91 +1149,91 @@ $table->data[4][0] .= __('Not condition').' '.ui_print_help_tip(__('If you // We do not show the modules until the user searches with the filter. - if ($autosearch) { - if (! defined('METACONSOLE')) { - $result = db_get_all_rows_sql($sql); +if ($autosearch) { + if (! defined('METACONSOLE')) { + $result = db_get_all_rows_sql($sql); - if ($result === false) { - $result = []; - } else { - ui_pagination($count, false, $offset, 0, false, 'offset', true); - } - } else { - // For each server defined and not disabled. - $servers = db_get_all_rows_sql( - 'SELECT * + if ($result === false) { + $result = []; + } else { + ui_pagination($count, false, $offset, 0, false, 'offset', true); + } + } else { + // For each server defined and not disabled. + $servers = db_get_all_rows_sql( + 'SELECT * FROM tmetaconsole_setup WHERE disabled = 0' - ); - if ($servers === false) { - $servers = []; - } - - $result = []; - $count_modules = 0; - foreach ($servers as $server) { - // If connection was good then retrieve all data server. - if (metaconsole_connect($server) == NOERR) { - $connection = true; - } else { - $connection = false; - } - - $result_server = db_get_all_rows_sql($sql); - - if (!empty($result_server)) { - // Create HASH login info. - $pwd = $server['auth_token']; - $auth_serialized = json_decode($pwd, true); - - if (is_array($auth_serialized)) { - $pwd = $auth_serialized['auth_token']; - $api_password = $auth_serialized['api_password']; - $console_user = $auth_serialized['console_user']; - $console_password = $auth_serialized['console_password']; - } - - $user = $config['id_user']; - $user_rot13 = str_rot13($config['id_user']); - $hashdata = $user.$pwd; - $hashdata = md5($hashdata); - $url_hash = '&'.'loginhash=auto&'.'loginhash_data='.$hashdata.'&'.'loginhash_user='.$user_rot13; - - foreach ($result_server as $result_element_key => $result_element_value) { - $result_server[$result_element_key]['server_id'] = $server['id']; - $result_server[$result_element_key]['server_name'] = $server['server_name']; - $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; - $result_server[$result_element_key]['hashdata'] = $hashdata; - $result_server[$result_element_key]['user'] = $config['id_user']; - $result_server[$result_element_key]['groups_in_server'] = agents_get_all_groups_agent( - $result_element_value['id_agent'], - $result_element_value['id_group'] - ); - - $count_modules++; - } - - $result = array_merge($result, $result_server); - } - - metaconsole_restore_db(); - } - - if ($count_modules > $config['block_size']) { - ui_pagination($count_modules, false, $offset); - } - - // Get number of elements of the pagination. - $result = ui_meta_get_subset_array($result, $inferior_limit, $superior_limit); - } + ); + if ($servers === false) { + $servers = []; } - if (($config['dbtype'] == 'oracle') && ($result !== false)) { - for ($i = 0; $i < count($result); $i++) { - unset($result[$i]['rnum']); + $result = []; + $count_modules = 0; + foreach ($servers as $server) { + // If connection was good then retrieve all data server. + if (metaconsole_connect($server) == NOERR) { + $connection = true; + } else { + $connection = false; } + + $result_server = db_get_all_rows_sql($sql); + + if (!empty($result_server)) { + // Create HASH login info. + $pwd = $server['auth_token']; + $auth_serialized = json_decode($pwd, true); + + if (is_array($auth_serialized)) { + $pwd = $auth_serialized['auth_token']; + $api_password = $auth_serialized['api_password']; + $console_user = $auth_serialized['console_user']; + $console_password = $auth_serialized['console_password']; + } + + $user = $config['id_user']; + $user_rot13 = str_rot13($config['id_user']); + $hashdata = $user.$pwd; + $hashdata = md5($hashdata); + $url_hash = '&'.'loginhash=auto&'.'loginhash_data='.$hashdata.'&'.'loginhash_user='.$user_rot13; + + foreach ($result_server as $result_element_key => $result_element_value) { + $result_server[$result_element_key]['server_id'] = $server['id']; + $result_server[$result_element_key]['server_name'] = $server['server_name']; + $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; + $result_server[$result_element_key]['hashdata'] = $hashdata; + $result_server[$result_element_key]['user'] = $config['id_user']; + $result_server[$result_element_key]['groups_in_server'] = agents_get_all_groups_agent( + $result_element_value['id_agent'], + $result_element_value['id_group'] + ); + + $count_modules++; + } + + $result = array_merge($result, $result_server); + } + + metaconsole_restore_db(); } + if ($count_modules > $config['block_size']) { + ui_pagination($count_modules, false, $offset); + } + + // Get number of elements of the pagination. + $result = ui_meta_get_subset_array($result, $inferior_limit, $superior_limit); + } +} + +if (($config['dbtype'] == 'oracle') && ($result !== false)) { + for ($i = 0; $i < count($result); $i++) { + unset($result[$i]['rnum']); + } +} + // Urls to sort the table. $url_agent_name = 'index.php?sec='.$section.'&sec2=operation/agentes/status_monitor'; @@ -1284,570 +1283,553 @@ $table->data[4][0] .= __('Not condition').' '.ui_print_help_tip(__('If you $url_timestamp_down .= '&sort_field=timestamp&sort=down'; // Start Build List Result. - if (!empty($result)) { - $table = new StdClass(); - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->width = '100%'; - $table->class = 'info_table'; - $table->head = []; - $table->data = []; - $table->size = []; - $table->align = []; +if (!empty($result)) { + $table = new StdClass(); + $table->cellpadding = 0; + $table->cellspacing = 0; + $table->width = '100%'; + $table->class = 'info_table'; + $table->head = []; + $table->data = []; + $table->size = []; + $table->align = []; - $show_fields = explode(',', $config['status_monitor_fields']); + $show_fields = explode(',', $config['status_monitor_fields']); - if (in_array('policy', $show_fields)) { - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - $table->head[0] = ''.__('P.').''; - } - } + if (in_array('policy', $show_fields)) { + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { + $table->head[0] = ''.__('P.').''; + } + } - if (in_array('agent', $show_fields) || is_metaconsole()) { - $table->head[1] = __('Agent'); - $table->head[1] .= ui_get_sorting_arrows($url_agent_name.'up', $url_agent_name.'down', $selectAgentNameUp, $selectAgentNameDown); - } + if (in_array('agent', $show_fields) || is_metaconsole()) { + $table->head[1] = __('Agent'); + $table->head[1] .= ui_get_sorting_arrows($url_agent_name.'up', $url_agent_name.'down', $selectAgentNameUp, $selectAgentNameDown); + } - if (in_array('data_type', $show_fields) || is_metaconsole()) { - $table->head[2] = __('Data Type'); - $table->head[2] .= ui_get_sorting_arrows($url_type.'up', $url_type.'down', $selectDataTypeUp, $selectDataTypeDown); - $table->align[2] = 'left'; - } + if (in_array('data_type', $show_fields) || is_metaconsole()) { + $table->head[2] = __('Data Type'); + $table->head[2] .= ui_get_sorting_arrows($url_type.'up', $url_type.'down', $selectDataTypeUp, $selectDataTypeDown); + $table->align[2] = 'left'; + } - if (in_array('module_name', $show_fields) || is_metaconsole()) { - $table->head[3] = __('Module name'); - $table->head[3] .= ui_get_sorting_arrows($url_module_name.'up', $url_module_name.'down', $selectModuleNameUp, $selectModuleNameDown); - } + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $table->head[3] = __('Module name'); + $table->head[3] .= ui_get_sorting_arrows($url_module_name.'up', $url_module_name.'down', $selectModuleNameUp, $selectModuleNameDown); + } - if (in_array('server_type', $show_fields) || is_metaconsole()) { - $table->head[4] = __('Server type'); - $table->head[4] .= ui_get_sorting_arrows($url_server_type.'up', $url_server_type.'down', $selectTypeUp, $selectTypeDown); - } + if (in_array('server_type', $show_fields) || is_metaconsole()) { + $table->head[4] = __('Server type'); + $table->head[4] .= ui_get_sorting_arrows($url_server_type.'up', $url_server_type.'down', $selectTypeUp, $selectTypeDown); + } - if (in_array('interval', $show_fields) || is_metaconsole()) { - $table->head[5] = __('Interval'); - $table->head[5] .= ui_get_sorting_arrows($url_interval.'up', $url_interval.'down', $selectIntervalUp, $selectIntervalDown); - $table->align[5] = 'left'; - } + if (in_array('interval', $show_fields) || is_metaconsole()) { + $table->head[5] = __('Interval'); + $table->head[5] .= ui_get_sorting_arrows($url_interval.'up', $url_interval.'down', $selectIntervalUp, $selectIntervalDown); + $table->align[5] = 'left'; + } - if (in_array('status', $show_fields) || is_metaconsole()) { - $table->head[6] = __('Status'); - $table->head[6] .= ui_get_sorting_arrows($url_status.'up', $url_status.'down', $selectStatusUp, $selectStatusDown); - $table->align[6] = 'left'; - } + if (in_array('status', $show_fields) || is_metaconsole()) { + $table->head[6] = __('Status'); + $table->head[6] .= ui_get_sorting_arrows($url_status.'up', $url_status.'down', $selectStatusUp, $selectStatusDown); + $table->align[6] = 'left'; + } - if (in_array('last_status_change', $show_fields)) { - $table->head[7] = __('Last status change'); - $table->head[7] .= ui_get_sorting_arrows($url_status.'up', $url_status.'down', $selectStatusUp, $selectStatusDown); - $table->align[7] = 'left'; - } + if (in_array('last_status_change', $show_fields)) { + $table->head[7] = __('Last status change'); + $table->head[7] .= ui_get_sorting_arrows($url_status.'up', $url_status.'down', $selectStatusUp, $selectStatusDown); + $table->align[7] = 'left'; + } - if (in_array('graph', $show_fields) || is_metaconsole()) { - $table->head[8] = __('Graph'); - $table->align[8] = 'left'; - } + if (in_array('graph', $show_fields) || is_metaconsole()) { + $table->head[8] = __('Graph'); + $table->align[8] = 'left'; + } - if (in_array('warn', $show_fields) || is_metaconsole()) { - $table->head[9] = __('Warn'); - $table->align[9] = 'left'; - } + if (in_array('warn', $show_fields) || is_metaconsole()) { + $table->head[9] = __('Warn'); + $table->align[9] = 'left'; + } - if (in_array('data', $show_fields) || is_metaconsole()) { - $table->head[10] = __('Data'); - $table->align[10] = 'left'; + if (in_array('data', $show_fields) || is_metaconsole()) { + $table->head[10] = __('Data'); + $table->align[10] = 'left'; + if (is_metaconsole()) { + $table->head[10] .= ui_get_sorting_arrows($url_data.'up', $url_data.'down', $selectDataUp, $selectDataDown); + } + } + + if (in_array('timestamp', $show_fields) || is_metaconsole()) { + $table->head[11] = __('Timestamp'); + $table->head[11] .= ui_get_sorting_arrows($url_timestamp_up, $url_timestamp_down, $selectTimestampUp, $selectTimestampDown); + $table->align[11] = 'left'; + } + + $id_type_web_content_string = db_get_value( + 'id_tipo', + 'ttipo_modulo', + 'nombre', + 'web_content_string' + ); + + foreach ($result as $row) { + // Avoid unset, null and false value. + if (empty($row['server_name'])) { + $row['server_name'] = ''; + } + + $is_web_content_string = (bool) db_get_value_filter( + 'id_agente_modulo', + 'tagente_modulo', + [ + 'id_agente_modulo' => $row['id_agente_modulo'], + 'id_tipo_modulo' => $id_type_web_content_string, + ] + ); + + // Fixed the goliat sends the strings from web. + // Without HTML entities. + if ($is_web_content_string) { + $row['datos'] = io_safe_input($row['datos']); + } + + // Fixed the data from Selenium Plugin. + if ($row['datos'] != strip_tags($row['datos'])) { + $row['datos'] = io_safe_input($row['datos']); + } + + $data = []; + + if (in_array('policy', $show_fields) || is_metaconsole()) { + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if (is_metaconsole()) { - $table->head[10] .= ui_get_sorting_arrows($url_data.'up', $url_data.'down', $selectDataUp, $selectDataDown); - } - } - - if (in_array('timestamp', $show_fields) || is_metaconsole()) { - $table->head[11] = __('Timestamp'); - $table->head[11] .= ui_get_sorting_arrows($url_timestamp_up, $url_timestamp_down, $selectTimestampUp, $selectTimestampDown); - $table->align[11] = 'left'; - } - - $id_type_web_content_string = db_get_value( - 'id_tipo', - 'ttipo_modulo', - 'nombre', - 'web_content_string' - ); - - foreach ($result as $row) { - // Avoid unset, null and false value. - if (empty($row['server_name'])) { - $row['server_name'] = ''; + $node = metaconsole_get_connection_by_id($row['server_id']); + if (metaconsole_load_external_db($node) !== NOERR) { + // Restore the default connection. + metaconsole_restore_db(); + $errors++; + break; + } } - $is_web_content_string = (bool) db_get_value_filter( - 'id_agente_modulo', - 'tagente_modulo', + $policyInfo = policies_info_module_policy($row['id_agente_modulo']); + + if ($policyInfo === false) { + $data[0] = ''; + } else { + $linked = policies_is_module_linked($row['id_agente_modulo']); + + $adopt = false; + if (policies_is_module_adopt($row['id_agente_modulo'])) { + $adopt = true; + } + + if ($linked) { + if ($adopt) { + $img = 'images/policies_brick.png'; + $title = __('(Adopt) ').$policyInfo['name_policy']; + } else { + $img = 'images/policies_mc.png'; + $title = $policyInfo['name_policy']; + } + } else { + if ($adopt) { + $img = 'images/policies_not_brick.png'; + $title = __('(Unlinked) (Adopt) ').$policyInfo['name_policy']; + } else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ').$policyInfo['name_policy']; + } + } + + if (is_metaconsole()) { + $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; + } else { + $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; + } + } + + if (is_metaconsole()) { + metaconsole_restore_db(); + } + } + } + + if (in_array('agent', $show_fields) || is_metaconsole()) { + $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; + + // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view + if (defined('METACONSOLE')) { + $agent_link = ''; + $agent_alias = ui_print_truncate_text( + $agent_alias, + 'agent_small', + false, + true, + false, + '[…]', + 'font-size:7.5pt;' + ); + if (can_user_access_node()) { + $data[1] = $agent_link.''.$agent_alias.''; + } else { + $data[1] = $agent_alias; + } + } else { + $data[1] = ''; + $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;'); + $data[1] .= ''; + } + } + + if (in_array('data_type', $show_fields) || is_metaconsole()) { + $data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true, ['class' => 'invert_filter']); + $agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); + if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) { + $show_edit_icon = true; + if (defined('METACONSOLE')) { + if (!can_user_access_node()) { + $show_edit_icon = false; + } + + $url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']); + } else { + $url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'; + } + + if ($show_edit_icon) { + $table->cellclass[][2] = 'action_buttons'; + $data[2] .= ''.html_print_image( + 'images/config.png', + true, + [ + 'alt' => '0', + 'border' => '', + 'title' => __('Edit'), + ] + ).''; + } + } + } + + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $data[3] = ui_print_truncate_text($row['module_name'], 'module_small', false, true, true); + if ($row['extended_info'] != '') { + $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); + } + + if ($row['tags'] != '') { + $data[3] .= html_print_image( + '/images/tag_red.png', + true, [ - 'id_agente_modulo' => $row['id_agente_modulo'], - 'id_tipo_modulo' => $id_type_web_content_string, + 'title' => $row['tags'], + 'class' => 'tag_row', ] ); + } + } - // Fixed the goliat sends the strings from web. - // Without HTML entities. - if ($is_web_content_string) { - $row['datos'] = io_safe_input($row['datos']); - } - - // Fixed the data from Selenium Plugin. - if ($row['datos'] != strip_tags($row['datos'])) { - $row['datos'] = io_safe_input($row['datos']); - } - - $data = []; - - if (in_array('policy', $show_fields) || is_metaconsole()) { - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - if (is_metaconsole()) { - $node = metaconsole_get_connection_by_id($row['server_id']); - if (metaconsole_load_external_db($node) !== NOERR) { - // Restore the default connection. - metaconsole_restore_db(); - $errors++; - break; - } - } - - $policyInfo = policies_info_module_policy($row['id_agente_modulo']); - - if ($policyInfo === false) { - $data[0] = ''; - } else { - $linked = policies_is_module_linked($row['id_agente_modulo']); - - $adopt = false; - if (policies_is_module_adopt($row['id_agente_modulo'])) { - $adopt = true; - } - - if ($linked) { - if ($adopt) { - $img = 'images/policies_brick.png'; - $title = __('(Adopt) ').$policyInfo['name_policy']; - } else { - $img = 'images/policies_mc.png'; - $title = $policyInfo['name_policy']; - } - } else { - if ($adopt) { - $img = 'images/policies_not_brick.png'; - $title = __('(Unlinked) (Adopt) ').$policyInfo['name_policy']; - } else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ').$policyInfo['name_policy']; - } - } - - if (is_metaconsole()) { - $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; - } else { - $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; - } - } - - if (is_metaconsole()) { - metaconsole_restore_db(); - } - } - } - - if (in_array('agent', $show_fields) || is_metaconsole()) { - $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; - - // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view - if (defined('METACONSOLE')) { - $agent_link = ''; - $agent_alias = ui_print_truncate_text( - $agent_alias, - 'agent_small', - false, - true, - false, - '[…]', - 'font-size:7.5pt;' - ); - if (can_user_access_node()) { - $data[1] = $agent_link.''.$agent_alias.''; - } else { - $data[1] = $agent_alias; - } - } else { - $data[1] = ''; - $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;'); - $data[1] .= ''; - } - } - - if (in_array('data_type', $show_fields) || is_metaconsole()) { - $data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true, ['class' => 'invert_filter']); - $agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); - if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) { - $show_edit_icon = true; - if (defined('METACONSOLE')) { - if (!can_user_access_node()) { - $show_edit_icon = false; - } - - $url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']); - } else { - $url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'; - } - - if ($show_edit_icon) { - $table->cellclass[][2] = 'action_buttons'; - $data[2] .= ''.html_print_image( - 'images/config.png', - true, - [ - 'alt' => '0', - 'border' => '', - 'title' => __('Edit'), - ] - ).''; - } - } - } - - if (in_array('module_name', $show_fields) || is_metaconsole()) { - $data[3] = ui_print_truncate_text($row['module_name'], 'module_small', false, true, true); - if ($row['extended_info'] != '') { - $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); - } - - if ($row['tags'] != '') { - $data[3] .= html_print_image( - '/images/tag_red.png', - true, - [ - 'title' => $row['tags'], - 'class' => 'tag_row', - ] - ); - } - } - - if (in_array('server_type', $show_fields) || is_metaconsole()) { - $data[4] = servers_show_type($row['id_modulo']); - } + if (in_array('server_type', $show_fields) || is_metaconsole()) { + $data[4] = servers_show_type($row['id_modulo']); + } - if (in_array('module_name', $show_fields) || is_metaconsole()) { - $data[3] = ui_print_truncate_text($row['module_name'], 'module_small', false, true, true); - if ($row['extended_info'] != '') { - $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); - } + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $data[3] = ui_print_truncate_text($row['module_name'], 'module_small', false, true, true); + if ($row['extended_info'] != '') { + $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); + } - if ($row['tags'] != '') { - $data[3] .= html_print_image( - '/images/tag_red.png', - true, - [ - 'title' => $row['tags'], - 'class' => 'tag_row invert_filter', - ] - ); - } - } + if ($row['tags'] != '') { + $data[3] .= html_print_image( + '/images/tag_red.png', + true, + [ + 'title' => $row['tags'], + 'class' => 'tag_row invert_filter', + ] + ); + } + } - if (in_array('server_type', $show_fields) || is_metaconsole()) { - $data[4] = servers_show_type($row['id_modulo']); - } + if (in_array('server_type', $show_fields) || is_metaconsole()) { + $data[4] = servers_show_type($row['id_modulo']); + } - if (in_array('interval', $show_fields) || is_metaconsole()) { - $data[5] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); - } + if (in_array('interval', $show_fields) || is_metaconsole()) { + $data[5] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); + } - if (in_array('status', $show_fields) || is_metaconsole()) { - if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 - || $row['module_type'] > 23) && $row['module_type'] != 100) - ) { - $data[6] = ui_print_status_image( - STATUS_MODULE_NO_DATA, - __('NOT INIT'), - true - ); - } else if ($row['estado'] == 0) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_OK, - __('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_OK, - __('NORMAL').': '.htmlspecialchars($row['datos']), - true - ); - } - } else if ($row['estado'] == 1) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_CRITICAL, - __('CRITICAL').': '.remove_right_zeros( - number_format($row['datos'], $config['graph_precision']) - ), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_CRITICAL, - __('CRITICAL').': '.htmlspecialchars($row['datos']), - true - ); - } - } else if ($row['estado'] == 2) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_WARNING, - __('WARNING').': '.remove_right_zeros( - number_format($row['datos'], $config['graph_precision']) - ), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_WARNING, - __('WARNING').': '.htmlspecialchars($row['datos']), - true - ); - } - } else if ($row['estado'] == 3) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').': '.remove_right_zeros( - number_format($row['datos'], $config['graph_precision']) - ), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').': '.htmlspecialchars($row['datos']), - true - ); - } - } else if ($row['estado'] == 4) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_NO_DATA, - __('NO DATA').': '.remove_right_zeros( - number_format($row['datos'], $config['graph_precision']) - ), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_NO_DATA, - __('NO DATA').': '.htmlspecialchars($row['datos']), - true - ); - } - } else { - $last_status = modules_get_agentmodule_last_status( - $row['id_agente_modulo'] - ); - switch ($last_status) { - case 0: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.htmlspecialchars($row['datos']), - true - ); - } - break; - - case 1: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.htmlspecialchars($row['datos']), - true - ); - } - break; - - case 2: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.htmlspecialchars($row['datos']), - true - ); - } - break; - } - } - } - - if (in_array('last_status_change', $show_fields) || is_metaconsole()) { - $data[7] = ($row['last_status_change'] > 0) ? human_time_comparation($row['last_status_change']) : __('N/A'); - } - - if (in_array('graph', $show_fields) || is_metaconsole()) { - $data[8] = ''; - - $acl_graphs = false; - - // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions. - if (!is_metaconsole()) { - $agent_groups = agents_get_all_groups_agent($row['id_agent'], $row['id_group']); - $acl_graphs = check_acl_one_of_groups($config['id_user'], $agent_groups, 'RR'); - } else { - $acl_graphs = true; - } - - if ($row['history_data'] == 1 && $acl_graphs) { - $tresholds = true; - if (empty((float) $module['min_warning']) === true - && empty((float) $module['max_warning']) === true - && empty($module['warning_inverse']) === true - && empty((float) $module['min_critical']) === true - && empty((float) $module['max_critical']) === true - && empty($module['critical_inverse']) === true - ) { - $tresholds = false; - } - - $graph_type = return_graphtype($row['module_type']); - - $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); - $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); - $win_handle = 'day_'.$handle; - - $graph_params = [ - 'type' => $graph_type, - 'period' => SECONDS_1DAY, - 'id' => $row['id_agente_modulo'], - 'refresh' => SECONDS_10MINUTES, - ]; - - if ($tresholds === true || $graph_type === 'boolean') { - $graph_params['histogram'] = 1; - } - - if (is_metaconsole() && isset($row['server_id'])) { - // Set the server id. - $graph_params['server'] = $row['server_id']; - } - - $graph_params_str = http_build_query($graph_params); - - $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; - - $data[8] = get_module_realtime_link_graph($row); - - if ($tresholds === true || $graph_type === 'boolean') { - $data[8] .= ''.html_print_image( - 'images/histograma.png', - true, - [ - 'border' => '0', - 'alt' => '', - 'class' => 'invert_filter', - ] - ).''; - } - - if (!is_snapshot_data($row['datos'])) { - if ($tresholds === true || $graph_type === 'boolean') { - unset($graph_params['histogram']); - } - - $graph_params_str = http_build_query($graph_params); - - $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; - $data[8] .= ''.html_print_image('images/chart.png', true, ['border' => '0', 'alt' => '', 'class' => 'invert_filter']).''; - } - - $data[8] .= ''.html_print_image( - 'images/binary.png', - true, - [ - 'border' => '0', - 'alt' => '', - 'class' => 'invert_filter', - ] - ).''; - - $data[8] .= ''.$row['module_name'].''; - } - } - - if (in_array('warn', $show_fields) || is_metaconsole()) { - $data[9] = ui_print_module_warn_value( - $row['max_warning'], - $row['min_warning'], - $row['str_warning'], - $row['max_critical'], - $row['min_critical'], - $row['str_critical'], - $row['warning_inverse'], - $row['critical_inverse'] + if (in_array('status', $show_fields) || is_metaconsole()) { + if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 + || $row['module_type'] > 23) && $row['module_type'] != 100) + ) { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NOT INIT'), + true + ); + } else if ($row['estado'] == 0) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_OK, + __('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true ); - - if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { - if ($config['render_proc']) { - switch ($row['module_type']) { - case 2: - case 6: - case 9: - case 18: - case 21: - case 31: - if ($row['datos'] >= 1) { - $salida = $config['render_proc_ok']; - } else { - $salida = $config['render_proc_fail']; - } - break; - - default: - switch ($row['module_type']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - $salida = human_milliseconds_to_string($row['datos']); - } else { - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - } - break; - - default: - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; - } - break; - } + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_OK, + __('NORMAL').': '.htmlspecialchars($row['datos']), + true + ); + } + } else if ($row['estado'] == 1) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_CRITICAL, + __('CRITICAL').': '.remove_right_zeros( + number_format($row['datos'], $config['graph_precision']) + ), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_CRITICAL, + __('CRITICAL').': '.htmlspecialchars($row['datos']), + true + ); + } + } else if ($row['estado'] == 2) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_WARNING, + __('WARNING').': '.remove_right_zeros( + number_format($row['datos'], $config['graph_precision']) + ), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_WARNING, + __('WARNING').': '.htmlspecialchars($row['datos']), + true + ); + } + } else if ($row['estado'] == 3) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').': '.remove_right_zeros( + number_format($row['datos'], $config['graph_precision']) + ), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').': '.htmlspecialchars($row['datos']), + true + ); + } + } else if ($row['estado'] == 4) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NO DATA').': '.remove_right_zeros( + number_format($row['datos'], $config['graph_precision']) + ), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NO DATA').': '.htmlspecialchars($row['datos']), + true + ); + } + } else { + $last_status = modules_get_agentmodule_last_status( + $row['id_agente_modulo'] + ); + switch ($last_status) { + case 0: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.htmlspecialchars($row['datos']), + true + ); + } + break; + + case 1: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.htmlspecialchars($row['datos']), + true + ); + } + break; + + case 2: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.htmlspecialchars($row['datos']), + true + ); + } + break; + } + } + } + + if (in_array('last_status_change', $show_fields) || is_metaconsole()) { + $data[7] = ($row['last_status_change'] > 0) ? human_time_comparation($row['last_status_change']) : __('N/A'); + } + + if (in_array('graph', $show_fields) || is_metaconsole()) { + $data[8] = ''; + + $acl_graphs = false; + + // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions. + if (!is_metaconsole()) { + $agent_groups = agents_get_all_groups_agent($row['id_agent'], $row['id_group']); + $acl_graphs = check_acl_one_of_groups($config['id_user'], $agent_groups, 'RR'); + } else { + $acl_graphs = true; + } + + if ($row['history_data'] == 1 && $acl_graphs) { + $tresholds = true; + if (empty((float) $module['min_warning']) === true + && empty((float) $module['max_warning']) === true + && empty($module['warning_inverse']) === true + && empty((float) $module['min_critical']) === true + && empty((float) $module['max_critical']) === true + && empty($module['critical_inverse']) === true + ) { + $tresholds = false; + } + + $graph_type = return_graphtype($row['module_type']); + + $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); + $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); + $win_handle = 'day_'.$handle; + + $graph_params = [ + 'type' => $graph_type, + 'period' => SECONDS_1DAY, + 'id' => $row['id_agente_modulo'], + 'refresh' => SECONDS_10MINUTES, + ]; + + if ($tresholds === true || $graph_type === 'boolean') { + $graph_params['histogram'] = 1; + } + + if (is_metaconsole() && isset($row['server_id'])) { + // Set the server id. + $graph_params['server'] = $row['server_id']; + } + + $graph_params_str = http_build_query($graph_params); + + $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; + + $data[8] = get_module_realtime_link_graph($row); + + if ($tresholds === true || $graph_type === 'boolean') { + $data[8] .= ''.html_print_image( + 'images/histograma.png', + true, + [ + 'border' => '0', + 'alt' => '', + 'class' => 'invert_filter', + ] + ).''; + } + + if (!is_snapshot_data($row['datos'])) { + if ($tresholds === true || $graph_type === 'boolean') { + unset($graph_params['histogram']); + } + + $graph_params_str = http_build_query($graph_params); + + $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; + $data[8] .= ''.html_print_image('images/chart.png', true, ['border' => '0', 'alt' => '', 'class' => 'invert_filter']).''; + } + + $data[8] .= ''.html_print_image( + 'images/binary.png', + true, + [ + 'border' => '0', + 'alt' => '', + 'class' => 'invert_filter', + ] + ).''; + + $data[8] .= ''.$row['module_name'].''; + } + } + + if (in_array('warn', $show_fields) || is_metaconsole()) { + $data[9] = ui_print_module_warn_value( + $row['max_warning'], + $row['min_warning'], + $row['str_warning'], + $row['max_critical'], + $row['min_critical'], + $row['str_critical'], + $row['warning_inverse'], + $row['critical_inverse'] + ); + + if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { + if ($config['render_proc']) { + switch ($row['module_type']) { + case 2: + case 6: + case 9: + case 18: + case 21: + case 31: + if ($row['datos'] >= 1) { + $salida = $config['render_proc_ok']; + } else { + $salida = $config['render_proc_fail']; + } + break; + + default: switch ($row['module_type']) { case 15: $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); @@ -1862,128 +1844,145 @@ $table->data[4][0] .= __('Not condition').' '.ui_print_help_tip(__('If you $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); break; } - } + break; + } + } else { + switch ($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { + $salida = human_milliseconds_to_string($row['datos']); + } else { + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + } + break; - // Show units ONLY in numeric data types. - if (isset($row['unit'])) { + default: + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + } + } + + // Show units ONLY in numeric data types. + if (isset($row['unit'])) { + $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); + if ($data_macro) { + $salida = $data_macro; + } else { + $salida .= ' '.''.io_safe_output($row['unit']).''; + if (strlen($salida) > $config['agent_size_text_small']) { + $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); + // Clean tag . + $text_aux = explode(' $row['id_agente_modulo'], + 'interval' => $row['current_interval'], + 'module_name' => $row['module_name'], + 'id_node' => $row['server_id'], + ] + ); + $salida = ui_get_snapshot_image($link, $is_snapshot).'  '; + } else { + $sub_string = substr(io_safe_output($row['datos']), 0, 12); + if ($module_value == $sub_string) { + if ($module_value == 0 && !$sub_string) { + $salida = 0; + } else { $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); if ($data_macro) { $salida = $data_macro; } else { - $salida .= ' '.''.io_safe_output($row['unit']).''; - if (strlen($salida) > $config['agent_size_text_small']) { - $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); - // Clean tag . - $text_aux = explode(' $row['id_agente_modulo'], - 'interval' => $row['current_interval'], - 'module_name' => $row['module_name'], - 'id_node' => $row['server_id'], - ] - ); - $salida = ui_get_snapshot_image($link, $is_snapshot).'  '; - } else { - $sub_string = substr(io_safe_output($row['datos']), 0, 12); - if ($module_value == $sub_string) { - if ($module_value == 0 && !$sub_string) { - $salida = 0; - } else { - $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); - if ($data_macro) { - $salida = $data_macro; - } else { - $salida = $row['datos']; - } - } + // Fixed the data from Selenium Plugin. + if ($module_value != strip_tags($module_value)) { + $module_value = io_safe_input($module_value); + $sub_string = substr($row['datos'], 0, 12); } else { - // Fixed the goliat sends the strings from web. - // Without HTML entities. - if ($is_web_content_string) { - $sub_string = substr($row['datos'], 0, 12); - } else { - // Fixed the data from Selenium Plugin. - if ($module_value != strip_tags($module_value)) { - $module_value = io_safe_input($module_value); - $sub_string = substr($row['datos'], 0, 12); - } else { - $sub_string = substr(io_safe_output($row['datos']), 0, 12); - } - } - - if ($module_value == $sub_string) { - $salida = $module_value; - } else { - $salida = ''.'".''.$sub_string.' '."".html_print_image('images/rosette.png', true).''; - } + $sub_string = substr(io_safe_output($row['datos']), 0, 12); } } + + if ($module_value == $sub_string) { + $salida = $module_value; + } else { + $salida = ''.'".''.$sub_string.' '."".html_print_image('images/rosette.png', true).''; + } } } - - if (in_array('data', $show_fields) || is_metaconsole()) { - $data[10] = $salida; - } - - if (in_array('timestamp', $show_fields) || is_metaconsole()) { - if ($row['module_interval'] > 0) { - $interval = $row['module_interval']; - } else { - $interval = $row['agent_interval']; - } - - if ($row['estado'] == 3) { - $option = [ - 'html_attr' => 'class="redb"', - 'style' => 'font-size:7pt;', - ]; - } else { - $option = ['style' => 'font-size:7pt;']; - } - - $data[11] = ui_print_timestamp($row['utimestamp'], true, $option); - } - - array_push($table->data, $data); - } - - html_print_table($table); - - - if ($count_modules > $config['block_size']) { - ui_pagination($count_modules, false, $offset, 0, false, 'offset', true, 'pagination-bottom'); - } - } else { - if ($first_interaction) { - ui_print_info_message(['no_close' => true, 'message' => __('This group doesn\'t have any monitor')]); - } else { - ui_print_info_message(['no_close' => true, 'message' => __('Sorry no search parameters')]); } } + if (in_array('data', $show_fields) || is_metaconsole()) { + $data[10] = $salida; + } + + if (in_array('timestamp', $show_fields) || is_metaconsole()) { + if ($row['module_interval'] > 0) { + $interval = $row['module_interval']; + } else { + $interval = $row['agent_interval']; + } + + if ($row['estado'] == 3) { + $option = [ + 'html_attr' => 'class="redb"', + 'style' => 'font-size:7pt;', + ]; + } else { + $option = ['style' => 'font-size:7pt;']; + } + + $data[11] = ui_print_timestamp($row['utimestamp'], true, $option); + } + + array_push($table->data, $data); + } + + html_print_table($table); + + + if ($count_modules > $config['block_size']) { + ui_pagination($count_modules, false, $offset, 0, false, 'offset', true, 'pagination-bottom'); + } +} else { + if ($first_interaction) { + ui_print_info_message(['no_close' => true, 'message' => __('This group doesn\'t have any monitor')]); + } else { + ui_print_info_message(['no_close' => true, 'message' => __('Sorry no search parameters')]); + } +} + // End Build List Result. echo "
"; @@ -1992,7 +1991,7 @@ $table->data[4][0] .= __('Not condition').' '.ui_print_help_tip(__('If you ui_require_javascript_file('pandora_modules'); - ?> +?>