2006-03-27 05:37:27 +02:00
< ? php
2021-04-29 13:28:03 +02:00
/**
* Monitor Status View .
*
* @ category View
* @ package Pandora FMS
* @ subpackage Monitoring .
* @ version 1.0 . 0
* @ license See below
*
* ______ ___ _______ _______ ________
2023-06-08 12:42:10 +02:00
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
2021-04-29 13:28:03 +02:00
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
2023-06-08 11:53:13 +02:00
* Copyright ( c ) 2005 - 2023 Pandora FMS
2023-06-08 13:19:01 +02:00
* Please see https :// pandorafms . com / community / for full contribution list
2021-04-29 13:28:03 +02:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* ============================================================================
*/
// Begin.
2023-11-03 17:48:15 +01:00
use PandoraFMS\Enterprise\Metaconsole\Node ;
2010-03-02 Sancho Lerena <slerena@artica.es>
* include/functions_reporting.php: Solved issue with several undefined
vars.
* include/functions_servers.php: Solved issue with several undefined
vars.
* include/functions_config.php: Added metaconsola witch to readconfig.
* include/config_process.php: Update build.. is YYMMDD !
* include/functions_ui.php: Removed deprecated call to split and replaced
by preg_split.
* index.php: Activated developer mode.
* operation/agentes/estado_monitores.php: Solved small problem with modules
without history, filling missing column in table. Added headers
* godmode/alerts/configure_alert_compound.php,
operation/agentes/status_monitor.php
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_commands.php,
godmode/modules/manage_network_templates.php,
godmode/modules/module_list.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php: Removed deprecated call to include
config.php and in some cases, added new header style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2444 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-03-02 15:13:00 +01:00
global $config ;
2008-04-17 17:27:25 +02:00
2008-07-21 14:23:28 +02:00
check_login ();
2006-03-27 05:37:27 +02:00
2019-01-30 16:18:44 +01:00
if ( ! check_acl ( $config [ 'id_user' ], 0 , 'AR' )
&& ! check_acl ( $config [ 'id_user' ], 0 , 'AW' )
&& ! check_acl ( $config [ 'id_user' ], 0 , 'AM' )
) {
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_ACL_VIOLATION ,
2019-01-30 16:18:44 +01:00
'Trying to access Agent Management'
);
include 'general/noaccess.php' ;
return ;
2008-01-10 17:40:00 +01:00
}
2006-03-27 05:37:27 +02:00
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_agents.php' ;
require_once $config [ 'homedir' ] . '/include/functions_modules.php' ;
require_once $config [ 'homedir' ] . '/include/functions_users.php' ;
enterprise_include_once ( 'include/functions_metaconsole.php' );
2012-11-26 19:38:09 +01:00
2019-01-30 16:18:44 +01:00
$isFunctionPolicies = enterprise_include_once ( 'include/functions_policies.php' );
* include/functions_graph.php
include/functions_html.php
include/functions_messages.php
include/db/postgresql.php
include/db/mysql.php
include/db/oracle.php
include/functions_reporting.php
include/functions_filemanager.php
include/functions_gis.php
include/auth/ldap.php
include/auth/mysql.php
include/functions_networkmap.php
include/functions_network_components.php
include/ajax/skins.ajax.php
include/ajax/reporting.ajax.php
include/ajax/visual_console_builder.ajax.php
include/ajax/alert_list.ajax.php
include/ajax/module.php
include/functions_config.php
include/functions_api.php
include/help/en/help_timesource.php
include/help/es/help_timesource.php
include/help/ja/help_timesource.php
include/config_process.php
include/functions_ui.php
include/functions_custom_graphs.php
include/fgraph.php
include/functions_incidents.php
include/api.php
include/functions_reports.php
include/functions_ui_renders.php
extensions/insert_data.php
extensions/system_info.php
extensions/extension_uploader.php
extensions/pandora_logs.php
extensions/agents_modules.php
extensions/update_manager.php
extensions/ssh_console.php
extensions/dbmanager.php
extensions/vnc_view.php
extensions/resource_registration.php
extensions/resource_exportation.php
extensions/users_connected.php
extensions/module_groups.php
extensions/update_manager/load_updatemanager.php
extensions/update_manager/lib/libupdate_manager_client.php
extensions/update_manager/lib/libupdate_manager.php
extensions/update_manager/lib/libupdate_manager_components.php
extensions/update_manager/lib/libupdate_manager_updates.php
extensions/update_manager/settings.php
extensions/update_manager/main.php
extensions/plugin_registration.php
operation/incidents/incident.php
operation/incidents/incident_detail.php
operation/incidents/incident_statistics.php
operation/search_modules.php
operation/visual_console/render_view.php
operation/visual_console/index.php
operation/extensions.php
operation/agentes/status_monitor.php
operation/agentes/export_csv.php
operation/agentes/estado_ultimopaquete.php
operation/agentes/datos_agente.php
operation/agentes/alerts_status.php
operation/agentes/estado_generalagente.php
operation/agentes/custom_fields.php
operation/agentes/estado_agente.php
operation/agentes/networkmap.topology.php
operation/agentes/networkmap.groups.php
operation/agentes/sla_view.php
operation/agentes/exportdata.php
operation/agentes/gis_view.php
operation/agentes/estado_monitores.php
operation/agentes/ver_agente.php
operation/agentes/graphs.php
operation/agentes/agent_fields.php
operation/agentes/tactical.php
operation/agentes/group_view.php
operation/agentes/networkmap.php
operation/agentes/stat_win.php
operation/servers/view_server.php
operation/servers/view_server_detail.php
operation/menu.php
operation/search_agents.php
operation/search_graphs.php
operation/snmpconsole/snmp_view.php
operation/users/user_edit.php
operation/gis_maps/render_view.php
operation/gis_maps/ajax.php
operation/integria_incidents/incident.php
operation/integria_incidents/incident_detail.php
operation/integria_incidents/incident_statistics.php
operation/events/event_statistics.php
operation/events/events_rss.php
operation/events/export_csv.php
operation/events/sound_events.php
operation/events/events_validate.php
operation/events/events_list.php
operation/events/events_marquee.php
operation/events/events.php
operation/search_alerts.php
operation/messages/message.php
operation/reporting/reporting_xml.php
operation/reporting/reporting_viewer.php
operation/reporting/graph_viewer.php
operation/search_reports.php
operation/search_maps.php
operation/search_users.php
extras/pandora_diag.php
mobile/operation/agents/monitor_status.php
mobile/operation/agents/view_agents.php
mobile/operation/agents/view_alerts.php
mobile/operation/agents/group_view.php
mobile/operation/events/events.php
mobile/index.php
general/error_authconfig.php
general/links_menu.php
general/logon_ok.php
general/error_dbconfig.php
general/ui/agents_list.php
general/header.php
godmode/groups/modu_group_list.php
godmode/groups/configure_group.php
godmode/groups/configure_modu_group.php
godmode/groups/group_list.php
godmode/admin_access_logs.php
godmode/db/db_main.php
godmode/db/db_audit.php
godmode/db/db_sanity.php
godmode/db/db_refine.php
godmode/db/db_info.php
godmode/db/db_event.php
godmode/db/db_purge.php
godmode/extensions.php
godmode/agentes/agent_template.php
godmode/agentes/module_manager_editor_common.php
godmode/agentes/fields_manager.php
godmode/agentes/agent_conf_gis.php
godmode/agentes/module_manager_editor_prediction.php
godmode/agentes/module_manager.php
godmode/agentes/modificar_agente.php
godmode/agentes/configurar_agente.php
godmode/agentes/configure_field.php
godmode/agentes/module_manager_editor.php
godmode/agentes/planned_downtime.php
godmode/agentes/manage_config_remote.php
godmode/agentes/agent_manager.php
godmode/servers/recon_script.php
godmode/servers/plugin.php
godmode/servers/manage_recontask.php
godmode/servers/modificar_server.php
godmode/servers/manage_recontask_form.php
godmode/alerts/alert_list.list.php
godmode/alerts/configure_alert_compound.php
godmode/alerts/alert_compounds.php
godmode/alerts/alert_list.php
godmode/alerts/configure_alert_template.php
godmode/alerts/alert_templates.php
godmode/alerts/configure_alert_action.php
godmode/alerts/configure_alert_command.php
godmode/alerts/alert_actions.php
godmode/alerts/alert_list.builder.php
godmode/alerts/alert_commands.php
godmode/setup/file_manager.php
godmode/setup/os.list.php
godmode/setup/news.php
godmode/setup/gis_step_2.php
godmode/setup/links.php
godmode/setup/setup.php
godmode/setup/os.php
godmode/setup/performance.php
godmode/setup/setup_auth.php
godmode/setup/gis.php
godmode/setup/os.builder.php
godmode/setup/setup_visuals.php
godmode/snmpconsole/snmp_alert.php
godmode/snmpconsole/snmp_filters.php
godmode/users/user_list.php
godmode/users/configure_profile.php
godmode/gis_maps/configure_gis_map.php
godmode/gis_maps/index.php
godmode/massive/massive_add_alerts.php
godmode/massive/massive_copy_modules.php
godmode/massive/massive_delete_agents.php
godmode/massive/massive_enable_disable_alerts.php
godmode/massive/massive_operations.php
godmode/massive/massive_delete_profiles.php
godmode/massive/massive_edit_agents.php
godmode/massive/massive_delete_action_alerts.php
godmode/massive/massive_delete_modules.php
godmode/massive/massive_add_profiles.php
godmode/massive/massive_delete_alerts.php
godmode/massive/massive_edit_modules.php
godmode/massive/massive_standby_alerts.php
godmode/massive/massive_add_action_alerts.php
godmode/modules/manage_network_components_form.php
godmode/modules/manage_nc_groups_form.php
godmode/modules/manage_network_templates.php
godmode/modules/module_list.php
godmode/modules/manage_network_components_form_common.php
godmode/modules/manage_network_components_form_network.php
godmode/modules/manage_network_templates_form.php
godmode/modules/manage_network_components_form_wmi.php
godmode/modules/manage_network_components.php
godmode/modules/manage_nc_groups.php
godmode/reporting/visual_console_builder.wizard.php
godmode/reporting/graph_builder.main.php
godmode/reporting/reporting_builder.list_items.php
godmode/reporting/visual_console_builder.php
godmode/reporting/reporting_builder.preview.php
godmode/reporting/reporting_builder.main.php
godmode/reporting/visual_console_builder.data.php
godmode/reporting/visual_console_builder.elements.php
godmode/reporting/graph_builder.php
godmode/reporting/visual_console_builder.preview.php
godmode/reporting/graph_builder.graph_editor.php
godmode/reporting/reporting_builder.php
godmode/reporting/visual_console_builder.editor.php
godmode/reporting/reporting_builder.item_editor.php
godmode/reporting/map_builder.php
godmode/reporting/graphs.php
godmode/reporting/graph_builder.preview.php
include/functions_db.php: Added some includes and functions of this code have "db_" prefix.
* include/functions.php: Moved function check_login(), check_acl(),
dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php.
* include/functions_groups.php: Moved functions get_childrens(), safe_acl_group()
and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(),
get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(),
get_group_name(), get_group_users() from functions_db.php to this code.
* include/functions_profile.php: New library with profile functions. Moved functions
get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(),
delete_profile() from functions_db.php to this code. Added new parameter in function
get_profile() to retrieve profiles with filter conditions applied.
* include/functions_users.php: New library with users functions. Moved functions
get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(),
get_user_first_group(), user_access_to_agent() from funtions_db.php to this code.
* godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile().
* include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(),
get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(),
check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(),
agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(),
get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(),
get_agent_group() from functions_db.php to this code.
* include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(),
get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(),
get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(),
get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(),
get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(),
get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(),
get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(),
give_modulecategory_name(),
give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(),
get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(),
get_modulegroup_name() from functions_db.php to this code.
* include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(),
get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(),
get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(),
get_agentmodule_last_status() from functions_db.php to this code.
* include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion()
from functions_db.php to this code.
* include/functions_events.php: Moved functions get_group_events(), get_agent_events(),
get_module_events() from functions_db.php to this code.
* include/functions_servers.php: Moved functions get_server_name(), show_server_type(),
check_server_status(), server_status() from functions_db.php to this code.
* include/functions_network_profiles.php: Moved function get_networkprofile_name()
from functions_db.php to this code.
* include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y()
from fucntions_db.php to this code.
* include/functions_io.php: Moved function __() from functions_db.php to this code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
2023-02-28 19:01:37 +01:00
$buttons = [];
$subpage = '' ;
if ( is_metaconsole () === false ) {
2019-02-25 14:42:48 +01:00
$section = ( string ) get_parameter ( 'section' , 'view' );
2019-02-15 14:22:55 +01:00
2019-02-25 14:42:48 +01:00
$buttons [ 'fields' ] = [
'active' => false ,
2021-03-11 15:40:23 +01:00
'text' => '<a href="index.php?sec=view&sec2=operation/agentes/status_monitor§ion=fields">' . html_print_image (
2023-02-17 13:35:42 +01:00
'images/edit_columns@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'Custom fields' ),
2023-02-17 13:35:42 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ,
2019-02-25 14:42:48 +01:00
'operation' => true ,
];
2019-02-15 14:22:55 +01:00
2019-02-25 14:42:48 +01:00
$buttons [ 'view' ] = [
'active' => false ,
2021-03-11 15:40:23 +01:00
'text' => '<a href="index.php?sec=view&sec2=operation/agentes/status_monitor">' . html_print_image (
2023-02-17 13:35:42 +01:00
'images/logs@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'View' ),
2023-02-17 13:35:42 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ,
2019-02-25 14:42:48 +01:00
'operation' => true ,
];
2019-02-15 14:22:55 +01:00
switch ( $section ) {
case 'fields' :
$buttons [ 'fields' ][ 'active' ] = true ;
2021-04-29 13:28:03 +02:00
$subpage = ' » ' . __ ( 'Custom fields' );
2019-02-25 14:42:48 +01:00
break ;
2019-02-15 14:22:55 +01:00
default :
$buttons [ 'view' ][ 'active' ] = true ;
2019-02-25 14:42:48 +01:00
break ;
2019-02-15 14:22:55 +01:00
}
2023-02-28 19:01:37 +01:00
}
2019-01-18 11:13:29 +01:00
2023-02-28 19:01:37 +01:00
if ( is_metaconsole () === false ) {
2019-02-25 14:42:48 +01:00
if ( $section == 'fields' ) {
include_once $config [ 'homedir' ] . '/godmode/agentes/status_monitor_custom_fields.php' ;
exit ();
}
2019-01-30 16:18:44 +01:00
} else {
2020-11-26 12:28:12 +01:00
$section = ( string ) get_parameter ( 'sec' , 'estado' );
2012-11-26 19:38:09 +01:00
}
2008-01-10 17:40:00 +01:00
2020-10-29 12:55:44 +01:00
$recursion = get_parameter_switch ( 'recursion' , false );
2023-01-19 10:49:48 +01:00
2020-10-29 12:55:44 +01:00
if ( $recursion === false ) {
$recursion = get_parameter ( 'recursion' , false );
}
$ag_freestring = ( string ) get_parameter ( 'ag_freestring' );
$moduletype = ( string ) get_parameter ( 'moduletype' );
$datatype = ( string ) get_parameter ( 'datatype' );
$ag_modulename = ( string ) get_parameter ( 'ag_modulename' );
$refr = ( int ) get_parameter ( 'refr' , 0 );
$offset = ( int ) get_parameter ( 'offset' , 0 );
$status = ( int ) get_parameter ( 'status' , 4 );
$modulegroup = ( int ) get_parameter ( 'modulegroup' , - 1 );
2023-01-19 10:49:48 +01:00
$tag_filter = get_parameter ( 'tag_filter' , [ 0 ]);
2020-10-29 12:55:44 +01:00
$min_hours_status = ( string ) get_parameter ( 'min_hours_status' , '' );
// Sort functionality.
$sortField = get_parameter ( 'sort_field' );
$sort = get_parameter ( 'sort' , 'none' );
// When the previous page was a visualmap and show only one module.
$id_module = ( int ) get_parameter ( 'id_module' , 0 );
$ag_custom_fields = ( array ) get_parameter ( 'ag_custom_fields' , []);
2016-11-17 15:30:37 +01:00
$module_option = ( int ) get_parameter ( 'module_option' , 1 );
2021-05-06 17:08:11 +02:00
$not_condition = ( string ) get_parameter ( 'not_condition' , '' );
2021-06-25 09:37:26 +02:00
$is_none = 'All' ;
if ( $not_condition !== '' ) {
$is_none = 'None' ;
2021-08-24 13:30:50 +02:00
$not_condition = 'NOT' ;
2021-06-25 09:37:26 +02:00
}
2021-05-06 17:08:11 +02:00
// If option not_condition is enabled, the conditions of the queries are reversed.
$condition_query = '=' ;
if ( $not_condition !== '' ) {
$condition_query = '!=' ;
}
2019-03-06 17:25:36 +01:00
$autosearch = false ;
2021-05-06 17:08:11 +02:00
// It is validated if it receives parameters different from those it has by default.
2019-03-06 17:25:36 +01:00
if ( $ag_freestring !== '' || $moduletype !== '' || $datatype !== ''
|| $ag_modulename !== '' || $refr !== 0 || $offset !== 0 || $status !== 4
2023-02-15 14:25:43 +01:00
|| $modulegroup !== - 1 || ( bool ) array_filter ( $tag_filter ) !== false || $sortField !== ''
2019-03-06 17:25:36 +01:00
|| $sort !== 'none' || $id_module !== 0 || $module_option !== 1
2020-03-23 12:47:58 +01:00
|| $min_hours_status !== ''
2019-03-06 17:25:36 +01:00
) {
$autosearch = true ;
}
2016-10-17 12:30:52 +02:00
2023-03-15 08:56:15 +01:00
// The execution has not been done manually.
$userRequest = ( bool ) get_parameter ( 'uptbutton' );
2023-09-01 09:37:16 +02:00
if ( $userRequest === true ) {
2023-03-15 08:56:15 +01:00
$autosearch = true ;
}
2022-10-26 12:02:56 +02:00
if ( is_metaconsole () === false ) {
2019-01-30 16:18:44 +01:00
$ag_group = ( int ) get_parameter ( 'ag_group' , 0 );
} else {
2021-05-07 09:32:54 +02:00
$ag_group = get_parameter ( 'ag_group' , 0 );
2019-01-30 16:18:44 +01:00
$ag_group_metaconsole = $ag_group ;
2013-10-14 14:36:41 +02:00
}
2016-10-17 12:30:52 +02:00
$ag_custom_fields_params = '' ;
2014-04-14 15:18:20 +02:00
if ( ! empty ( $ag_custom_fields )) {
2019-01-30 16:18:44 +01:00
foreach ( $ag_custom_fields as $id => $value ) {
if ( ! empty ( $value )) {
$ag_custom_fields_params .= '&ag_custom_fields[' . $id . ']=' . $value ;
}
}
2014-04-14 15:18:20 +02:00
}
2019-01-30 16:18:44 +01:00
2013-06-24 15:43:49 +02:00
if ( $id_module ) {
2019-01-30 16:18:44 +01:00
$status = - 1 ;
$ag_modulename = modules_get_agentmodule_name ( $id_module );
$ag_freestring = modules_get_agentmodule_agent_alias ( $id_module );
2013-06-24 15:43:49 +02:00
}
2021-05-06 17:08:11 +02:00
// Get Groups and profiles from user.
2019-01-30 16:18:44 +01:00
$user_groups = implode ( ',' , array_keys ( users_get_groups ( false , 'AR' , false )));
2013-01-10 17:00:30 +01:00
2021-05-06 17:08:11 +02:00
// Begin Build SQL sentences.
2019-01-30 16:18:44 +01:00
$sql_from = ' FROM tagente_modulo
2018-09-27 12:46:45 +02:00
INNER JOIN tagente
ON tagente_modulo . id_agente = tagente . id_agente
LEFT JOIN tagent_secondary_group tasg
2023-11-03 17:48:15 +01:00
ON tagente_modulo . id_agente = tasg . id_agent
2018-09-27 12:46:45 +02:00
INNER JOIN tagente_estado
ON tagente_estado . id_agente_modulo = tagente_modulo . id_agente_modulo
INNER JOIN tmodule
ON tmodule . id_module = tagente_modulo . id_modulo
INNER JOIN ttipo_modulo
ON tagente_modulo . id_tipo_modulo = ttipo_modulo . id_tipo
LEFT JOIN ttag_module
2019-01-30 16:18:44 +01:00
ON tagente_modulo . id_agente_modulo = ttag_module . id_agente_modulo ' ;
2018-09-27 12:46:45 +02:00
$sql_conditions = ' WHERE tagente.disabled = 0' ;
2013-02-18 14:46:28 +01:00
2014-07-23 18:59:05 +02:00
if ( is_numeric ( $ag_group )) {
2019-01-30 16:18:44 +01:00
$id_ag_group = 0 ;
} else {
$id_ag_group = db_get_value ( 'id_grupo' , 'tgrupo' , 'nombre' , $ag_group );
2014-07-23 18:59:05 +02:00
}
2013-11-12 13:38:13 +01:00
2023-01-19 10:49:48 +01:00
$load_filter_id = ( int ) get_parameter ( 'filter_id' , 0 );
if ( $load_filter_id > 0 ) {
$user_groups_fl = users_get_groups (
$config [ 'id_user' ],
'AR' ,
2023-02-28 17:06:31 +01:00
users_can_manage_group_all ( 'AR' ),
2023-01-19 10:49:48 +01:00
true
);
$sql = sprintf (
' SELECT id_filter , id_name
FROM tmonitor_filter
WHERE id_filter = % d AND id_group_filter IN ( % s ) ' ,
$load_filter_id ,
implode ( ',' , array_keys ( $user_groups_fl ))
);
$loaded_filter = db_get_row_sql ( $sql );
}
2024-02-09 13:51:56 +01:00
if ( isset ( $loaded_filter [ 'id_filter' ]) === false ) {
$loaded_filter [ 'id_filter' ] = 0 ;
}
2023-01-19 10:49:48 +01:00
if ( $loaded_filter [ 'id_filter' ] > 0 ) {
$query_filter [ 'id_filter' ] = $load_filter_id ;
$filter = db_get_row_filter ( 'tmonitor_filter' , $query_filter , false );
if ( $filter !== false ) {
$ag_group = $filter [ 'ag_group' ];
$recursion = $filter [ 'recursion' ];
$status = $filter [ 'status' ];
$modulegroup = $filter [ 'modulegroup' ];
$ag_modulename = $filter [ 'ag_modulename' ];
$ag_freestring = $filter [ 'ag_freestring' ];
$tag_filter = $filter [ 'tag_filter' ];
$moduletype = $filter [ 'moduletype' ];
$module_option = $filter [ 'module_option' ];
$min_hours_status = $filter [ 'min_hours_status' ];
$datatype = $filter [ 'datatype' ];
$not_condition = $filter [ 'not_condition' ];
$ag_custom_fields = $filter [ 'ag_custom_fields' ];
if ( $not_condition === 'false' ) {
$not_condition = '' ;
}
if ( $not_condition !== '' ) {
$is_none = 'None' ;
$not_condition = 'NOT' ;
}
if ( $not_condition !== '' ) {
$condition_query = '!=' ;
}
if ( is_array ( $tag_filter ) === false ) {
$tag_filter = json_decode ( $tag_filter , true );
}
2023-02-15 14:25:43 +01:00
2023-01-19 10:49:48 +01:00
if ( $tag_filter === '' ) {
$tag_filter = [ 0 => 0 ];
}
if ( is_array ( $ag_custom_fields ) === false ) {
$ag_custom_fields = json_decode ( io_safe_output ( $ag_custom_fields ), true );
}
}
2023-02-23 11:00:46 +01:00
2023-03-08 12:55:53 +01:00
// Fav menu.
2023-02-23 11:00:46 +01:00
$fav_menu = [
'id_element' => $loaded_filter [ 'id_filter' ],
'url' => 'operation/agentes/status_monitor&pure=&load_filter=1&filter_id=' . $loaded_filter [ 'id_filter' ],
'label' => $loaded_filter [ 'id_name' ],
'section' => 'Modules' ,
];
}
2023-03-08 12:55:53 +01:00
if ( is_metaconsole () === false ) {
2023-02-23 11:00:46 +01:00
$section = ( string ) get_parameter ( 'section' , 'view' );
$buttons [ 'fields' ] = [
'active' => false ,
'text' => '<a href="index.php?sec=view&sec2=operation/agentes/status_monitor§ion=fields">' . html_print_image (
2023-03-08 12:55:53 +01:00
'images/edit_columns@svg.svg' ,
2023-02-23 11:00:46 +01:00
true ,
[
'title' => __ ( 'Custom fields' ),
2023-03-08 12:55:53 +01:00
'class' => 'invert_filter main_menu_icon' ,
2023-02-23 11:00:46 +01:00
]
) . '</a>' ,
'operation' => true ,
];
$buttons [ 'view' ] = [
'active' => false ,
'text' => '<a href="index.php?sec=view&sec2=operation/agentes/status_monitor">' . html_print_image (
2023-03-08 12:55:53 +01:00
'images/logs@svg.svg' ,
2023-02-23 11:00:46 +01:00
true ,
[
'title' => __ ( 'View' ),
2023-03-08 12:55:53 +01:00
'class' => 'invert_filter main_menu_icon' ,
2023-02-23 11:00:46 +01:00
]
) . '</a>' ,
'operation' => true ,
];
switch ( $section ) {
case 'fields' :
$buttons [ 'fields' ][ 'active' ] = true ;
$subpage = ' » ' . __ ( 'Custom fields' );
break ;
default :
$buttons [ 'view' ][ 'active' ] = true ;
break ;
}
2023-03-08 12:55:53 +01:00
}
2023-02-23 11:00:46 +01:00
2023-03-13 13:01:48 +01:00
// Header.
ui_print_standard_header (
__ ( 'Monitor detail' ) . $subpage ,
'images/agent.png' ,
false ,
'' ,
true ,
$buttons ,
[
2023-02-23 11:00:46 +01:00
[
2023-03-13 13:01:48 +01:00
'link' => '' ,
'label' => __ ( 'Monitoring' ),
2023-02-23 11:00:46 +01:00
],
2023-03-08 12:55:53 +01:00
[
2023-03-13 13:01:48 +01:00
'link' => '' ,
'label' => __ ( 'Views' ),
2023-03-08 12:55:53 +01:00
],
2023-03-13 13:01:48 +01:00
],
( empty ( $fav_menu ) === true ) ? [] : $fav_menu
);
2023-02-23 11:00:46 +01:00
2023-03-08 12:55:53 +01:00
2023-02-28 17:06:31 +01:00
$all_groups = [];
2023-01-19 10:49:48 +01:00
2021-05-06 17:08:11 +02:00
// Agent group selector.
2022-10-26 12:02:56 +02:00
if ( is_metaconsole () === false ) {
2019-01-30 16:18:44 +01:00
if ( $ag_group > 0 && check_acl ( $config [ 'id_user' ], $ag_group , 'AR' )) {
2020-10-29 12:55:44 +01:00
if ( $recursion ) {
$all_groups = groups_get_children_ids ( $ag_group , true );
// User has explicit permission on group 1 ?
$sql_conditions_group = sprintf (
' AND (tagente.id_grupo IN (%s) OR tasg.id_group IN (%s)) ' ,
implode ( ',' , $all_groups ),
implode ( ',' , $all_groups )
);
} else {
$sql_conditions_group = sprintf (
2021-05-06 17:08:11 +02:00
' AND (tagente.id_grupo ' . $condition_query . ' %d OR tasg.id_group ' . $condition_query . ' %d)' ,
2020-10-29 12:55:44 +01:00
$ag_group ,
$ag_group
);
}
2019-01-30 16:18:44 +01:00
} else if ( $user_groups != '' ) {
// User has explicit permission on group 1 ?
$sql_conditions_group = ' AND (
2018-04-09 18:56:05 +02:00
tagente . id_grupo IN ( '.$user_groups.' )
OR tasg . id_group IN ( '.$user_groups.' )
) ' ;
2019-01-30 16:18:44 +01:00
}
} else {
if ((( int ) $ag_group !== 0 ) && ( check_acl ( $config [ 'id_user' ], $id_ag_group , 'AR' ))) {
2020-10-29 12:55:44 +01:00
if ( $recursion ) {
$all_groups = groups_get_children_ids ( $ag_group , true );
// User has explicit permission on group 1 ?
$sql_conditions_group = sprintf (
' AND (tagente.id_grupo IN (%s) OR tasg.id_group IN (%s)) ' ,
implode ( ',' , $all_groups ),
implode ( ',' , $all_groups )
);
} else {
$sql_conditions_group = sprintf (
2021-05-07 09:32:54 +02:00
' AND (tagente.id_grupo ' . $not_condition . ' IN (%s) OR tasg.id_group ' . $not_condition . ' IN (%s))' ,
2020-10-29 12:55:44 +01:00
$ag_group ,
$ag_group
);
}
2019-01-30 16:18:44 +01:00
} else if ( $user_groups != '' ) {
// User has explicit permission on group 1 ?
$sql_conditions_group = ' AND (
2018-04-09 19:10:19 +02:00
tagente . id_grupo IN ( '.$user_groups.' )
OR tasg . id_group IN ( '.$user_groups.' )
) ' ;
2019-01-30 16:18:44 +01:00
}
2013-01-10 17:00:30 +01:00
}
2014-07-23 18:59:05 +02:00
2021-05-06 17:08:11 +02:00
// Module group.
2022-10-26 12:02:56 +02:00
if ( is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
if ( $modulegroup != '-1' ) {
2021-05-06 17:08:11 +02:00
$sql_conditions .= sprintf ( ' AND tagente_modulo.id_module_group ' . $not_condition . ' IN (%s)' , $modulegroup );
2019-01-30 16:18:44 +01:00
}
} else if ( $modulegroup > - 1 ) {
2021-05-06 17:08:11 +02:00
$sql_conditions .= sprintf ( ' AND tagente_modulo.id_module_group ' . $condition_query . ' \'%d\'' , $modulegroup );
2013-01-10 17:00:30 +01:00
}
2021-05-06 17:08:11 +02:00
// Module name selector.
2016-08-24 15:31:28 +02:00
if ( $ag_modulename != '' ) {
2021-05-06 17:08:11 +02:00
$sql_conditions .= " AND tagente_modulo.nombre $not_condition LIKE '% " . $ag_modulename . " %' " ;
2013-01-10 17:00:30 +01:00
}
2021-04-13 12:24:35 +02:00
if ( $id_module ) {
$sql_conditions .= sprintf ( ' AND tagente_modulo.id_agente_modulo = \'%d\'' , $id_module );
}
2016-11-16 09:59:48 +01:00
if ( $module_option !== 0 ) {
2019-01-30 16:18:44 +01:00
if ( $module_option == 1 ) {
2021-05-06 17:08:11 +02:00
// Only enabled.
$sql_conditions .= sprintf ( ' AND tagente_modulo.disabled ' . $condition_query . ' 0' );
2019-01-30 16:18:44 +01:00
} else if ( $module_option == 2 ) {
2021-05-06 17:08:11 +02:00
// Only disabled.
$sql_conditions .= sprintf ( ' AND tagente_modulo.disabled ' . $condition_query . ' 1' );
2019-01-30 16:18:44 +01:00
}
2016-11-16 09:59:48 +01:00
}
2016-10-14 18:51:17 +02:00
2023-02-27 09:55:29 +01:00
if ( empty ( $datatype ) === false ) {
2021-05-06 17:08:11 +02:00
$sql_conditions .= sprintf ( ' AND ttipo_modulo.id_tipo ' . $condition_query . ' ' . $datatype );
2016-10-14 18:51:17 +02:00
}
if ( $moduletype != '' ) {
2021-05-06 17:08:11 +02:00
$sql_conditions .= sprintf ( ' AND tagente_modulo.id_modulo ' . $condition_query . ' ' . $moduletype . '' );
2016-10-14 18:51:17 +02:00
}
2021-05-06 17:08:11 +02:00
// Freestring selector.
2016-08-24 15:31:28 +02:00
if ( $ag_freestring != '' ) {
2023-11-03 17:48:15 +01:00
$sql_conditions .= ' AND EXISTS (
SELECT 1
FROM tagente
WHERE tagente . id_agente = tagente_modulo . id_agente
2023-12-22 12:55:21 +01:00
AND ( tagente . nombre '.$not_condition.' LIKE \ '%%' . $ag_freestring . ' %% \ '
OR tagente . alias '.$not_condition.' LIKE \ '%%' . $ag_freestring . ' %% \ '
OR tagente_modulo . nombre '.$not_condition.' LIKE \ '%%' . $ag_freestring . ' %% \ '
2023-11-03 17:48:15 +01:00
OR tagente_modulo . descripcion '.$not_condition.' LIKE \ '%%' . $ag_freestring . ' %% \ ' )
) ' ;
2013-01-10 17:00:30 +01:00
}
2021-05-06 17:08:11 +02:00
// Status selector.
2019-01-30 16:18:44 +01:00
if ( $status == AGENT_MODULE_STATUS_NORMAL ) {
2021-05-06 17:08:11 +02:00
// Normal.
$sql_conditions .= ' AND tagente_estado.estado ' . $condition_query . ' 0
2016-08-24 15:31:28 +02:00
AND ( utimestamp > 0 OR ( tagente_modulo . id_tipo_modulo IN ( 21 , 22 , 23 , 100 ))) ' ;
2019-01-30 16:18:44 +01:00
} else if ( $status == AGENT_MODULE_STATUS_CRITICAL_BAD ) {
2021-05-06 17:08:11 +02:00
// Critical.
$sql_conditions .= ' AND tagente_estado.estado ' . $condition_query . ' 1 AND utimestamp > 0' ;
2019-01-30 16:18:44 +01:00
} else if ( $status == AGENT_MODULE_STATUS_WARNING ) {
2021-05-06 17:08:11 +02:00
// Warning.
$sql_conditions .= ' AND tagente_estado.estado ' . $condition_query . ' 2 AND utimestamp > 0' ;
2019-01-30 16:18:44 +01:00
} else if ( $status == AGENT_MODULE_STATUS_NOT_NORMAL ) {
2021-05-06 17:08:11 +02:00
// Not normal.
2019-01-30 16:18:44 +01:00
$sql_conditions .= ' AND tagente_estado.estado <> 0' ;
} else if ( $status == AGENT_MODULE_STATUS_UNKNOWN ) {
2021-05-06 17:08:11 +02:00
// Unknown.
$sql_conditions .= ' AND tagente_estado.estado ' . $condition_query . ' 3 AND tagente_estado.utimestamp <> 0' ;
2019-01-30 16:18:44 +01:00
} else if ( $status == AGENT_MODULE_STATUS_NOT_INIT ) {
2021-05-06 17:08:11 +02:00
// Not init.
$sql_conditions .= ' AND tagente_estado.utimestamp ' . $condition_query . ' 0
2016-08-24 15:31:28 +02:00
AND tagente_modulo . id_tipo_modulo NOT IN ( 21 , 22 , 23 , 100 ) ' ;
2013-01-10 17:00:30 +01:00
}
2021-05-07 11:16:28 +02:00
$min_hours_condition = '<' ;
if ( $not_condition !== '' ) {
$min_hours_condition = '>' ;
}
2020-03-23 12:47:58 +01:00
if ( ! empty ( $min_hours_status )) {
$date = new DateTime ( null , new DateTimeZone ( $config [ 'timezone' ]));
$current_timestamp = $date -> getTimestamp ();
$max_time = ( $current_timestamp - (( int ) $min_hours_status * 3600 ));
2021-05-07 11:16:28 +02:00
$sql_conditions .= sprintf ( ' AND tagente_estado.last_status_change ' . $min_hours_condition . ' %d' , $max_time );
2020-03-23 12:47:58 +01:00
}
2021-05-06 17:08:11 +02:00
// Filter by agent custom fields.
2019-01-30 16:18:44 +01:00
$sql_conditions_custom_fields = '' ;
2014-04-14 15:18:20 +02:00
if ( ! empty ( $ag_custom_fields )) {
2019-01-30 16:18:44 +01:00
$cf_filter = [];
foreach ( $ag_custom_fields as $field_id => $value ) {
if ( ! empty ( $value )) {
2021-05-06 17:08:11 +02:00
$cf_filter [] = '(tagent_custom_data.id_field ' . $condition_query . ' ' . $field_id . ' AND tagent_custom_data.description ' . $not_condition . ' LIKE \'%' . $value . '%\')' ;
2019-01-30 16:18:44 +01:00
}
}
2014-04-14 15:18:20 +02:00
2019-01-30 16:18:44 +01:00
if ( ! empty ( $cf_filter )) {
2021-05-07 11:16:28 +02:00
$sql_conditions_custom_fields = ' AND tagente.id_agente ' . $not_condition . ' IN (
2014-04-14 15:18:20 +02:00
SELECT tagent_custom_data . id_agent
FROM tagent_custom_data
2019-01-30 16:18:44 +01:00
WHERE '.implode(' AND ', $cf_filter).' ) ' ;
}
2014-04-14 15:18:20 +02:00
}
2023-01-19 10:49:48 +01:00
$all_tags = in_array ( 0 , $tag_filter );
2021-05-06 17:08:11 +02:00
// Filter by tag.
2023-01-19 10:49:48 +01:00
if ( $all_tags === false ) {
$sql_conditions .= ' AND tagente_modulo . id_agente_modulo IN (
SELECT ttag_module . id_agente_modulo
FROM ttag_module
WHERE 1 = 1 ' ;
if ( $all_tags === false ) {
$sql_conditions .= ' AND ttag_module.id_tag ' . $not_condition . ' IN (' . implode ( ',' , $tag_filter ) . '))' ;
2019-01-30 16:18:44 +01:00
}
2023-01-19 10:49:48 +01:00
} else if ( $not_condition === 'NOT' ) {
// Match nothing if not condition has been selected along with all tags selected (none).
$sql_conditions .= ' AND 0=0' ;
2013-01-10 17:00:30 +01:00
}
2016-10-14 18:51:17 +02:00
2021-05-06 17:08:11 +02:00
// Apply the module ACL with tags.
2015-10-01 16:18:45 +02:00
$sql_conditions_tags = '' ;
2016-10-17 12:30:52 +02:00
2015-10-01 16:18:45 +02:00
if ( ! users_is_admin ()) {
2023-02-03 11:07:52 +01:00
$sql_conditions_tags = tags_get_acl_tags (
$config [ 'id_user' ],
( $recursion ) ? array_flip ( $all_groups ) : $ag_group ,
'AR' ,
'module_condition' ,
'AND' ,
'tagente_modulo' ,
true ,
[],
false
);
2019-01-30 16:18:44 +01:00
if ( is_numeric ( $sql_conditions_tags )) {
$sql_conditions_tags = ' AND 1 = 0' ;
}
2013-06-07 14:28:20 +02:00
}
2021-05-06 17:08:11 +02:00
// Two modes of filter. All the filters and only ACLs filter.
2019-01-30 16:18:44 +01:00
$sql_conditions_all = $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields ;
2013-01-10 17:00:30 +01:00
2021-05-06 17:08:11 +02:00
// Get count to paginate.
2019-01-30 16:18:44 +01:00
if ( ! defined ( 'METACONSOLE' )) {
$count = db_get_sql ( 'SELECT COUNT(DISTINCT tagente_modulo.id_agente_modulo)' . $sql_from . $sql_conditions_all );
}
2013-01-10 17:00:30 +01:00
2021-05-06 17:08:11 +02:00
// Get limit_sql depend of the metaconsole or standard mode.
2022-10-26 12:02:56 +02:00
if ( is_metaconsole () === true ) {
2021-05-06 17:08:11 +02:00
// Offset will be used to get the subset of modules.
2019-01-30 16:18:44 +01:00
$inferior_limit = $offset ;
$superior_limit = ( $config [ 'block_size' ] + $offset );
2021-05-06 17:08:11 +02:00
// Offset reset to get all elements.
2019-01-30 16:18:44 +01:00
$offset = 0 ;
if ( ! isset ( $config [ 'meta_num_elements' ])) {
$config [ 'meta_num_elements' ] = 100 ;
}
$limit_sql = $config [ 'meta_num_elements' ];
} else {
$limit_sql = $config [ 'block_size' ];
2013-01-10 17:00:30 +01:00
}
2019-01-30 16:18:44 +01:00
$fields = [];
2015-06-08 13:13:09 +02:00
$fields [ AGENT_MODULE_STATUS_NORMAL ] = __ ( 'Normal' );
2013-03-26 18:15:49 +01:00
$fields [ AGENT_MODULE_STATUS_WARNING ] = __ ( 'Warning' );
$fields [ AGENT_MODULE_STATUS_CRITICAL_BAD ] = __ ( 'Critical' );
2013-07-24 13:06:24 +02:00
$fields [ AGENT_MODULE_STATUS_UNKNOWN ] = __ ( 'Unknown' );
2019-01-30 16:18:44 +01:00
$fields [ AGENT_MODULE_STATUS_NOT_NORMAL ] = __ ( 'Not normal' );
2021-05-06 17:08:11 +02:00
// Default.
2013-03-26 18:15:49 +01:00
$fields [ AGENT_MODULE_STATUS_NOT_INIT ] = __ ( 'Not init' );
2012-11-29 18:34:51 +01:00
2019-01-30 16:18:44 +01:00
$rows_select = [];
2016-08-24 15:31:28 +02:00
$rows_select [ 0 ] = __ ( 'Not assigned' );
2022-10-26 12:02:56 +02:00
if ( is_metaconsole () === false ) {
2019-01-30 16:18:44 +01:00
$rows = db_get_all_rows_sql (
' SELECT *
FROM tmodule_group ORDER BY name '
);
$rows = io_safe_output ( $rows );
2023-02-17 13:35:42 +01:00
if ( empty ( $rows ) === false ) {
2019-01-30 16:18:44 +01:00
foreach ( $rows as $module_group ) {
$rows_select [ $module_group [ 'id_mg' ]] = $module_group [ 'name' ];
}
}
} else {
$rows_select = modules_get_modulegroups ();
2016-09-12 11:54:54 +02:00
}
2019-01-30 16:18:44 +01:00
$tags = [];
2015-01-15 18:08:58 +01:00
$tags = tags_get_user_tags ();
2023-02-17 13:35:42 +01:00
if ( empty ( $tags ) === true ) {
$tagsElement = __ ( 'No tags' );
2019-01-30 16:18:44 +01:00
} else {
2023-02-17 13:35:42 +01:00
$tagsElement = html_print_select (
2019-01-30 16:18:44 +01:00
$tags ,
2023-01-19 10:49:48 +01:00
'tag_filter[]' ,
2019-01-30 16:18:44 +01:00
$tag_filter ,
'' ,
2023-01-19 10:49:48 +01:00
__ ( 'All' ),
0 ,
true ,
2019-01-30 16:18:44 +01:00
true ,
true ,
'' ,
false ,
2023-02-23 15:44:01 +01:00
'width: 100%;'
2019-01-30 16:18:44 +01:00
);
2023-02-17 13:35:42 +01:00
$tagsElement .= ui_print_input_placeholder (
__ ( 'Only it is show tags in use.' ),
true
2019-01-30 16:18:44 +01:00
);
2016-10-17 12:30:52 +02:00
}
2015-01-15 15:11:26 +01:00
2023-02-17 13:35:42 +01:00
2019-01-30 16:18:44 +01:00
$network_available = db_get_sql (
' SELECT count ( * )
2016-10-14 18:51:17 +02:00
FROM tserver
2019-01-30 16:18:44 +01:00
WHERE server_type = 1 '
);
2021-05-06 17:08:11 +02:00
// POSTGRESQL AND ORACLE COMPATIBLE.
2019-01-30 16:18:44 +01:00
$wmi_available = db_get_sql (
' SELECT count ( * )
2016-10-14 18:51:17 +02:00
FROM tserver
2019-01-30 16:18:44 +01:00
WHERE server_type = 6 '
);
2021-05-06 17:08:11 +02:00
// POSTGRESQL AND ORACLE COMPATIBLE.
2019-01-30 16:18:44 +01:00
$plugin_available = db_get_sql (
' SELECT count ( * )
2016-10-14 18:51:17 +02:00
FROM tserver
2019-01-30 16:18:44 +01:00
WHERE server_type = 4 '
);
2021-05-06 17:08:11 +02:00
// POSTGRESQL AND ORACLE COMPATIBLE.
2019-01-30 16:18:44 +01:00
$prediction_available = db_get_sql (
' SELECT count ( * )
2016-10-14 18:51:17 +02:00
FROM tserver
2019-01-30 16:18:44 +01:00
WHERE server_type = 5 '
);
2021-05-06 17:08:11 +02:00
// POSTGRESQL AND ORACLE COMPATIBLE.
2019-01-30 16:18:44 +01:00
$wux_available = db_get_sql (
' SELECT count ( * )
2017-11-06 18:45:53 +01:00
FROM tserver
2019-01-30 16:18:44 +01:00
WHERE server_type = 17 '
);
2021-05-06 17:08:11 +02:00
// POSTGRESQL AND ORACLE COMPATIBLE.
// Development mode to use all servers.
2019-01-30 16:18:44 +01:00
if ( $develop_bypass ) {
2016-10-14 18:51:17 +02:00
$network_available = 1 ;
$wmi_available = 1 ;
$plugin_available = 1 ;
$prediction_available = 1 ;
2019-01-30 16:18:44 +01:00
}
2016-10-14 18:51:17 +02:00
2021-12-07 16:21:20 +01:00
$typemodules = [];
$typemodules [ 1 ] = __ ( 'Data server module' );
2022-10-26 12:02:56 +02:00
if ( $network_available || is_metaconsole () === true ) {
2016-10-14 18:51:17 +02:00
$typemodules [ 2 ] = __ ( 'Network server module' );
2019-01-30 16:18:44 +01:00
}
2022-10-26 12:02:56 +02:00
if ( $plugin_available || is_metaconsole () === true ) {
2016-10-14 18:51:17 +02:00
$typemodules [ 4 ] = __ ( 'Plugin server module' );
2019-01-30 16:18:44 +01:00
}
2022-10-26 12:02:56 +02:00
if ( $wmi_available || is_metaconsole () === true ) {
2016-10-14 18:51:17 +02:00
$typemodules [ 6 ] = __ ( 'WMI server module' );
2019-01-30 16:18:44 +01:00
}
2022-10-26 12:02:56 +02:00
if ( $prediction_available || is_metaconsole () === true ) {
2016-10-14 18:51:17 +02:00
$typemodules [ 5 ] = __ ( 'Prediction server module' );
2019-01-30 16:18:44 +01:00
}
if ( enterprise_installed ()) {
$typemodules [ 7 ] = __ ( 'Web server module' );
2022-10-26 12:02:56 +02:00
if ( $wux_available || is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
$typemodules [ 8 ] = __ ( 'Wux server module' );
2016-10-14 18:51:17 +02:00
}
2019-01-30 16:18:44 +01:00
}
$monitor_options = [
0 => __ ( 'All' ),
1 => __ ( 'Only enabled' ),
2 => __ ( 'Only disabled' ),
];
2016-10-14 18:51:17 +02:00
2020-03-23 12:47:58 +01:00
$min_hours_val = empty ( $min_hours_status ) ? '' : ( int ) $min_hours_status ;
2019-01-30 16:18:44 +01:00
switch ( $moduletype ) {
case 1 :
2023-02-17 13:35:42 +01:00
$sqlModuleType = sprintf (
2019-01-30 16:18:44 +01:00
' SELECT id_tipo , descripcion
2016-10-14 18:51:17 +02:00
FROM ttipo_modulo
2021-05-06 17:08:11 +02:00
WHERE categoria '.$not_condition.' IN ( 6 , 7 , 8 , 0 , 1 , 2 , - 1 ) order by descripcion '
2019-01-30 16:18:44 +01:00
);
break ;
case 2 :
2023-02-17 13:35:42 +01:00
$sqlModuleType = sprintf (
2019-01-30 16:18:44 +01:00
' SELECT id_tipo , descripcion
2016-10-14 18:51:17 +02:00
FROM ttipo_modulo
2021-05-06 17:08:11 +02:00
WHERE categoria '.$not_condition.' between 3 and 5 '
2019-01-30 16:18:44 +01:00
);
break ;
case 4 :
2023-02-17 13:35:42 +01:00
$sqlModuleType = sprintf (
2019-01-30 16:18:44 +01:00
' SELECT id_tipo , descripcion
2016-10-14 18:51:17 +02:00
FROM ttipo_modulo
2021-05-06 17:08:11 +02:00
WHERE categoria '.$not_condition.' between 0 and 2 '
2019-01-30 16:18:44 +01:00
);
break ;
case 6 :
2023-02-17 13:35:42 +01:00
$sqlModuleType = sprintf (
2019-01-30 16:18:44 +01:00
' SELECT id_tipo , descripcion
2016-10-14 18:51:17 +02:00
FROM ttipo_modulo
2021-05-06 17:08:11 +02:00
WHERE categoria '.$not_condition.' between 0 and 2 '
2019-01-30 16:18:44 +01:00
);
break ;
case 7 :
2023-02-17 13:35:42 +01:00
$sqlModuleType = sprintf (
2019-01-30 16:18:44 +01:00
' SELECT id_tipo , descripcion
2016-10-14 18:51:17 +02:00
FROM ttipo_modulo
2021-05-06 17:08:11 +02:00
WHERE categoria '.$condition_query.' 9 '
2019-01-30 16:18:44 +01:00
);
break ;
case 5 :
2023-02-17 13:35:42 +01:00
$sqlModuleType = sprintf (
2019-01-30 16:18:44 +01:00
' SELECT id_tipo , descripcion
2016-10-14 18:51:17 +02:00
FROM ttipo_modulo
2021-05-06 17:08:11 +02:00
WHERE categoria '.$condition_query.' 0 '
2019-01-30 16:18:44 +01:00
);
break ;
case 8 :
2023-02-17 13:35:42 +01:00
$sqlModuleType = sprintf (
2019-01-30 16:18:44 +01:00
' SELECT id_tipo , descripcion
2017-11-06 18:45:53 +01:00
FROM ttipo_modulo
2021-05-06 17:08:11 +02:00
WHERE nombre '.$condition_query.' \ 'web_analysis\''
2019-01-30 16:18:44 +01:00
);
break ;
case '' :
2023-02-17 13:35:42 +01:00
default :
$sqlModuleType = sprintf (
2019-01-30 16:18:44 +01:00
' SELECT id_tipo , descripcion
FROM ttipo_modulo '
);
break ;
}
2021-05-07 09:32:54 +02:00
if ( $not_condition !== '' ) {
$check_not_condition = true ;
2023-02-17 13:35:42 +01:00
} else {
$check_not_condition = '' ;
2021-05-07 09:32:54 +02:00
}
2022-06-01 15:07:51 +02:00
$custom_fields = db_get_all_fields_in_table ( 'tagent_custom_fields' );
if ( $custom_fields === false ) {
$custom_fields = [];
}
2015-07-01 11:27:37 +02:00
2022-06-01 15:07:51 +02:00
$div_custom_fields = '<div class="flex-row">' ;
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 = '' ;
2021-05-06 17:08:11 +02:00
}
2022-06-01 15:07:51 +02:00
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$div_custom_fields .= '<div class="div-col">' ;
2014-04-14 15:18:20 +02:00
2022-06-01 15:07:51 +02:00
$div_custom_fields .= '<div class="div-span">' ;
$div_custom_fields .= '<span >' . $custom_field [ 'name' ] . '</span>' ;
$div_custom_fields .= '</div>' ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$div_custom_fields .= '<div class="div-input">' ;
$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 .= '</div>' ;
2021-05-06 17:08:11 +02:00
2022-06-01 15:07:51 +02:00
$div_custom_fields .= '</div>' ;
}
2021-05-06 17:08:11 +02:00
2022-06-01 15:07:51 +02:00
$div_custom_fields .= '</div>' ;
2019-01-30 16:18:44 +01:00
2023-02-17 13:35:42 +01:00
// End Build SQL sentences.
//
// Start Build Search Form.
//
$table = new stdClass ();
$tableFilter = new StdClass ();
$tableFilter -> width = '100%' ;
2023-02-23 15:44:01 +01:00
$tableFilter -> size = [];
$tableFilter -> size [ 0 ] = '33%' ;
$tableFilter -> size [ 1 ] = '33%' ;
$tableFilter -> size [ 2 ] = '33%' ;
2023-02-17 13:35:42 +01:00
$tableFilter -> id = 'main_status_monitor_filter' ;
2023-02-23 15:44:01 +01:00
$tableFilter -> class = 'filter-table-adv' ;
2023-02-17 13:35:42 +01:00
// Captions for first line.
2023-02-23 15:44:01 +01:00
$tableFilter -> data [ 'first_line' ][ 0 ] = html_print_label_input_block (
__ ( 'Group' ),
html_print_select_groups (
$config [ 'id_user' ],
'AR' ,
true ,
'ag_group' ,
$ag_group ,
'' ,
'' ,
'0' ,
true ,
false ,
false ,
'' ,
false ,
'' ,
false ,
false ,
'id_grupo' ,
false ,
false ,
false ,
false ,
false ,
false ,
$not_condition
)
2023-02-17 13:35:42 +01:00
);
2023-02-23 15:44:01 +01:00
$tableFilter -> data [ 'first_line' ][ 0 ] .= html_print_label_input_block (
__ ( 'Recursion' ),
html_print_checkbox_switch (
'recursion' ,
1 ,
( $recursion === true || $recursion === 'true' || $recursion === '1' ) ? 'checked' : false ,
true
),
[
'div_class' => 'add-input-reverse' ,
'label_class' => 'label-thin' ,
]
2023-02-17 13:35:42 +01:00
);
2023-02-23 15:44:01 +01:00
$tableFilter -> data [ 'first_line' ][ 1 ] = html_print_label_input_block (
__ ( 'Module group' ),
html_print_select (
$rows_select ,
'modulegroup' ,
$modulegroup ,
'' ,
__ ( $is_none ),
- 1 ,
true ,
false ,
true ,
'' ,
false ,
'width: 100%;'
)
2023-02-17 13:35:42 +01:00
);
2023-02-23 15:44:01 +01:00
$tableFilter -> rowspan [ 'first_line' ][ 2 ] = 3 ;
$tableFilter -> data [ 'first_line' ][ 2 ] = html_print_label_input_block (
__ ( 'Tags' ),
$tagsElement
2023-02-17 13:35:42 +01:00
);
2023-02-23 15:44:01 +01:00
2023-02-17 13:35:42 +01:00
// Inputs for second line.
2023-02-23 15:44:01 +01:00
$tableFilter -> data [ 'second_line' ][ 0 ] = html_print_label_input_block (
__ ( 'Monitor status' ),
html_print_select (
$fields ,
'status' ,
$status ,
'' ,
__ ( $is_none ),
- 1 ,
true ,
false ,
true ,
'' ,
false ,
'width: 100%'
)
2023-02-17 13:35:42 +01:00
);
2023-02-23 15:44:01 +01:00
$tableFilter -> data [ 'second_line' ][ 1 ] = html_print_label_input_block (
__ ( 'Module name' ),
html_print_autocomplete_modules (
'ag_modulename' ,
$ag_modulename ,
false ,
true ,
'' ,
[],
2023-03-30 12:25:45 +02:00
true ,
0 ,
'30' ,
2023-02-23 15:44:01 +01:00
true
)
2023-02-17 13:35:42 +01:00
);
2023-02-23 15:44:01 +01:00
$tableFilter -> data [ 'third_line' ][ 0 ] = html_print_label_input_block (
__ ( 'Search' ),
html_print_input_text (
'ag_freestring' ,
$ag_freestring ,
'' ,
40 ,
30 ,
true
)
);
2023-02-17 13:35:42 +01:00
// Advanced filter.
$tableAdvancedFilter = new StdClass ();
$tableAdvancedFilter -> width = '100%' ;
$tableAdvancedFilter -> class = 'filters' ;
2023-02-23 15:44:01 +01:00
$tableAdvancedFilter -> size = [];
$tableAdvancedFilter -> size [ 0 ] = '33%' ;
$tableAdvancedFilter -> size [ 1 ] = '33%' ;
$tableAdvancedFilter -> size [ 2 ] = '33%' ;
$tableAdvancedFilter -> data [ 'advancedField_1' ][ 0 ] = html_print_label_input_block (
__ ( 'Server type' ),
html_print_select (
$typemodules ,
'moduletype' ,
$moduletype ,
'' ,
__ ( $is_none ),
'' ,
true ,
false ,
true ,
'' ,
false ,
'width: 100%;'
)
2023-02-17 13:35:42 +01:00
);
2023-02-23 15:44:01 +01:00
$tableAdvancedFilter -> data [ 'advancedField_1' ][ 1 ] = html_print_label_input_block (
__ ( 'Show monitors...' ),
html_print_select (
$monitor_options ,
'module_option' ,
$module_option ,
'' ,
'' ,
'' ,
true ,
false ,
true ,
'' ,
false ,
'width: 100%;'
)
);
2023-02-17 13:35:42 +01:00
2023-02-23 15:44:01 +01:00
$tableAdvancedFilter -> data [ 'advancedField_1' ][ 2 ] = html_print_label_input_block (
__ ( 'Min. hours in current status' ),
html_print_input_text ( 'min_hours_status' , $min_hours_val , '' , 12 , 20 , true )
);
2023-02-17 13:35:42 +01:00
2023-02-23 15:44:01 +01:00
$tableAdvancedFilter -> data [ 'advancedField_2' ][ 0 ] = html_print_label_input_block (
__ ( 'Data type' ),
2023-05-11 13:00:32 +02:00
html_print_select_from_sql ( $sqlModuleType , 'datatype' , $datatype , '' , __ ( 'All' ), 0 , true )
2023-02-23 15:44:01 +01:00
);
2023-02-17 13:35:42 +01:00
2023-02-23 15:44:01 +01:00
$tableAdvancedFilter -> data [ 'advancedField_2' ][ 1 ] = html_print_label_input_block (
__ ( 'Not condition' ),
html_print_div (
[
'class' => 'mrgn_5px mrgn_lft_0px mrgn_right_0px flex wrap' ,
'content' => html_print_input (
[
'type' => 'switch' ,
'name' => 'not_condition' ,
'return' => false ,
'checked' => ( $check_not_condition === true || $check_not_condition === 'true' || $check_not_condition === '1' ) ? 'checked' : false ,
'value' => 'NOT' ,
'id' => 'not_condition_switch' ,
'onclick' => 'changeNotConditionStatus(this)' ,
]
) . ui_print_input_placeholder (
__ ( 'If you check this option, those elements that do NOT meet any of the requirements will be shown' ),
true
),
],
true
)
);
2023-02-17 13:35:42 +01:00
2023-02-23 15:44:01 +01:00
$tableAdvancedFilter -> colspan [ 2 ][ 0 ] = 3 ;
2023-02-17 13:35:42 +01:00
$tableAdvancedFilter -> data [ 2 ][ 0 ] = ui_toggle (
2022-06-01 15:07:51 +02:00
$div_custom_fields ,
__ ( 'Agent custom fields' ),
'' ,
'' ,
true ,
true ,
'' ,
2023-02-23 15:44:01 +01:00
'white-box-content'
2022-06-01 15:07:51 +02:00
);
2019-01-30 16:18:44 +01:00
2023-02-23 15:44:01 +01:00
$tableFilter -> colspan [ 3 ][ 0 ] = 3 ;
2023-02-17 13:35:42 +01:00
$tableFilter -> data [ 3 ][ 0 ] = ui_toggle (
2022-06-01 15:07:51 +02:00
html_print_table (
2023-02-17 13:35:42 +01:00
$tableAdvancedFilter ,
2022-06-01 15:07:51 +02:00
true
),
2023-02-17 13:35:42 +01:00
'<span class="">' . __ ( 'Advanced options' ) . '</span>' ,
2022-06-01 15:07:51 +02:00
'' ,
'' ,
true ,
true ,
'' ,
2023-02-23 15:44:01 +01:00
'white-box-content'
2022-06-01 15:07:51 +02:00
);
2019-01-30 16:18:44 +01:00
2023-02-23 15:44:01 +01:00
$filters = '<form method="post" action="index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor&refr=' . $refr . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&module_option=' . $module_option . '&ag_modulename=' . $ag_modulename . '&moduletype=' . $moduletype . '&datatype=' . $datatype . '&status=' . $status . '&sort_field=' . $sortField . '&sort=' . $sort . '&pure=' . $config [ 'pure' ] . $ag_custom_fields_params . '">' ;
$filters .= html_print_table ( $tableFilter , true );
$buttons = html_print_submit_button (
__ ( 'Filter' ),
'uptbutton' ,
false ,
[
'icon' => 'search' ,
'mode' => 'mini' ,
],
true
2022-06-01 15:07:51 +02:00
);
2019-01-30 16:18:44 +01:00
2023-02-23 15:44:01 +01:00
$buttons .= html_print_button (
2023-01-19 10:49:48 +01:00
__ ( 'Load filter' ),
'load-filter' ,
false ,
'' ,
2023-02-17 13:35:42 +01:00
[
2023-02-20 14:35:32 +01:00
'icon' => 'wand' ,
'mode' => 'mini secondary' ,
'class' => 'float-left margin-right-2 sub config' ,
2023-02-17 13:35:42 +01:00
],
2023-01-19 10:49:48 +01:00
true
);
2024-01-02 11:18:53 +01:00
if ( check_acl ( $config [ 'id_user' ], 0 , 'AW' )) {
$buttons .= html_print_button (
__ ( 'Manage filter' ),
'save-filter' ,
false ,
'' ,
[
'icon' => 'wand' ,
'mode' => 'mini secondary' ,
'class' => 'float-left margin-right-2 sub wand' ,
],
true
);
}
2023-01-19 10:49:48 +01:00
2023-02-23 15:44:01 +01:00
$filters .= html_print_div (
2023-02-17 13:35:42 +01:00
[
2023-02-23 15:44:01 +01:00
'class' => 'action-buttons' ,
'content' => $buttons ,
2023-02-17 13:35:42 +01:00
],
2022-06-01 15:07:51 +02:00
true
);
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$filters .= '</form>' ;
2023-02-23 10:24:03 +01:00
ui_toggle (
$filters ,
'<span class="subsection_header_title">' . __ ( 'Filters' ) . '</span>' ,
'filter_form' ,
'' ,
true ,
false ,
'' ,
'white-box-content' ,
'box-flat white_table_graph fixed_filter_bar'
);
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
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 ;
2023-05-29 10:32:43 +02:00
$selectStatusChangeUp = false ;
$selectStatusChangeDown = false ;
2022-06-01 15:07:51 +02:00
$selectDataUp = false ;
$selectDataDown = false ;
$selectTimestampUp = false ;
$selectTimestampDown = false ;
$order = null ;
switch ( $sortField ) {
case 'agent_alias' :
2022-09-27 11:14:18 +02:00
$fieldForSorting = 'agent_alias' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
$selectAgentNameUp = $selected ;
$order = [
'field' => 'tagente.alias' ,
'order' => 'ASC' ,
];
2019-01-30 16:18:44 +01:00
break ;
2022-06-01 15:07:51 +02:00
case 'down' :
$selectAgentNameDown = $selected ;
$order = [
'field' => 'tagente.alias' ,
'order' => 'DESC' ,
];
2019-01-30 16:18:44 +01:00
break ;
2022-06-01 15:07:51 +02:00
}
break ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
case 'type' :
2022-09-29 00:24:31 +02:00
$fieldForSorting = 'module_type' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
$selectDataTypeUp = $selected ;
$order = [
'field' => 'tagente_modulo.id_tipo_modulo' ,
'order' => 'ASC' ,
];
break ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
case 'down' :
$selectDataTypeDown = $selected ;
$order = [
'field' => 'tagente_modulo.id_tipo_modulo' ,
'order' => 'DESC' ,
];
2019-01-30 16:18:44 +01:00
break ;
2022-06-01 15:07:51 +02:00
}
break ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
case 'moduletype' :
2022-09-29 00:24:31 +02:00
$fieldForSorting = 'module_type' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
$selectTypeUp = $selected ;
$order = [
'field' => 'tagente_modulo.id_modulo' ,
'order' => 'ASC' ,
];
break ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
case 'down' :
$selectTypeDown = $selected ;
$order = [
'field' => 'tagente_modulo.id_modulo' ,
'order' => 'DESC' ,
];
2019-01-30 16:18:44 +01:00
break ;
2022-06-01 15:07:51 +02:00
}
break ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
case 'module_name' :
2022-09-28 16:29:18 +02:00
$fieldForSorting = 'module_name' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
$selectModuleNameUp = $selected ;
$order = [
'field' => 'tagente_modulo.nombre' ,
'order' => 'ASC' ,
];
break ;
2021-05-06 17:08:11 +02:00
2022-06-01 15:07:51 +02:00
case 'down' :
$selectModuleNameDown = $selected ;
$order = [
'field' => 'tagente_modulo.nombre' ,
'order' => 'DESC' ,
];
2020-03-23 13:19:08 +01:00
break ;
2022-06-01 15:07:51 +02:00
}
break ;
2020-03-23 13:19:08 +01:00
2022-06-01 15:07:51 +02:00
case 'interval' :
2022-09-23 12:54:51 +02:00
$fieldForSorting = 'module_interval' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
$selectIntervalUp = $selected ;
$order = [
'field' => 'tagente_modulo.module_interval' ,
'order' => 'ASC' ,
];
break ;
2021-05-06 17:08:11 +02:00
2022-06-01 15:07:51 +02:00
case 'down' :
$selectIntervalDown = $selected ;
$order = [
'field' => 'tagente_modulo.module_interval' ,
'order' => 'DESC' ,
];
2020-03-23 13:19:08 +01:00
break ;
2022-06-01 15:07:51 +02:00
}
break ;
2020-03-23 13:19:08 +01:00
2022-06-01 15:07:51 +02:00
case 'status' :
2022-09-23 12:54:51 +02:00
$fieldForSorting = 'estado' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
$selectStatusUp = $selected ;
$order = [
'field' => 'tagente_estado.estado' ,
'order' => 'ASC' ,
];
break ;
2021-05-06 17:08:11 +02:00
2022-06-01 15:07:51 +02:00
case 'down' :
$selectStatusDown = $selected ;
$order = [
'field' => 'tagente_estado.estado' ,
'order' => 'DESC' ,
];
2019-01-30 16:18:44 +01:00
break ;
2022-06-01 15:07:51 +02:00
}
break ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
case 'last_status_change' :
2022-09-23 12:54:51 +02:00
$fieldForSorting = 'last_status_change' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
2023-05-29 10:32:43 +02:00
$selectStatusChangeUp = $selected ;
2022-06-01 15:07:51 +02:00
$order = [
'field' => 'tagente_estado.last_status_change' ,
'order' => 'ASC' ,
];
break ;
2021-05-06 17:08:11 +02:00
2022-06-01 15:07:51 +02:00
case 'down' :
2023-05-29 10:32:43 +02:00
$selectStatusChangeDown = $selected ;
2022-06-01 15:07:51 +02:00
$order = [
'field' => 'tagente_estado.last_status_change' ,
'order' => 'DESC' ,
];
2019-01-30 16:18:44 +01:00
break ;
2022-06-01 15:07:51 +02:00
}
break ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
case 'timestamp' :
2022-09-23 12:54:51 +02:00
$fieldForSorting = 'utimestamp' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
$selectTimestampUp = $selected ;
$order = [
'field' => 'tagente_estado.utimestamp' ,
'order' => 'ASC' ,
];
break ;
2021-05-06 17:08:11 +02:00
2022-06-01 15:07:51 +02:00
case 'down' :
$selectTimestampDown = $selected ;
$order = [
'field' => 'tagente_estado.utimestamp' ,
'order' => 'DESC' ,
];
2019-01-30 16:18:44 +01:00
break ;
2022-06-01 15:07:51 +02:00
}
break ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
case 'data' :
2022-09-23 12:54:51 +02:00
$fieldForSorting = 'datos' ;
2022-06-01 15:07:51 +02:00
switch ( $sort ) {
case 'up' :
$selectDataUp = $selected ;
2019-01-30 16:18:44 +01:00
$order = [
2022-06-01 15:07:51 +02:00
'field' => 'tagente_estado.datos' ,
2021-05-06 17:08:11 +02:00
'order' => 'ASC' ,
2019-01-30 16:18:44 +01:00
];
break ;
2022-06-01 15:07:51 +02:00
case 'down' :
$selectDataDown = $selected ;
$order = [
'field' => 'tagente_estado.datos' ,
'order' => 'DESC' ,
];
break ;
2019-01-30 16:18:44 +01:00
}
2022-06-01 15:07:51 +02:00
break ;
default :
2022-09-27 11:14:18 +02:00
$fieldForSorting = 'agent_alias' ;
2022-06-01 15:07:51 +02:00
$selectAgentNameUp = $selected ;
$selectAgentNameDown = false ;
$selectDataTypeUp = false ;
$selectDataTypeDown = false ;
$selectTypeUp = false ;
$selectTypeDown = false ;
$selectModuleNameUp = false ;
$selectModuleNameDown = false ;
$selectIntervalUp = false ;
$selectIntervalDown = false ;
$selectStatusUp = false ;
$selectStatusDown = false ;
2023-05-29 10:32:43 +02:00
$selectStatusChangeUp = false ;
$selectStatusChangeDown = false ;
2022-06-01 15:07:51 +02:00
$selectDataUp = false ;
$selectDataDown = false ;
$selectTimestampUp = false ;
$selectTimestampDown = false ;
$order = [
'field' => 'tagente.alias' ,
'order' => 'ASC' ,
];
break ;
}
2019-01-30 16:18:44 +01:00
2023-02-27 09:55:29 +01:00
$sql = ' SELECT
2020-10-29 12:55:44 +01:00
( SELECT GROUP_CONCAT ( ttag . name SEPARATOR \ ' , \ ' )
2018-08-02 13:02:33 +02:00
FROM ttag
WHERE ttag . id_tag IN (
SELECT ttag_module . id_tag
FROM ttag_module
2023-02-27 09:55:29 +01:00
WHERE ttag_module . id_agente_modulo = tagente_modulo . id_agente_modulo
)
) AS tags ,
2018-08-02 13:02:33 +02:00
tagente_modulo . id_agente_modulo ,
tagente_modulo . id_modulo ,
tagente . intervalo AS agent_interval ,
tagente . alias AS agent_alias ,
tagente . nombre AS agent_name ,
tagente_modulo . nombre AS module_name ,
tagente_modulo . history_data ,
tagente . id_grupo AS id_group ,
tagente . id_agente AS id_agent ,
tagente_modulo . id_tipo_modulo AS module_type ,
tagente_modulo . module_interval ,
tagente_estado . datos ,
tagente_estado . estado ,
2020-03-23 12:47:58 +01:00
tagente_estado . last_status_change ,
2018-08-02 13:02:33 +02:00
tagente_modulo . min_warning ,
tagente_modulo . max_warning ,
tagente_modulo . str_warning ,
tagente_modulo . unit ,
tagente_modulo . min_critical ,
tagente_modulo . max_critical ,
tagente_modulo . str_critical ,
tagente_modulo . extended_info ,
tagente_modulo . critical_inverse ,
tagente_modulo . warning_inverse ,
2019-01-30 16:18:44 +01:00
tagente_estado . utimestamp AS utimestamp '.$sql_from.$sql_conditions_all.'
2018-08-02 13:02:33 +02:00
GROUP BY tagente_modulo . id_agente_modulo
2019-01-30 16:18:44 +01:00
ORDER BY '.$order[' field '].' '.$order[' order '].'
2023-11-03 17:48:15 +01:00
LIMIT '.$limit_sql.' OFFSET ' . $offset ;
2012-11-29 18:34:51 +01:00
2023-02-27 09:55:29 +01:00
// We do not show the modules until the user searches with the filter.
2022-06-01 15:07:51 +02:00
if ( $autosearch ) {
2023-02-17 13:35:42 +01:00
if ( is_metaconsole () === false ) {
2022-06-01 15:07:51 +02:00
$result = db_get_all_rows_sql ( $sql );
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( $result === false ) {
$result = [];
} else {
2023-02-17 13:35:42 +01:00
$tablePagination = ui_pagination ( $count , false , $offset , 0 , true , 'offset' , false );
2022-06-01 15:07:51 +02:00
}
} else {
// For each server defined and not disabled.
$servers = db_get_all_rows_sql (
' SELECT *
2013-03-26 18:15:49 +01:00
FROM tmetaconsole_setup
2019-01-30 16:18:44 +01:00
WHERE disabled = 0 '
2022-06-01 15:07:51 +02:00
);
if ( $servers === false ) {
$servers = [];
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$result = [];
$count_modules = 0 ;
foreach ( $servers as $server ) {
2023-11-03 17:48:15 +01:00
try {
$node = new Node (( int ) $server [ 'id' ]);
$node -> connect ();
$result_server = db_get_all_rows_sql ( $sql );
if ( empty ( $result_server ) === false ) {
// 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' ];
}
2019-01-30 16:18:44 +01:00
2023-11-03 17:48:15 +01:00
$user = $config [ 'id_user' ];
$user_rot13 = str_rot13 ( $config [ 'id_user' ]);
$hashdata = $user . $pwd ;
$hashdata = md5 ( $hashdata );
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 ++ ;
}
2022-06-01 15:07:51 +02:00
2023-11-03 17:48:15 +01:00
$result = array_merge ( $result , $result_server );
2019-01-30 16:18:44 +01:00
}
2023-11-03 17:48:15 +01:00
usort ( $result , arrayOutputSorting ( $sort , $fieldForSorting ));
} catch ( \Exception $e ) {
$node -> disconnect ();
return ;
} finally {
$node -> disconnect ();
2019-01-30 16:18:44 +01:00
}
}
2022-06-01 15:07:51 +02:00
if ( $count_modules > $config [ 'block_size' ]) {
2023-12-19 16:50:36 +01:00
$show_count = false ;
if ( is_metaconsole () === true ) {
$show_count = true ;
}
$tablePagination = ui_pagination ( $count_modules , false , $offset , 0 , true , 'offset' , $show_count );
2019-01-30 16:18:44 +01:00
}
2022-06-01 15:07:51 +02:00
// Get number of elements of the pagination.
$result = ui_meta_get_subset_array ( $result , $inferior_limit , $superior_limit );
}
}
2023-02-27 09:55:29 +01:00
// Urls to sort the table.
$url_agent_name = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
$url_type = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
$url_module_name = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
$url_server_type = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
$url_interval = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
$url_status = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
2023-05-29 10:32:43 +02:00
$url_status_change = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
2023-02-27 09:55:29 +01:00
$url_data = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
$url_timestamp_up = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
$url_timestamp_down = 'index.php?sec=' . $section . '&sec2=operation/agentes/status_monitor' ;
$url_agent_name .= '&refr=' . $refr . '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
$url_type .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
$url_module_name .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
$url_server_type .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
$url_interval .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
$url_status .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
2023-05-29 10:32:43 +02:00
$url_status_change .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
2023-02-27 09:55:29 +01:00
$url_data .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
$url_timestamp_up .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
$url_timestamp_down .= '&datatype=' . $datatype . '&moduletype=' . $moduletype . '&refr=' . $refr . '&modulegroup=' . $modulegroup . '&offset=' . $offset . '&ag_group=' . $ag_group . '&ag_freestring=' . $ag_freestring . '&ag_modulename=' . $ag_modulename . '&status=' . $status . $ag_custom_fields_params ;
// Holy god...
$url_agent_name .= '&recursion=' . $recursion ;
$url_type .= '&recursion=' . $recursion ;
$url_module_name .= '&recursion=' . $recursion ;
$url_server_type .= '&recursion=' . $recursion ;
$url_interval .= '&recursion=' . $recursion ;
$url_status .= '&recursion=' . $recursion ;
2023-05-29 10:32:43 +02:00
$url_status_change .= '&recursion=' . $recursion ;
2023-02-27 09:55:29 +01:00
$url_data .= '&recursion=' . $recursion ;
$url_timestamp_up .= '&recursion=' . $recursion ;
$url_timestamp_down .= '&recursion=' . $recursion ;
$url_agent_name .= '&sort_field=agent_alias&sort=' ;
$url_type .= '&sort_field=type&sort=' ;
$url_module_name .= '&sort_field=module_name&sort=' ;
$url_server_type .= '&sort_field=moduletype&sort=' ;
$url_interval .= '&sort_field=interval&sort=' ;
$url_status .= '&sort_field=status&sort=' ;
2023-05-29 10:32:43 +02:00
$url_status_change .= '&sort_field=last_status_change&sort=' ;
2023-02-27 09:55:29 +01:00
$url_data .= '&sort_field=data&sort=' ;
$url_timestamp_up .= '&sort_field=timestamp&sort=up' ;
$url_timestamp_down .= '&sort_field=timestamp&sort=down' ;
// Start Build List Result.
2023-02-17 13:35:42 +01:00
if ( empty ( $result ) === false ) {
2023-02-20 14:35:32 +01:00
if ( is_metaconsole () === true ) {
html_print_action_buttons (
2023-03-09 11:25:43 +01:00
'' ,
2023-02-20 14:35:32 +01:00
[
'type' => 'form_action' ,
'right_content' => $tablePagination ,
]
);
2022-06-01 15:07:51 +02:00
}
$table = new StdClass ();
$table -> cellpadding = 0 ;
$table -> cellspacing = 0 ;
2023-02-17 13:35:42 +01:00
$table -> styleTable = 'margin: 0 10px; width: -webkit-fill-available; width: -moz-available' ;
$table -> class = 'info_table tactical_table' ;
$table -> id = 'monitors_view' ;
2022-06-01 15:07:51 +02:00
$table -> head = [];
$table -> data = [];
$table -> size = [];
$table -> align = [];
$show_fields = explode ( ',' , $config [ 'status_monitor_fields' ]);
if ( in_array ( 'policy' , $show_fields )) {
if ( $isFunctionPolicies !== ENTERPRISE_NOT_HOOK ) {
$table -> head [ 0 ] = '<span title=\'' . __ ( 'Policy' ) . '\'>' . __ ( 'P.' ) . '</span>' ;
}
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'agent' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 1 ] = '<span>' . __ ( 'Agent' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> head [ 1 ] .= ui_get_sorting_arrows ( $url_agent_name . 'up' , $url_agent_name . 'down' , $selectAgentNameUp , $selectAgentNameDown );
}
2019-01-09 12:27:22 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'data_type' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 2 ] = '<span>' . __ ( 'Data Type' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> head [ 2 ] .= ui_get_sorting_arrows ( $url_type . 'up' , $url_type . 'down' , $selectDataTypeUp , $selectDataTypeDown );
2023-02-17 13:35:42 +01:00
$table -> headstyle [ 2 ] = 'text-align: center' ;
$table -> align [ 2 ] = 'center' ;
2022-06-01 15:07:51 +02:00
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'module_name' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 3 ] = '<span>' . __ ( 'Module name' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> head [ 3 ] .= ui_get_sorting_arrows ( $url_module_name . 'up' , $url_module_name . 'down' , $selectModuleNameUp , $selectModuleNameDown );
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'server_type' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 4 ] = '<span>' . __ ( 'Server type' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> head [ 4 ] .= ui_get_sorting_arrows ( $url_server_type . 'up' , $url_server_type . 'down' , $selectTypeUp , $selectTypeDown );
2023-02-17 13:35:42 +01:00
$table -> headstyle [ 4 ] = 'text-align: center' ;
$table -> align [ 4 ] = 'center' ;
2022-06-01 15:07:51 +02:00
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'interval' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 5 ] = '<span>' . __ ( 'Interval' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> head [ 5 ] .= ui_get_sorting_arrows ( $url_interval . 'up' , $url_interval . 'down' , $selectIntervalUp , $selectIntervalDown );
$table -> align [ 5 ] = 'left' ;
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'status' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 6 ] = '<span>' . __ ( 'Status' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> head [ 6 ] .= ui_get_sorting_arrows ( $url_status . 'up' , $url_status . 'down' , $selectStatusUp , $selectStatusDown );
$table -> align [ 6 ] = 'left' ;
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'last_status_change' , $show_fields )) {
2023-02-17 13:35:42 +01:00
$table -> head [ 7 ] = '<span>' . __ ( 'Last status change' ) . '</span>' ;
2023-05-29 10:32:43 +02:00
$table -> head [ 7 ] .= ui_get_sorting_arrows ( $url_status_change . 'up' , $url_status_change . 'down' , $selectStatusChangeUp , $selectStatusChangeDown );
2023-02-17 13:35:42 +01:00
$table -> headstyle [ 7 ] = 'text-align: center' ;
$table -> align [ 7 ] = 'center' ;
2022-06-01 15:07:51 +02:00
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'graph' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 8 ] = '<span>' . __ ( 'Graph' ) . '</span>' ;
$table -> headstyle [ 8 ] = 'text-align: center' ;
$table -> align [ 8 ] = 'center' ;
2022-06-01 15:07:51 +02:00
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'warn' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 9 ] = '<span>' . __ ( 'W/C' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> align [ 9 ] = 'left' ;
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'data' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 10 ] = '<span>' . __ ( 'Data' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> align [ 10 ] = 'left' ;
if ( is_metaconsole ()) {
$table -> head [ 10 ] .= ui_get_sorting_arrows ( $url_data . 'up' , $url_data . 'down' , $selectDataUp , $selectDataDown );
}
}
2019-02-25 14:42:48 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'timestamp' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$table -> head [ 11 ] = '<span>' . __ ( 'Timestamp' ) . '</span>' ;
2022-06-01 15:07:51 +02:00
$table -> head [ 11 ] .= ui_get_sorting_arrows ( $url_timestamp_up , $url_timestamp_down , $selectTimestampUp , $selectTimestampDown );
$table -> align [ 11 ] = 'left' ;
}
2019-01-30 16:18:44 +01:00
2023-02-06 16:44:14 +01:00
if ( check_acl ( $config [ 'id_user' ], 0 , 'AR' )) {
$actions_list = true ;
$table -> head [ 12 ] = __ ( 'Actions' );
$table -> align [ 12 ] = 'left' ;
}
2022-06-01 15:07:51 +02:00
$id_type_web_content_string = db_get_value (
'id_tipo' ,
'ttipo_modulo' ,
'nombre' ,
'web_content_string'
);
2019-01-30 16:18:44 +01:00
2023-05-05 13:04:02 +02:00
$inc_id = 0 ;
2022-06-01 15:07:51 +02:00
foreach ( $result as $row ) {
// Avoid unset, null and false value.
2023-02-17 13:35:42 +01:00
if ( empty ( $row [ 'server_name' ]) === true ) {
2022-06-01 15:07:51 +02:00
$row [ 'server_name' ] = '' ;
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$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 ,
]
);
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
// Fixed the goliat sends the strings from web.
// Without HTML entities.
if ( $is_web_content_string ) {
$row [ 'datos' ] = io_safe_input ( $row [ 'datos' ]);
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
// Fixed the data from Selenium Plugin.
if ( $row [ 'datos' ] != strip_tags ( $row [ 'datos' ])) {
$row [ 'datos' ] = io_safe_input ( $row [ 'datos' ]);
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$data = [];
2019-02-25 14:42:48 +01:00
2022-06-01 15:07:51 +02:00
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 ;
}
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$policyInfo = policies_info_module_policy ( $row [ 'id_agente_modulo' ]);
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( $policyInfo === false ) {
$data [ 0 ] = '' ;
} else {
$linked = policies_is_module_linked ( $row [ 'id_agente_modulo' ]);
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$adopt = false ;
if ( policies_is_module_adopt ( $row [ 'id_agente_modulo' ])) {
$adopt = true ;
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( $linked ) {
if ( $adopt ) {
$img = 'images/policies_brick.png' ;
$title = __ ( '(Adopt) ' ) . $policyInfo [ 'name_policy' ];
} else {
$img = 'images/policies_mc.png' ;
$title = $policyInfo [ 'name_policy' ];
2019-02-25 14:42:48 +01:00
}
2022-06-01 15:07:51 +02:00
} 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' ];
2019-02-25 14:42:48 +01:00
}
2019-01-30 16:18:44 +01:00
}
2019-02-25 14:42:48 +01:00
2022-06-01 15:07:51 +02:00
if ( is_metaconsole ()) {
$data [ 0 ] = '<a href="?sec=gmodules&sec2=advanced/policymanager&id=' . $policyInfo [ 'id_policy' ] . '">' . html_print_image ( $img , true , [ 'title' => $title ]) . '</a>' ;
2019-01-30 16:18:44 +01:00
} else {
2022-06-01 15:07:51 +02:00
$data [ 0 ] = '<a href="?sec=gmodules&sec2=enterprise/godmode/policies/policies&id=' . $policyInfo [ 'id_policy' ] . '">' . html_print_image ( $img , true , [ 'title' => $title ]) . '</a>' ;
2019-01-30 16:18:44 +01:00
}
}
2022-06-01 15:07:51 +02:00
if ( is_metaconsole ()) {
metaconsole_restore_db ();
}
}
}
2021-05-06 17:08:11 +02:00
2022-06-01 15:07:51 +02:00
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
2023-05-05 13:04:02 +02:00
if ( is_metaconsole () === true ) {
2023-11-30 08:45:34 +01:00
echo " <form id='agent-redirection- " . $inc_id . " ' method='POST' target='_blank' action=' " . $row [ 'server_url' ] . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $row [ 'id_agent' ] . " '> " ;
2023-05-05 13:04:02 +02:00
html_print_input_hidden (
'loginhash' ,
'auto' ,
false
);
html_print_input_hidden (
'loginhash_data' ,
$row [ 'hashdata' ],
false
);
html_print_input_hidden (
'loginhash_user' ,
str_rot13 ( $row [ 'user' ]),
false
);
echo '</form>' ;
2024-02-20 08:26:02 +01:00
$agent_link = " <a target='_blank' href=' " . $row [ 'server_url' ] . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&loginhash=auto&loginhash_data=' . $row [ 'hashdata' ] . '&loginhash_user=' . str_rot13 ( $row [ 'user' ]) . '&id_agente=' . $row [ 'id_agent' ] . " '> " ;
2023-05-05 13:04:02 +02:00
2022-06-01 15:07:51 +02:00
$agent_alias = ui_print_truncate_text (
$agent_alias ,
'agent_small' ,
false ,
true ,
2023-01-20 08:02:58 +01:00
true ,
2022-06-01 15:07:51 +02:00
'[…]' ,
'font-size:7.5pt;'
);
if ( can_user_access_node ()) {
$data [ 1 ] = $agent_link . '<b>' . $agent_alias . '</b></a>' ;
} else {
$data [ 1 ] = $agent_alias ;
2019-02-25 14:42:48 +01:00
}
2022-06-01 15:07:51 +02:00
} else {
$data [ 1 ] = '<strong><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $row [ 'id_agent' ] . '">' ;
$data [ 1 ] .= ui_print_truncate_text ( $agent_alias , 'agent_medium' , false , true , false , '[…]' , 'font-size:7.5pt;' );
$data [ 1 ] .= '</a></strong>' ;
}
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'data_type' , $show_fields ) || is_metaconsole ()) {
2023-02-17 13:35:42 +01:00
$data [ 2 ] = html_print_image ( 'images/' . modules_show_icon_type ( $row [ 'module_type' ]), true , [ 'class' => 'invert_filter main_menu_icon' ]);
2022-06-01 15:07:51 +02:00
$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 ;
2023-02-17 13:35:42 +01:00
if ( is_metaconsole () === true ) {
2022-06-01 15:07:51 +02:00
if ( ! can_user_access_node ()) {
$show_edit_icon = false ;
2019-02-25 14:42:48 +01:00
}
2019-01-30 16:18:44 +01:00
2023-02-17 13:35:42 +01:00
$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' ]);
2022-06-01 15:07:51 +02:00
} 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' ;
2019-01-30 16:18:44 +01:00
}
2022-06-01 15:07:51 +02:00
}
}
2019-01-30 16:18:44 +01:00
2023-02-17 13:35:42 +01:00
if ( in_array ( 'module_name' , $show_fields ) === true || is_metaconsole () === true ) {
$data [ 3 ] = html_print_anchor (
[
2024-02-20 08:26:02 +01:00
'target' => '_blank' ,
2023-02-17 13:35:42 +01:00
'href' => ( $url_edit_module ? ? '#' ),
'content' => ui_print_truncate_text ( $row [ 'module_name' ], 'module_small' , false , true , true ),
],
true
);
2019-01-30 16:18:44 +01:00
2023-02-17 13:35:42 +01:00
if ( empty ( $row [ 'extended_info' ]) === false ) {
2022-06-01 15:07:51 +02:00
$data [ 3 ] .= ui_print_help_tip ( $row [ 'extended_info' ], true , '/images/default_list.png' );
}
2021-06-14 08:26:33 +02:00
2023-02-17 13:35:42 +01:00
if ( empty ( $row [ 'tags' ]) === false ) {
2022-06-01 15:07:51 +02:00
$data [ 3 ] .= html_print_image (
2023-02-17 13:35:42 +01:00
'/images/tag@svg.svg' ,
2022-06-01 15:07:51 +02:00
true ,
[
'title' => $row [ 'tags' ],
2023-03-16 18:51:54 +01:00
'class' => 'invert_filter main_menu_icon' ,
2022-06-01 15:07:51 +02:00
]
);
}
}
2019-01-30 16:18:44 +01:00
2022-12-19 16:38:47 +01:00
if ( in_array ( 'server_type' , $show_fields ) === true || is_metaconsole () === true ) {
$data [ 4 ] = ui_print_servertype_icon (( int ) $row [ 'id_modulo' ]);
2022-06-01 15:07:51 +02:00
}
2023-02-17 13:35:42 +01:00
if ( in_array ( 'interval' , $show_fields ) === true || is_metaconsole () === true ) {
$data [ 5 ] = (( int ) $row [ 'module_interval' ] === 0 ) ? human_time_description_raw ( $row [ 'agent_interval' ]) : human_time_description_raw ( $row [ 'module_interval' ]);
2022-06-01 15:07:51 +02:00
}
if ( in_array ( 'status' , $show_fields ) || is_metaconsole ()) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] = '<div class="status_rounded_rectangles">' ;
2023-02-17 13:35:42 +01:00
if ( $row [ 'utimestamp' ] === 0 && (( $row [ 'module_type' ] < 21
2022-06-01 15:07:51 +02:00
|| $row [ 'module_type' ] > 23 ) && $row [ 'module_type' ] != 100 )
) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_NO_DATA ,
__ ( 'NOT INIT' ),
true
);
} else if ( $row [ 'estado' ] == 0 ) {
if ( is_numeric ( $row [ 'datos' ])) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_OK ,
2022-10-26 18:25:16 +02:00
__ ( 'NORMAL' ) . ': ' . remove_right_zeros ( number_format ( $row [ 'datos' ], $config [ 'graph_precision' ], $config [ 'decimal_separator' ], $config [ 'thousand_separator' ])),
2022-06-01 15:07:51 +02:00
true
);
} else {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_OK ,
__ ( 'NORMAL' ) . ': ' . htmlspecialchars ( $row [ 'datos' ]),
true
);
}
} else if ( $row [ 'estado' ] == 1 ) {
if ( is_numeric ( $row [ 'datos' ])) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_CRITICAL ,
__ ( 'CRITICAL' ) . ': ' . remove_right_zeros (
2022-10-26 18:25:16 +02:00
number_format (
$row [ 'datos' ],
$config [ 'graph_precision' ],
$config [ 'decimal_separator' ],
$config [ 'thousand_separator' ]
)
2022-06-01 15:07:51 +02:00
),
true
);
} else {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_CRITICAL ,
__ ( 'CRITICAL' ) . ': ' . htmlspecialchars ( $row [ 'datos' ]),
true
);
}
} else if ( $row [ 'estado' ] == 2 ) {
if ( is_numeric ( $row [ 'datos' ])) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_WARNING ,
__ ( 'WARNING' ) . ': ' . remove_right_zeros (
2022-10-26 18:25:16 +02:00
number_format (
$row [ 'datos' ],
$config [ 'graph_precision' ],
$config [ 'decimal_separator' ],
$config [ 'thousand_separator' ]
)
2022-06-01 15:07:51 +02:00
),
true
);
} else {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_WARNING ,
__ ( 'WARNING' ) . ': ' . htmlspecialchars ( $row [ 'datos' ]),
true
);
}
} else if ( $row [ 'estado' ] == 3 ) {
if ( is_numeric ( $row [ 'datos' ])) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_UNKNOWN ,
__ ( 'UNKNOWN' ) . ': ' . remove_right_zeros (
2022-10-26 18:25:16 +02:00
number_format (
$row [ 'datos' ],
$config [ 'graph_precision' ],
$config [ 'decimal_separator' ],
$config [ 'thousand_separator' ]
)
2022-06-01 15:07:51 +02:00
),
true
);
} else {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_UNKNOWN ,
__ ( 'UNKNOWN' ) . ': ' . htmlspecialchars ( $row [ 'datos' ]),
true
);
}
} else if ( $row [ 'estado' ] == 4 ) {
if ( is_numeric ( $row [ 'datos' ])) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_NO_DATA ,
__ ( 'NO DATA' ) . ': ' . remove_right_zeros (
2022-10-26 18:25:16 +02:00
number_format (
$row [ 'datos' ],
$config [ 'graph_precision' ],
$config [ 'decimal_separator' ],
$config [ 'thousand_separator' ]
)
2022-06-01 15:07:51 +02:00
),
true
);
} else {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_NO_DATA ,
__ ( 'NO DATA' ) . ': ' . htmlspecialchars ( $row [ 'datos' ]),
true
);
}
} else {
$last_status = modules_get_agentmodule_last_status (
$row [ 'id_agente_modulo' ]
);
2023-02-20 15:58:41 +01:00
2022-06-01 15:07:51 +02:00
switch ( $last_status ) {
case 0 :
2021-06-14 11:02:57 +02:00
if ( is_numeric ( $row [ 'datos' ])) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_UNKNOWN ,
2022-10-26 18:25:16 +02:00
__ ( 'UNKNOWN' ) . ' - ' . __ ( 'Last status' ) . ' ' . __ ( 'NORMAL' ) . ': ' . remove_right_zeros ( number_format ( $row [ 'datos' ], $config [ 'graph_precision' ], $config [ 'decimal_separator' ], $config [ 'thousand_separator' ])),
2021-06-14 11:02:57 +02:00
true
);
} else {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_UNKNOWN ,
__ ( 'UNKNOWN' ) . ' - ' . __ ( 'Last status' ) . ' ' . __ ( 'NORMAL' ) . ': ' . htmlspecialchars ( $row [ 'datos' ]),
2021-06-14 11:02:57 +02:00
true
);
}
2022-06-01 15:07:51 +02:00
break ;
case 1 :
2021-06-14 11:02:57 +02:00
if ( is_numeric ( $row [ 'datos' ])) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2021-06-14 11:02:57 +02:00
STATUS_MODULE_UNKNOWN ,
2022-10-26 18:25:16 +02:00
__ ( 'UNKNOWN' ) . ' - ' . __ ( 'Last status' ) . ' ' . __ ( 'CRITICAL' ) . ': ' . remove_right_zeros ( number_format ( $row [ 'datos' ], $config [ 'graph_precision' ], $config [ 'decimal_separator' ], $config [ 'thousand_separator' ])),
2021-06-14 11:02:57 +02:00
true
);
} else {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2021-06-14 11:02:57 +02:00
STATUS_MODULE_UNKNOWN ,
2022-06-01 15:07:51 +02:00
__ ( 'UNKNOWN' ) . ' - ' . __ ( 'Last status' ) . ' ' . __ ( 'CRITICAL' ) . ': ' . htmlspecialchars ( $row [ 'datos' ]),
2021-06-14 11:02:57 +02:00
true
);
}
2022-06-01 15:07:51 +02:00
break ;
case 2 :
2021-06-14 11:02:57 +02:00
if ( is_numeric ( $row [ 'datos' ])) {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_UNKNOWN ,
2022-10-26 18:25:16 +02:00
__ ( 'UNKNOWN' ) . ' - ' . __ ( 'Last status' ) . ' ' . __ ( 'WARNING' ) . ': ' . remove_right_zeros ( number_format ( $row [ 'datos' ], $config [ 'graph_precision' ], $config [ 'decimal_separator' ], $config [ 'thousand_separator' ])),
2021-06-14 11:02:57 +02:00
true
);
} else {
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= ui_print_status_image (
2022-06-01 15:07:51 +02:00
STATUS_MODULE_UNKNOWN ,
__ ( 'UNKNOWN' ) . ' - ' . __ ( 'Last status' ) . ' ' . __ ( 'WARNING' ) . ': ' . htmlspecialchars ( $row [ 'datos' ]),
2021-06-14 11:02:57 +02:00
true
);
}
2022-06-01 15:07:51 +02:00
break ;
2021-06-14 11:02:57 +02:00
}
2022-06-01 15:07:51 +02:00
}
2023-02-20 15:58:41 +01:00
$data [ 6 ] .= '</div>' ;
2022-06-01 15:07:51 +02:00
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
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' );
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'graph' , $show_fields ) || is_metaconsole ()) {
$data [ 8 ] = '' ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$acl_graphs = false ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
// 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 ;
}
2022-01-18 13:01:49 +01:00
2022-06-01 15:07:51 +02:00
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 ;
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$graph_type = return_graphtype ( $row [ 'module_type' ]);
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$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 ;
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$graph_params = [
'type' => $graph_type ,
'period' => SECONDS_1DAY ,
'id' => $row [ 'id_agente_modulo' ],
'refresh' => SECONDS_10MINUTES ,
];
2022-01-18 13:01:49 +01:00
2022-06-01 15:07:51 +02:00
if ( $tresholds === true || $graph_type === 'boolean' ) {
$graph_params [ 'histogram' ] = 1 ;
}
2019-01-30 16:18:44 +01:00
2023-02-17 13:35:42 +01:00
if ( is_metaconsole () === true && isset ( $row [ 'server_id' ]) === true ) {
2022-06-01 15:07:51 +02:00
// Set the server id.
$graph_params [ 'server' ] = $row [ 'server_id' ];
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$graph_params_str = http_build_query ( $graph_params );
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$link = 'winopeng_var(\'' . $url . '?' . $graph_params_str . '\',\'' . $win_handle . '\', 800, 480)' ;
2019-01-30 16:18:44 +01:00
2023-02-17 13:35:42 +01:00
$graphIconsContent = [];
$graphIconsContent [] = get_module_realtime_link_graph ( $row );
2022-01-18 13:01:49 +01:00
2022-06-01 15:07:51 +02:00
if ( $tresholds === true || $graph_type === 'boolean' ) {
2023-02-17 13:35:42 +01:00
$graphIconsContent [] = html_print_anchor (
2022-06-01 15:07:51 +02:00
[
2023-02-17 13:35:42 +01:00
'href' => 'javascript:' . $link ,
'content' => html_print_image (
'images/event-history.svg' ,
true ,
[
'border' => '0' ,
'alt' => '' ,
'class' => 'invert_filter main_menu_icon' ,
]
),
],
true
);
2022-06-01 15:07:51 +02:00
}
2022-02-02 13:51:04 +01:00
2023-02-17 13:35:42 +01:00
if ( is_snapshot_data ( $row [ 'datos' ]) === false ) {
2022-06-01 15:07:51 +02:00
if ( $tresholds === true || $graph_type === 'boolean' ) {
unset ( $graph_params [ 'histogram' ]);
}
2022-02-02 13:51:04 +01:00
2022-06-01 15:07:51 +02:00
$graph_params_str = http_build_query ( $graph_params );
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$link = 'winopeng_var(\'' . $url . '?' . $graph_params_str . '\',\'' . $win_handle . '\', 800, 480)' ;
2023-02-17 13:35:42 +01:00
$graphIconsContent [] = html_print_anchor (
[
'href' => 'javascript:' . $link ,
'content' => html_print_image ( 'images/module-graph.svg' , true , [ 'border' => '0' , 'alt' => '' , 'class' => 'invert_filter main_menu_icon' ]),
],
true
);
2021-06-14 10:52:50 +02:00
}
2019-02-25 14:42:48 +01:00
2023-02-17 13:35:42 +01:00
$graphIconsContent [] = html_print_anchor (
2022-06-01 15:07:51 +02:00
[
2023-02-17 13:35:42 +01:00
'href' => 'javascript: show_module_detail_dialog(' . $row [ 'id_agente_modulo' ] . ', ' . $row [ 'id_agent' ] . ', \'' . $row [ 'server_name' ] . '\', 0, ' . SECONDS_1DAY . ', \'' . $row [ 'module_name' ] . '\')' ,
'content' => html_print_image (
'images/simple-value.svg' ,
true ,
[
'border' => '0' ,
'alt' => '' ,
'class' => 'invert_filter main_menu_icon' ,
]
),
],
true
);
2019-02-25 14:42:48 +01:00
2023-02-17 13:35:42 +01:00
$graphIconsContent [] = '<span id=\'hidden_name_module_' . $row [ 'id_agente_modulo' ] . ' \ '
2022-06-01 15:07:51 +02:00
class = \ 'invisible\'>' . $row [ 'module_name' ] . '</span>' ;
2023-02-17 13:35:42 +01:00
$data [ 8 ] = html_print_div (
[
'class' => 'table_action_buttons' ,
'content' => implode ( '' , $graphIconsContent ),
],
true
);
2022-06-01 15:07:51 +02:00
}
}
2021-06-14 10:52:50 +02:00
2022-06-01 15:07:51 +02:00
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' ];
2021-06-14 11:02:57 +02:00
}
2022-06-01 15:07:51 +02:00
break ;
default :
2021-06-14 11:02:57 +02:00
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 {
2022-10-26 18:25:16 +02:00
$salida = remove_right_zeros ( number_format ( $row [ 'datos' ], $config [ 'graph_precision' ], $config [ 'decimal_separator' ], $config [ 'thousand_separator' ]));
2021-06-14 11:02:57 +02:00
}
break ;
2019-01-30 16:18:44 +01:00
2021-06-14 11:02:57 +02:00
default :
2022-10-26 18:25:16 +02:00
$salida = remove_right_zeros ( number_format ( $row [ 'datos' ], $config [ 'graph_precision' ], $config [ 'decimal_separator' ], $config [ 'thousand_separator' ]));
2021-06-14 11:02:57 +02:00
break ;
}
2022-06-01 15:07:51 +02:00
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 {
2022-10-26 18:25:16 +02:00
$salida = remove_right_zeros ( number_format ( $row [ 'datos' ], $config [ 'graph_precision' ], $config [ 'decimal_separator' ], $config [ 'thousand_separator' ]));
2022-06-01 15:07:51 +02:00
}
break ;
default :
2022-10-26 18:25:16 +02:00
$salida = remove_right_zeros ( number_format ( $row [ 'datos' ], $config [ 'graph_precision' ], $config [ 'decimal_separator' ], $config [ 'thousand_separator' ]));
2022-06-01 15:07:51 +02:00
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 .= ' ' . '<i>' . io_safe_output ( $row [ 'unit' ]) . '</i>' ;
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 <i>.
$text_aux = explode ( '<a' , $salida );
$match = preg_replace ( '/(<i>|<\/i>|<i|<\/i|i>|\/i>|<|>)/' , '' , $text_aux [ 0 ]);
$salida = $match . '<a' . $text_aux [ 1 ];
} else {
$salida = ui_print_truncate_text ( $salida , 'agent_small' , true , true , false , '[…]' , 'font-size:7.5pt;' );
2021-06-14 10:52:50 +02:00
}
2022-06-01 15:07:51 +02:00
}
}
} else {
// Fixed the goliat sends the strings from web.
// Without HTML entities.
if ( $is_web_content_string ) {
$module_value = $row [ 'datos' ];
} else {
$module_value = io_safe_output ( $row [ 'datos' ]);
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
$is_snapshot = is_snapshot_data ( $module_value );
$is_large_image = is_text_to_black_string ( $module_value );
if (( $config [ 'command_snapshot' ]) && ( $is_snapshot || $is_large_image )) {
$link = ui_get_snapshot_link (
[
'id_module' => $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 ) {
2023-01-27 13:43:23 +01:00
if (( empty ( $module_value ) === true || $module_value == 0 ) && ! $sub_string ) {
2022-06-01 15:07:51 +02:00
$salida = 0 ;
} else {
2021-06-14 11:02:57 +02:00
$data_macro = modules_get_unit_macro ( $row [ 'datos' ], $row [ 'unit' ]);
if ( $data_macro ) {
$salida = $data_macro ;
2021-06-14 10:52:50 +02:00
} else {
2022-06-01 15:07:51 +02:00
$salida = $row [ 'datos' ];
2021-06-14 10:52:50 +02:00
}
2019-02-25 14:42:48 +01:00
}
2021-06-14 10:52:50 +02:00
} else {
2021-06-14 11:02:57 +02:00
// Fixed the goliat sends the strings from web.
// Without HTML entities.
if ( $is_web_content_string ) {
2022-06-01 15:07:51 +02:00
$sub_string = substr ( $row [ 'datos' ], 0 , 12 );
2021-06-14 11:02:57 +02:00
} else {
2022-06-01 15:07:51 +02:00
// 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 );
}
2021-06-14 11:02:57 +02:00
}
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( $module_value == $sub_string ) {
$salida = $module_value ;
2021-06-14 11:02:57 +02:00
} else {
2022-06-01 15:07:51 +02:00
$salida = '<span ' . " id='hidden_value_module_ " . $row [ 'id_agente_modulo' ] . " '
2021-03-11 15:40:23 +01:00
class = 'invisible' > " . $module_value .'</span>'.'<span '. " id = 'value_module_".$row[' id_agente_modulo ']."'
title = '".$module_value."' " . " class = 'nowrap' > " .'<span id= " value_module_text_ '.$row[' id_agente_modulo '].' " >'. $sub_string .'</span> '. " < a href = 'javascript: toggle_full_value(".$row[' id_agente_modulo '].")' > " .html_print_image('images/rosette.png', true).'</a></span>';
2019-02-25 14:42:48 +01:00
}
2019-01-30 16:18:44 +01:00
}
}
2022-06-01 15:07:51 +02:00
}
}
2019-02-25 14:42:48 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'data' , $show_fields ) || is_metaconsole ()) {
$data [ 10 ] = $salida ;
}
2019-02-25 14:42:48 +01:00
2022-06-01 15:07:51 +02:00
if ( in_array ( 'timestamp' , $show_fields ) || is_metaconsole ()) {
if ( $row [ 'module_interval' ] > 0 ) {
$interval = $row [ 'module_interval' ];
} else {
$interval = $row [ 'agent_interval' ];
}
2021-06-14 11:02:57 +02:00
2022-06-01 15:07:51 +02:00
if ( $row [ 'estado' ] == 3 ) {
$option = [
'html_attr' => 'class="redb"' ,
'style' => 'font-size:7pt;' ,
];
} else {
$option = [ 'style' => 'font-size:7pt;' ];
}
2021-06-14 11:02:57 +02:00
2022-06-01 15:07:51 +02:00
$data [ 11 ] = ui_print_timestamp ( $row [ 'utimestamp' ], true , $option );
}
2019-01-30 16:18:44 +01:00
2023-02-06 16:44:14 +01:00
if ( check_acl_one_of_groups ( $config [ 'id_user' ], $agent_groups , 'AW' )) {
2023-05-05 13:04:02 +02:00
$table -> cellclass [][ 2 ] = 'action_buttons' ;
2023-02-27 13:41:44 +01:00
if ( is_metaconsole () === true ) {
2023-11-30 08:45:34 +01:00
echo " <form id='agent-edit-redirection- " . $inc_id . " ' target='_blank' method='POST' action=' " . $row [ 'server_url' ] . " index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&edit_module=1'> " ;
2023-05-05 13:04:02 +02:00
html_print_input_hidden (
'id_agente' ,
$row [ 'id_agent' ],
false
);
html_print_input_hidden (
'id_agent_module' ,
$row [ 'id_agente_modulo' ],
false
);
html_print_input_hidden (
'loginhash' ,
'auto' ,
false
);
html_print_input_hidden (
'loginhash_data' ,
$row [ 'hashdata' ],
false
);
html_print_input_hidden (
'loginhash_user' ,
str_rot13 ( $row [ 'user' ]),
false
);
2023-02-27 13:41:44 +01:00
2023-05-05 13:04:02 +02:00
echo '</form>' ;
2023-11-30 08:45:34 +01:00
$url_edit_module = $row [ 'server_url' ];
$url_edit_module .= 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&' ;
$url_edit_module .= '&id_agente=' . $row [ 'id_agent' ];
$url_edit_module .= '&tab=module&id_agent_module=' . $row [ 'id_agente_modulo' ] . '&edit_module=1' ;
$url_edit_module .= '&loginhash=auto&loginhash_data=' . $row [ 'hashdata' ];
$url_edit_module .= '&loginhash_user=' . str_rot13 ( $row [ 'user' ]);
2024-02-20 08:26:02 +01:00
$agent_link = " <a href=' " . $url_edit_module . " '> " ;
2023-02-06 16:44:14 +01:00
2023-05-05 13:04:02 +02:00
$agent_alias = ui_print_truncate_text (
$agent_alias ,
'agent_small' ,
false ,
true ,
true ,
'[…]' ,
'font-size:7.5pt;'
);
$data [ 12 ] .= $agent_link . html_print_image (
'images/edit.svg' ,
true ,
[
'alt' => '0' ,
'border' => '' ,
'title' => __ ( 'Edit' ),
'class' => 'main_menu_icon invert_filter' ,
]
) . '</a>' ;
} else {
$url_edit_module = $row [ 'server_url' ];
$url_edit_module .= 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&' ;
$url_edit_module .= '&id_agente=' . $row [ 'id_agent' ];
$url_edit_module .= '&tab=module&id_agent_module=' . $row [ 'id_agente_modulo' ] . '&edit_module=1' ;
$data [ 12 ] .= '<a href="' . $url_edit_module . '">' . html_print_image (
'images/edit.svg' ,
true ,
[
'alt' => '0' ,
'border' => '' ,
'title' => __ ( 'Edit' ),
'class' => 'main_menu_icon invert_filter' ,
]
) . '</a>' ;
}
// Delete.
2023-02-27 13:41:44 +01:00
if ( is_metaconsole () === false ) {
2023-02-06 16:44:14 +01:00
$url_delete_module = $row [ 'server_url' ] . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente' ;
$url_delete_module .= '&id_agente=' . $row [ 'id_agent' ] . '&delete_module=' . $row [ 'id_agente_modulo' ];
$onclick = 'onclick="javascript: if (!confirm(\'' . __ ( 'Are you sure to delete?' ) . '\')) return false;' ;
$data [ 12 ] .= '<a href="' . $url_delete_module . '" ' . $onclick . '" target="_blank">' . html_print_image (
2023-02-27 18:05:51 +01:00
'images/delete.svg' ,
2023-02-06 16:44:14 +01:00
true ,
[
'alt' => '0' ,
'border' => '' ,
'title' => __ ( 'Delete' ),
2023-02-27 18:05:51 +01:00
'class' => 'main_menu_icon invert_filter' ,
2023-02-06 16:44:14 +01:00
]
) . '</a>' ;
}
}
2023-05-05 13:04:02 +02:00
$inc_id ++ ;
2022-06-01 15:07:51 +02:00
array_push ( $table -> data , $data );
}
2021-06-14 11:02:57 +02:00
2023-12-19 16:50:36 +01:00
if ( ! defined ( 'METACONSOLE' )) {
echo '<div class="total_pages">' . sprintf ( __ ( 'Total items: %s' ), $count ) . '</div>' ;
}
2022-06-01 15:07:51 +02:00
html_print_table ( $table );
2019-01-30 16:18:44 +01:00
2022-06-01 15:07:51 +02:00
if ( $count_modules > $config [ 'block_size' ]) {
2023-12-19 16:50:36 +01:00
$show_count = false ;
if ( is_metaconsole () === true ) {
$show_count = true ;
}
$tablePagination = ui_pagination ( $count_modules , false , $offset , 0 , true , 'offset' , $show_count );
2022-06-01 15:07:51 +02:00
}
} else {
2023-09-07 13:54:41 +02:00
ui_print_info_message ([ 'no_close' => true , 'message' => __ ( 'Please apply a filter to display the data' )]);
2022-06-01 15:07:51 +02:00
}
2013-05-20 10:42:02 +02:00
2024-02-09 13:51:56 +01:00
if ( isset ( $tablePagination ) === false ) {
$tablePagination = '' ;
}
2023-02-20 14:35:32 +01:00
if ( is_metaconsole () !== true ) {
html_print_action_buttons (
2023-03-09 11:25:43 +01:00
'' ,
2023-02-20 14:35:32 +01:00
[
'type' => 'form_action' ,
'right_content' => $tablePagination ,
]
);
}
2021-06-14 10:52:50 +02:00
2023-01-19 10:49:48 +01:00
// End Build List Result.
echo " <div id='monitor_details_window'></div> " ;
// Load filter div for dialog.
echo '<div id="load-modal-filter" style="display:none"></div>' ;
echo '<div id="save-modal-filter" style="display:none"></div>' ;
2015-01-15 18:08:58 +01:00
2023-01-19 10:49:48 +01:00
ui_require_javascript_file ( 'pandora_modules' );
2013-03-15 13:06:49 +01:00
2022-06-01 15:07:51 +02:00
?>
2020-10-26 10:14:14 +01:00
< script type = " text/javascript " >
2016-10-14 18:51:17 +02:00
2023-01-19 10:49:48 +01:00
var loading = 0 ;
/* Filter management */
$ ( '#button-load-filter' ) . click ( function ( event ) {
// event.preventDefault();
if ( $ ( '#load-filter-select' ) . length ) {
$ ( '#load-filter-select' ) . dialog ();
} else {
if ( loading == 0 ) {
loading = 1
$ . ajax ({
method : 'POST' ,
url : '<?php echo ui_get_full_url(' ajax . php '); ?>' ,
data : {
page : 'include/ajax/module' ,
load_filter_modal : 1
},
success : function ( data ){
$ ( '#load-modal-filter' )
. empty ()
. html ( data );
loading = 0 ;
}
});
}
}
});
$ ( '#button-save-filter' ) . click ( function (){
// event.preventDefault();
if ( $ ( '#save-filter-select' ) . length ) {
$ ( '#save-filter-select' ) . dialog ();
} else {
if ( loading == 0 ) {
loading = 1
$ . ajax ({
method : 'POST' ,
url : '<?php echo ui_get_full_url(' ajax . php '); ?>' ,
data : {
page : 'include/ajax/module' ,
save_filter_modal : 1 ,
current_filter : $ ( '#latest_filter_id' ) . val ()
},
success : function ( data ){
$ ( '#save-modal-filter' )
. empty ()
. html ( data );
loading = 0 ;
}
});
}
}
});
2021-06-25 09:37:26 +02:00
if ( ! document . getElementById ( 'not_condition_switch' ) . checked ){
document . getElementById ( " select2-ag_group-container " ) . innerHTML = " None " ;
}
2019-01-30 16:18:44 +01:00
$ ( '#moduletype' ) . click ( function () {
jQuery . get (
" ajax.php " ,
{
" page " : " general/subselect_data_module " ,
" module " : $ ( '#moduletype' ) . val ()
},
function ( data , status ) {
$ ( " #datatypetittle " ) . show ();
$ ( " #datatypebox " ) . hide ()
. empty ()
. append ( data )
. show ();
},
" html "
2016-10-14 18:51:17 +02:00
);
return false ;
2019-10-09 17:26:06 +02:00
});
2019-01-30 16:18:44 +01:00
function toggle_full_value ( id ) {
text = $ ( '#hidden_value_module_' + id ) . html ();
old_text = $ ( " #value_module_text_ " + id ) . html ();
$ ( " #hidden_value_module_ " + id ) . html ( old_text );
$ ( " #value_module_text_ " + id ) . html ( text );
}
2021-05-06 17:08:11 +02:00
// Show the modal window of an module.
2019-01-30 16:18:44 +01:00
function show_module_detail_dialog ( module_id , id_agent , server_name , offset , period , module_name ) {
if ( period == - 1 ) {
if ( $ ( " #period " ) . length == 1 ) {
period = $ ( '#period' ) . val ();
}
else {
period = < ? php echo SECONDS_1DAY ; ?> ;
}
}
if ( $ ( 'input[name=selection_mode]:checked' ) . val ()) {
var selection_mode = $ ( 'input[name=selection_mode]:checked' ) . val ();
var date_from = $ ( '#text-date_from' ) . val ();
var time_from = $ ( '#text-time_from' ) . val ();
var date_to = $ ( '#text-date_to' ) . val ();
var time_to = $ ( '#text-time_to' ) . val ();
var extra_parameters = '&selection_mode=' + selection_mode + '&date_from=' + date_from + '&date_to=' + date_to + '&time_from=' + time_from + '&time_to=' + time_to ;
}
title = < ? php echo '"' . __ ( 'Module: ' ) . '"' ; ?> ;
$ . ajax ({
type : " POST " ,
url : " <?php echo ui_get_full_url('ajax.php', false, false, false); ?> " ,
data : " page=include/ajax/module&get_module_detail=1&server_name= " + server_name + " &id_agent= " + id_agent + " &id_module= " + module_id + " &offset= " + offset + " &period= " + period + extra_parameters ,
dataType : " html " ,
success : function ( data ) {
$ ( " #monitor_details_window " ) . hide ()
. empty ()
. append ( data )
. dialog ({
resizable : true ,
draggable : true ,
modal : true ,
title : title + module_name ,
overlay : {
opacity : 0.5 ,
background : " black "
},
2023-02-17 11:54:48 +01:00
width : 700 ,
2019-01-30 16:18:44 +01:00
height : 500
})
. show ();
refresh_pagination_callback ( module_id , id_agent , server_name , module_name );
}
});
}
function refresh_pagination_callback ( module_id , id_agent , server_name , module_name ) {
$ ( " .binary_dialog " ) . click ( function () {
var classes = $ ( this ) . attr ( 'class' );
classes = classes . split ( ' ' );
var offset_class = classes [ 2 ];
offset_class = offset_class . split ( '_' );
var offset = offset_class [ 1 ];
var period = $ ( '#period' ) . val ();
show_module_detail_dialog ( module_id , id_agent , server_name , offset , period , module_name );
return false ;
});
}
2021-06-17 14:59:43 +02:00
2021-08-24 13:30:50 +02:00
2021-06-17 14:59:43 +02:00
function changeNotConditionStatus () {
2021-08-30 11:19:53 +02:00
2021-06-17 14:59:43 +02:00
let chkbox = document . getElementById ( 'not_condition_switch' );
if ( chkbox . checked ) {
2021-08-30 11:19:53 +02:00
2021-06-17 14:59:43 +02:00
$ ( 'select[name=datatypebox] > option:first-child' ) . val ( 'None' );
2021-06-17 15:04:21 +02:00
$ ( '#datatypebox option:first' ) . text ( 'None' );
2021-08-26 12:42:16 +02:00
$ ( 'select[name=status] > option:first-child' ) . text ( 'None' );
$ ( 'select[name=moduletype] > option:first-child' ) . text ( 'None' );
$ ( 'select[name=modulegroup] > option:first-child' ) . text ( 'None' );
$ ( 'select[name=tag_filter] > option:first-child' ) . text ( 'None' );
2021-08-24 13:30:50 +02:00
2021-08-30 11:19:53 +02:00
$ ( " #status " ) . select2 () . val ([ " None " ]) . trigger ( " change " );
$ ( " #moduletype " ) . select2 () . val ([ " None " ]) . trigger ( " change " );
$ ( " #modulegroup " ) . select2 () . val ([ " None " ]) . trigger ( " change " );
$ ( " #tag_filter " ) . select2 () . val ([ " None " ]) . trigger ( " change " );
document . getElementById ( " select2-status-container " ) . innerHTML = " None " ;
document . getElementById ( " select2-moduletype-container " ) . innerHTML = " None " ;
document . getElementById ( " select2-ag_group-container " ) . innerHTML = " None " ;
document . getElementById ( " select2-modulegroup-container " ) . innerHTML = " None " ;
2021-06-17 14:59:43 +02:00
} else {
2021-08-30 11:19:53 +02:00
$ ( 'select[name=datatypebox] > option:first-child' ) . val ( 'All' );
2021-06-17 15:04:21 +02:00
$ ( '#datatypebox option:first' ) . text ( 'All' );
2021-08-26 12:42:16 +02:00
$ ( 'select[name=status] > option:first-child' ) . text ( 'All' );
$ ( 'select[name=moduletype] > option:first-child' ) . text ( 'All' );
$ ( 'select[name=modulegroup] > option:first-child' ) . text ( 'All' );
$ ( 'select[name=tag_filter] > option:first-child' ) . text ( 'All' );
2021-08-30 11:19:53 +02:00
$ ( '#datatypebox option:first' ) . text ( 'All' );
$ ( " #status " ) . select2 () . val ([ " All " ]) . trigger ( " change " );
$ ( " #moduletype " ) . select2 () . val ([ " All " ]) . trigger ( " change " );
$ ( " #modulegroup " ) . select2 () . val ([ " All " ]) . trigger ( " change " );
$ ( " #tag_filter " ) . select2 () . val ([ " All " ]) . trigger ( " change " );
document . getElementById ( " select2-status-container " ) . innerHTML = " All " ;
document . getElementById ( " select2-moduletype-container " ) . innerHTML = " All " ;
document . getElementById ( " select2-ag_group-container " ) . innerHTML = " All " ;
document . getElementById ( " select2-modulegroup-container " ) . innerHTML = " All " ;
2021-06-17 14:59:43 +02:00
}
}
2021-08-24 13:30:50 +02:00
2021-06-17 14:59:43 +02:00
let chkbox = document . getElementById ( 'not_condition_switch' );
let value_swtich = " <?php echo $not_condition ; ?> " ;
if ( value_swtich != " " ) {
chkbox . checked = true ;
} else {
chkbox . checked = false ;
}
2023-03-08 12:55:53 +01:00
</ script >