diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 9af85a5200..1cb5919e19 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769, AIX version +# Version 7.0NG.770, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 6650404c74..c827c75d6d 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769, FreeBSD Version +# Version 7.0NG.770, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 957396affa..71e67359c1 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769, HP-UX Version +# Version 7.0NG.770, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index dac6aefc04..e9880484e0 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769, GNU/Linux +# Version 7.0NG.770, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index a12c8ccce7..4f76a73783 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769, GNU/Linux +# Version 7.0NG.770, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 75ff20dba4..1e5799ca06 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769, Solaris Version +# Version 7.0NG.770, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 6fca0a4523..4d0a3d6265 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2021 Artica Soluciones Tecnologicas -# Version 7.0NG.769 +# Version 7.0NG.770 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software # Foundation; either version 2 of the Licence or any later version diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index e47ec5442a..e60047ed0a 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.769, AIX version +# Version 7.0NG.770, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index bc353d4077..1ca3879a6b 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.769 +# Version 7.0NG.770 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 7e9f290fd0..35b0073d56 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.769, HPUX Version +# Version 7.0NG.770, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 674d2a3992..d3d9b2ed6d 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769 +# Version 7.0NG.770 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 9654e1f2ee..6ebf8f56cf 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769 +# Version 7.0NG.770 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 4fc7cf3202..42724a87d9 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769 +# Version 7.0NG.770 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index 2113795918..0ec36d0a34 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.769, Solaris version +# Version 7.0NG.770, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index b02f88017e..951a9c4d87 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.769, AIX version +# Version 7.0NG.770, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 5a6b6e4894..d165592662 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.769-230310 +Version: 7.0NG.770-230328 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 0ff5c31c0b..ca1b28074c 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.769-230310" +pandora_version="7.0NG.770-230328" 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/Darwin/dmg/build_darwin_dmg.sh b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh index b8862d3ee9..1596fa44c8 100644 --- a/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh +++ b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh @@ -31,7 +31,7 @@ fi if [ "$#" -ge 2 ]; then VERSION="$2" else - VERSION="7.0NG.769" + VERSION="7.0NG.770" fi # Path for the generated DMG file diff --git a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml index f1aebe06a1..163a0acd59 100644 --- a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml +++ b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml @@ -19,11 +19,11 @@ - pandorafms_src.pdk + pandorafms_src.pdk - pandorafms_uninstall.pdk + pandorafms_uninstall.pdk + Dark / 20 / file-csv@svg + Created with Sketch. + + + + + + \ No newline at end of file diff --git a/pandora_console/images/menu/fav_menu_gray.svg b/pandora_console/images/menu/fav_menu_gray.svg new file mode 100644 index 0000000000..8a894d7948 --- /dev/null +++ b/pandora_console/images/menu/fav_menu_gray.svg @@ -0,0 +1,9 @@ + + + + Dark / 20 / star@svg + Created with Sketch. + + + + \ No newline at end of file diff --git a/pandora_console/images/nodes@svg.svg b/pandora_console/images/nodes@svg.svg new file mode 100644 index 0000000000..b97a133d73 --- /dev/null +++ b/pandora_console/images/nodes@svg.svg @@ -0,0 +1,23 @@ + + + + A4F45784-4263-40A4-A100-0ADD2A4AF526@svg + Created with sketchtool. + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/plus@svg.svg b/pandora_console/images/plus@svg.svg new file mode 100644 index 0000000000..bb528c8ad7 --- /dev/null +++ b/pandora_console/images/plus@svg.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/pandora_console/images/refresh@svg.svg b/pandora_console/images/refresh@svg.svg new file mode 100644 index 0000000000..bead6c6a97 --- /dev/null +++ b/pandora_console/images/refresh@svg.svg @@ -0,0 +1,20 @@ + + + + 312C8F68-5915-4989-BCE0-E39966548B2E@svg + Created with sketchtool. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/star_fav_menu.png b/pandora_console/images/star_fav_menu.png new file mode 100644 index 0000000000..5d1521f202 Binary files /dev/null and b/pandora_console/images/star_fav_menu.png differ diff --git a/pandora_console/images/status_dot.svg b/pandora_console/images/status_dot.svg new file mode 100644 index 0000000000..3e9c8b2ead --- /dev/null +++ b/pandora_console/images/status_dot.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pandora_console/images/widgets/AvgSumMaxMinModule.png b/pandora_console/images/widgets/AvgSumMaxMinModule.png new file mode 100644 index 0000000000..19e980f38d Binary files /dev/null and b/pandora_console/images/widgets/AvgSumMaxMinModule.png differ diff --git a/pandora_console/images/widgets/ModulesByStatus.png b/pandora_console/images/widgets/ModulesByStatus.png new file mode 100644 index 0000000000..796ff6382a Binary files /dev/null and b/pandora_console/images/widgets/ModulesByStatus.png differ diff --git a/pandora_console/images/widgets/heatmap.png b/pandora_console/images/widgets/heatmap.png new file mode 100644 index 0000000000..f16f8eb992 Binary files /dev/null and b/pandora_console/images/widgets/heatmap.png differ diff --git a/pandora_console/images/world@svg.svg b/pandora_console/images/world@svg.svg new file mode 100644 index 0000000000..c71297eda4 --- /dev/null +++ b/pandora_console/images/world@svg.svg @@ -0,0 +1,9 @@ + + + + Dark / 20 / web@svg + Created with Sketch. + + + + \ No newline at end of file diff --git a/pandora_console/include/ajax/double_auth.ajax.php b/pandora_console/include/ajax/double_auth.ajax.php index 3a995ce43a..54856a26c3 100644 --- a/pandora_console/include/ajax/double_auth.ajax.php +++ b/pandora_console/include/ajax/double_auth.ajax.php @@ -216,11 +216,8 @@ if ($get_double_auth_info_page) { $html .= '

'; $html .= ''; $html .= '
'; - $html .= '
'; + $html .= '
'; $html .= html_print_button(__('Download the app'), 'google_authenticator_download', false, '', '', true); - $html .= '
'; - $html .= '
'; - $html .= '
'; $html .= html_print_button(__('Continue'), 'continue_to_generate', false, '', '', true); $html .= '
'; @@ -311,11 +308,11 @@ if ($get_double_auth_generation_page) { $html .= '
'; $html .= __('QR').':
'; $html .= '
'; - $html .= '
'; + $html .= '
'; $html .= html_print_button(__('Refresh code'), 'continue_to_generate', false, '', '', true); - $html .= ' '; $html .= html_print_button(__('Continue'), 'continue_to_validate', false, '', '', true); $html .= '
'; + $html .= '
'; ob_clean(); ?> @@ -453,7 +450,7 @@ if ($get_double_auth_validation_page) { $html .= html_print_input_text('code', '', '', 50, $secret_lenght, true); $html .= '
'; $html .= '

'; - $html .= '
'; + $html .= '
'; $html .= html_print_button(__('Validate code'), 'continue_to_validate', false, '', '', true); $html .= html_print_image('images/spinner.gif', true); $html .= '
'; diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 70d6cba47e..45ee2efd9c 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -91,9 +91,8 @@ $node_id = (int) get_parameter('node_id', 0); if ($get_comments === true) { $event = get_parameter('event', false); - $event_rep = (int) get_parameter('event_rep', 0); - $event_rep = get_parameter_post('event')['event_rep']; - $group_rep = get_parameter_post('event')['group_rep']; + $event_rep = (int) get_parameter_post('event')['event_rep']; + $group_rep = (int) get_parameter_post('event')['group_rep']; if ($event === false) { return __('Failed to retrieve comments'); @@ -126,7 +125,7 @@ if ($get_comments === true) { } else if ($group_rep === EVENT_GROUP_REP_EXTRAIDS) { $whereGrouped = sprintf( '`id_extra` = "%s"', - $event['id_extra'] + io_safe_output($event['id_extra']) ); } else { $whereGrouped = sprintf('`id_evento` = %d', $event['id_evento']); diff --git a/pandora_console/include/ajax/fav_menu.ajax.php b/pandora_console/include/ajax/fav_menu.ajax.php new file mode 100644 index 0000000000..0b837ec9b3 --- /dev/null +++ b/pandora_console/include/ajax/fav_menu.ajax.php @@ -0,0 +1,82 @@ + $url, + 'id_user' => $config['id_user'], + ], + ['*'] +); +$res = false; +$action = ''; +if ($exist !== false) { + $res = db_process_sql_delete( + 'tfavmenu_user', + [ + 'url' => $url, + 'id_user' => $config['id_user'], + ] + ); + $action = 'delete'; +} else { + $res = db_process_sql_insert( + 'tfavmenu_user', + [ + 'id_element' => $id_element, + 'url' => $url, + 'label' => $label, + 'section' => $section, + 'id_user' => $id_user, + ] + ); + $action = 'create'; +} + +if ($res !== false) { + echo json_encode(['success' => true, 'action' => $action]); +} else { + echo json_encode(['success' => false, 'action' => $action]); +} diff --git a/pandora_console/include/ajax/heatmap.ajax.php b/pandora_console/include/ajax/heatmap.ajax.php index abfcd39e45..dd22fcdfef 100644 --- a/pandora_console/include/ajax/heatmap.ajax.php +++ b/pandora_console/include/ajax/heatmap.ajax.php @@ -26,6 +26,8 @@ * ============================================================================ */ +use PandoraFMS\Enterprise\Metaconsole\Node; + if (is_ajax() === true) { global $config; @@ -216,6 +218,12 @@ if (is_ajax() === true) { if ($getInfo === true) { enterprise_include_once('include/functions_agents.php'); $id = get_parameter('id', 0); + $id_server = get_parameter('id_server', 0); + if (empty($id_server) === false) { + $nd = new Node($id_server); + $nd->connect(); + } + switch ($type) { case 3: case 2: @@ -375,6 +383,10 @@ if (is_ajax() === true) { } break; } + + if (empty($id_server) === false) { + $nd->disconnect(); + } } return; diff --git a/pandora_console/include/ajax/map_enterprise.ajax.php b/pandora_console/include/ajax/map_enterprise.ajax.php index a0178457f5..4c5738f29a 100644 --- a/pandora_console/include/ajax/map_enterprise.ajax.php +++ b/pandora_console/include/ajax/map_enterprise.ajax.php @@ -25,6 +25,8 @@ if ((bool) is_metaconsole() === true) { if ($networkmap) { $networkmap_id = get_parameter('networkmap_id', 0); + $dashboard = get_parameter('dashboard', 0); + $size = get_parameter('size', []); $x_offset = get_parameter('x_offset', 0); $y_offset = get_parameter('y_offset', 0); $zoom_dash = get_parameter('zoom_dash', 0.5); @@ -62,6 +64,15 @@ if ($networkmap) { global $id_networkmap; $id_networkmap = $networkmap['id']; $tab = 'radial_dynamic'; + if (empty($size) === false) { + if ($size['width'] > $size['height']) { + $width = $size['height']; + $height = ($size['height'] - 10); + } else { + $width = $size['width']; + $height = ($size['width'] + 50); + } + } include_once 'operation/agentes/networkmap.dinamic.php'; } else { diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 052f105eda..296971bfc5 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -68,6 +68,11 @@ if (check_login()) { 0 ); + $get_data_ModulesByStatus = (bool) get_parameter( + 'get_data_ModulesByStatus', + 0 + ); + $load_filter_modal = get_parameter('load_filter_modal', 0); $save_filter_modal = get_parameter('save_filter_modal', 0); $get_monitor_filters = get_parameter('get_monitor_filters', 0); @@ -248,7 +253,7 @@ if (check_login()) { false, false ); - $formtable->data[0][3] = "".html_print_image('images/refresh.png', true, ['style' => 'vertical-align: middle;', 'border' => '0', 'class' => 'invert_filter' ]).''; + $formtable->data[0][3] = "".html_print_image('images/refresh@svg.svg', true, ['style' => 'vertical-align: middle;', 'border' => '0', 'class' => 'main_menu_icon invert_filter' ]).''; $formtable->rowspan[0][3] = 2; $formtable->cellstyle[0][3] = 'vertical-align: middle;'; @@ -1274,19 +1279,21 @@ if (check_login()) { if ((int) $module['flag'] === 0) { $additionalLinkAction = '&flag=1'; $linkCaption = __('Force checks'); + $imgaction = 'images/target.png'; } else { $additionalLinkAction = ''; $linkCaption = __('Refresh'); + $imgaction = 'images/go-back@svg.svg'; } - $moduleActionButtons[] = html_print_button( - $linkCaption, - 'additional_action_for_'.$idAgenteModulo, - false, - 'window.location.assign("index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&id_agente_modulo='.$module['id_agente_modulo'].'&refr=60'.$addedLinkParams.'")', + $moduleActionButtons[] = html_print_anchor( [ - 'mode' => 'link', - 'style' => 'justify-content: flex-end;', + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&id_agente_modulo='.$module['id_agente_modulo'].'&refr=60'.$additionalLinkAction.'"', + 'content' => html_print_image( + $imgaction, + true, + [ 'class' => 'main_menu_icon' ] + ), ], true ); @@ -1296,14 +1303,14 @@ if (check_login()) { if ((bool) check_acl($config['id_user'], $id_grupo, 'AW') === true && $cluster_view === false ) { - $moduleActionButtons[] = html_print_button( - __('Edit'), - 'edit_module_'.$idAgenteModulo, - false, - 'window.location.assign("index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&id_agent_module='.$module['id_agente_modulo'].'&edit_module='.$module['id_modulo'].'")', + $moduleActionButtons[] = html_print_anchor( [ - 'mode' => 'link', - 'style' => 'justify-content: flex-end;', + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&id_agent_module='.$module['id_agente_modulo'].'&edit_module='.$module['id_modulo'].'"', + 'content' => html_print_image( + 'images/edit.svg', + true, + [ 'class' => 'main_menu_icon' ] + ), ], true ); @@ -1385,7 +1392,7 @@ if (check_login()) { false, 'offset', true, - 'pagination-bottom', + '', 'pagination_list_modules(offset_param)', [ 'count' => '', @@ -1568,7 +1575,7 @@ if (check_login()) { $value['thresholds'] ); - $resultData = ''; + $resultData = ''; if ($vdata !== null && $vdata !== '' && $vdata !== false) { if (isset($formatData) === true && (bool) $formatData === true @@ -1665,6 +1672,301 @@ if (check_login()) { return; } + if ($get_data_ModulesByStatus === true) { + global $config; + $data = []; + + $table_id = get_parameter('table_id', ''); + $search = get_parameter('search', ''); + $status = get_parameter('status', ''); + $start = get_parameter('start', 0); + $length = get_parameter('length', $config['block_size']); + // There is a limit of (2^32)^2 (18446744073709551615) rows in a MyISAM table, show for show all use max nrows. + $length = ($length != '-1') ? $length : '18446744073709551615'; + $order = get_datatable_order(true); + $nodes = get_parameter('nodes', 0); + + $where = ''; + $recordsTotal = 0; + + + if (empty($search) === false) { + $where = 'tagente_modulo.nombre LIKE "%%'.$search.'%%" AND '; + } + + if (str_contains($status, '6') === true) { + $expl = explode(',', $status); + $exist = array_search('6', $expl); + if (isset($exist) === true) { + unset($expl[$exist]); + } + + array_push($expl, '1', '2'); + + $status = implode(',', $expl); + } + + $where .= sprintf( + 'tagente_estado.estado IN (%s) + AND tagente_modulo.delete_pending = 0', + $status + ); + + if (is_metaconsole() === false) { + $order_by = ''; + switch ($order['field']) { + case 'nombre': + $order_by = 'tagente_modulo.'.$order['field'].' '.$order['direction']; + break; + + case 'alias': + $order_by = 'tagente.'.$order['field'].' '.$order['direction']; + break; + + case 'last_status_change': + $order_by = 'tagente_estado.'.$order['field'].' '.$order['direction']; + break; + + case 'estado': + $order_by = 'tagente_estado.'.$order['field'].' '.$order['direction']; + break; + + default: + $order_by = 'tagente_estado.last_status_change desc'; + break; + } + + $sql = sprintf( + 'SELECT + tagente_modulo.nombre, + tagente.alias, + tagente.id_agente, + tagente_estado.last_status_change, + tagente_estado.estado + FROM tagente_modulo + INNER JOIN tagente + ON tagente_modulo.id_agente = tagente.id_agente + INNER JOIN tagente_estado + ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + WHERE %s + ORDER BY %s + LIMIT %d, %d', + $where, + $order_by, + $start, + $length + ); + $data = db_get_all_rows_sql($sql); + + $sql_count = sprintf( + 'SELECT COUNT(*) AS "total" + FROM tagente_modulo + INNER JOIN tagente + ON tagente_modulo.id_agente = tagente.id_agente + INNER JOIN tagente_estado + ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + WHERE %s', + $where + ); + $recordsTotal = db_get_value_sql($sql_count); + + // Metaconsole. + } else { + // $servers_ids = array_column(metaconsole_get_servers(), 'id'); + $servers_ids = explode(',', $nodes); + + foreach ($servers_ids as $server_id) { + try { + $node = new Node((int) $server_id); + $node->connect(); + + $sql = sprintf( + 'SELECT + tagente_modulo.nombre, + tagente.alias, + tagente.id_agente, + tagente_estado.last_status_change, + tagente_estado.estado + FROM tagente_modulo + INNER JOIN tagente + ON tagente_modulo.id_agente = tagente.id_agente + INNER JOIN tagente_estado + ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + WHERE %s', + $where + ); + + $res_sql = db_get_all_rows_sql($sql); + + foreach ($res_sql as $row_sql) { + $row_sql['server_name'] = $node->server_name(); + $row_sql['server_url'] = $node->server_url(); + array_push($data, $row_sql); + } + + $node->disconnect(); + } catch (\Exception $e) { + // Unexistent modules. + $node->disconnect(); + } + } + + if (in_array(0, $servers_ids) === true) { + $sql = sprintf( + 'SELECT + tagente_modulo.nombre, + tagente.alias, + tagente.id_agente, + tagente_estado.last_status_change, + tagente_estado.estado + FROM tagente_modulo + INNER JOIN tagente + ON tagente_modulo.id_agente = tagente.id_agente + INNER JOIN tagente_estado + ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + WHERE %s', + $where + ); + + $res_sql = db_get_all_rows_sql($sql); + + foreach ($res_sql as $row_sql) { + $row_sql['server_name'] = __('Metaconsole'); + $row_sql['server_url'] = $config['homeurl']; + array_push($data, $row_sql); + } + } + + // Drop temporary table if exist. + db_process_sql('DROP TEMPORARY TABLE IF EXISTS temp_modules_status;'); + + $table_temporary = 'CREATE TEMPORARY TABLE IF NOT EXISTS temp_modules_status ( + id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + nombre VARCHAR(600), + alias VARCHAR(600), + id_agente INT, + last_status_change INT, + estado INT, + server_name VARCHAR(100), + server_url VARCHAR(200), + PRIMARY KEY (`id`), + KEY `nombre` (`nombre`(600)) + )'; + db_process_sql($table_temporary); + + $result = db_process_sql_insert_multiple('temp_modules_status', $data); + + if (empty($result) === false) { + $data = []; + $sql = ''; + $where = ''; + + if (empty($search) === false) { + $where = 'nombre LIKE "%%'.$search.'%%" AND '; + } + + $where .= sprintf( + 'estado IN (%s)', + $status + ); + + $order_by = $order['field'].' '.$order['direction']; + + $sql = sprintf( + 'SELECT + nombre, + alias, + id_agente, + last_status_change, + estado, + server_name, + server_url + FROM temp_modules_status + WHERE %s + ORDER BY %s + LIMIT %d, %d', + $where, + $order_by, + $start, + $length + ); + $data = db_get_all_rows_sql($sql); + + $sql_count = sprintf( + 'SELECT COUNT(*) AS "total" + FROM temp_modules_status + WHERE %s', + $where + ); + + $recordsTotal = db_get_value_sql($sql_count); + } + } + + if ($data === false) { + $data = []; + } + + foreach ($data as $key => $row) { + $data[$key]['nombre'] = html_ellipsis_characters($row['nombre'], 35, true); + + if (is_metaconsole() === false) { + $name_link = ''; + $name_link .= ''; + + $data[$key]['alias'] = $name_link; + + $data[$key]['last_status_change'] = ui_print_timestamp( + $row['last_status_change'], + true + ); + + switch ((int) $row['estado']) { + case 0: + $status_img = ui_print_status_image(STATUS_MODULE_OK, __('Normal'), true); + break; + + case 1: + case 6: + $status_img = ui_print_status_image(STATUS_MODULE_CRITICAL, __('Critical'), true); + break; + + case 2: + $status_img = ui_print_status_image(STATUS_MODULE_WARNING, __('Warning'), true); + break; + + case 3: + $status_img = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('Unknown'), true); + break; + + case 5: + $status_img = ui_print_status_image(STATUS_MODULE_NO_DATA, __('Not init'), true); + break; + + default: + $status_img = ''; + break; + } + + $data[$key]['estado'] = $status_img; + } + + echo json_encode( + [ + 'data' => $data, + 'recordsTotal' => $recordsTotal, + 'recordsFiltered' => $recordsTotal, + ] + ); + } + if ($get_children_modules === true) { $parent_modules = get_parameter('parent_modulues', false); $children_selected = []; @@ -1786,6 +2088,14 @@ if (check_login()) { if ($monitor_filters === false) { echo 'error'; } else { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id, + 'section' => 'Modules', + 'id_user' => $config['id_user'], + ] + ); echo 'ok'; } } diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 7bc4785011..2e9ec50479 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -27,8 +27,6 @@ */ // Begin. -require_once 'config.php'; - require_once __DIR__.'/config.php'; require_once __DIR__.'/functions.php'; require_once __DIR__.'/functions_db.php'; @@ -87,7 +85,7 @@ if (check_login(false) === false) {

Access is not granted

-