2006-03-27 05:37:27 +02:00
< ? php
2021-04-29 13:28:03 +02:00
/**
* Agent 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.
2010-03-02 20:25:51 +01:00
global $config ;
2011-03-23 18:44:44 +01:00
ob_start ();
2019-01-30 16:18:44 +01:00
require_once 'include/functions_reporting.php' ;
require_once $config [ 'homedir' ] . '/include/functions_agents.php' ;
require_once $config [ 'homedir' ] . '/include/functions_users.php' ;
require_once $config [ 'homedir' ] . '/include/functions_modules.php' ;
2013-08-01 18:20:36 +02:00
enterprise_include_once ( 'include/functions_config_agents.php' );
2023-01-25 17:22:54 +01:00
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-08 12:43:08 +01:00
ui_require_css_file ( 'tables' );
2019-01-30 16:18:44 +01:00
check_login ();
2006-07-11 10:49:21 +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' )) {
2022-02-01 13:39:18 +01:00
db_pandora_audit (
AUDIT_LOG_ACL_VIOLATION ,
'Trying to access agent main list view'
);
2019-01-30 16:18:44 +01:00
include 'general/noaccess.php' ;
return ;
2008-06-30 10:11:10 +02:00
}
2007-03-02 18:56:07 +01:00
2022-11-15 16:02:40 +01:00
if ( is_ajax () === true ) {
2019-01-30 16:18:44 +01:00
ob_get_clean ();
$get_agent_module_last_value = ( bool ) get_parameter ( 'get_agent_module_last_value' );
$get_actions_alert_template = ( bool ) get_parameter ( 'get_actions_alert_template' );
2022-11-15 16:02:40 +01:00
if ( $get_actions_alert_template === true ) {
2019-01-30 16:18:44 +01:00
$id_template = get_parameter ( 'id_template' );
$own_info = get_user_info ( $config [ 'id_user' ]);
$usr_groups = [];
$usr_groups = users_get_groups ( $config [ 'id_user' ], 'LW' , true );
$filter_groups = '' ;
$filter_groups = implode ( ',' , array_keys ( $usr_groups ));
2022-11-15 16:02:40 +01:00
$sql = sprintf (
" SELECT t1.id, t1.name,
( SELECT COUNT ( t2 . id )
FROM talert_templates t2
WHERE t2 . id = % d
AND t2 . id_alert_action = t1 . id ) as 'sort_order'
FROM talert_actions t1
WHERE id_group IN ( % s )
ORDER BY sort_order DESC " ,
$id_template ,
$filter_groups
);
2019-01-30 16:18:44 +01:00
$rows = db_get_all_rows_sql ( $sql );
if ( $rows !== false ) {
echo json_encode ( $rows );
} else {
echo 'false' ;
}
return ;
}
2022-11-15 16:02:40 +01:00
if ( $get_agent_module_last_value === true ) {
2023-04-27 16:05:37 +02:00
if ( is_metaconsole ()) {
if ( enterprise_include_once ( 'include/functions_metaconsole.php' ) !== ENTERPRISE_NOT_HOOK ) {
$server_name = explode ( ' ' , io_safe_output ( get_parameter ( 'server_name' )))[ 0 ];
$connection = metaconsole_get_connection ( $server_name );
if ( metaconsole_load_external_db ( $connection ) !== NOERR ) {
echo json_encode ( false );
// Restore db connection.
metaconsole_restore_db ();
return ;
}
}
}
2019-01-30 16:18:44 +01:00
$id_module = ( int ) get_parameter ( 'id_agent_module' );
$id_agent = ( int ) modules_get_agentmodule_agent (( int ) $id_module );
if ( ! check_acl_one_of_groups ( $config [ 'id_user' ], agents_get_all_groups_agent ( $id_agent ), 'AR' )) {
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 main list view'
);
echo json_encode ( false );
return ;
}
$module_value = modules_get_last_value ( $id_module );
if ( is_numeric ( $row [ 'value' ]) && ! modules_is_string_type ( $module [ 'id_tipo_modulo' ])) {
$value = $module_value ;
} else {
$module = modules_get_agentmodule ( $id_module );
$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' => $module [ 'id_agente_modulo' ],
'interval' => $module [ 'current_interval' ],
'module_name' => $module [ 'nombre' ],
]
);
$value = ui_get_snapshot_image ( $link , $is_snapshot ) . ' ' ;
} else {
$value = ui_print_module_string_value (
$module_value ,
$module [ 'id_agente_modulo' ],
$module [ 'current_interval' ],
$module [ 'module_name' ]
);
}
}
2023-04-27 16:05:37 +02:00
if ( is_metaconsole ()) {
// Restore db connection.
metaconsole_restore_db ();
}
2019-01-30 16:18:44 +01:00
echo json_encode ( $value );
return ;
}
return ;
2009-02-18 13:29:30 +01:00
}
2019-01-30 16:18:44 +01:00
2011-03-23 18:44:44 +01:00
ob_end_clean ();
2009-02-18 13:29:30 +01:00
2013-08-01 18:20:36 +02:00
2019-11-06 10:31:26 +01:00
// Take some parameters (GET).
2019-01-30 16:18:44 +01:00
$group_id = ( int ) get_parameter ( 'group_id' , 0 );
$search = trim ( get_parameter ( 'search' , '' ));
$search_custom = trim ( get_parameter ( 'search_custom' , '' ));
$offset = ( int ) get_parameter ( 'offset' , 0 );
2010-07-19 16:57:46 +02:00
$refr = get_parameter ( 'refr' , 0 );
2011-07-11 06:28:21 +02:00
$recursion = get_parameter ( 'recursion' , 0 );
2019-01-30 16:18:44 +01:00
$status = ( int ) get_parameter ( 'status' , - 1 );
2023-01-25 17:22:54 +01:00
$os = ( int ) get_parameter ( 'os' , 0 );
2023-09-06 17:00:16 +02:00
$os_version_regex = trim ( get_parameter ( 'os_version_regex' , '' ));
2023-10-02 16:42:32 +02:00
$os_type_regex = trim ( get_parameter ( 'os_type_regex' , '' ));
2023-01-25 17:22:54 +01:00
$policies = ( array ) get_parameter ( 'policies' , []);
$ag_custom_fields = ( array ) get_parameter ( 'ag_custom_fields' , []);
2008-01-10 17:40:00 +01:00
2015-01-26 13:50:58 +01:00
$strict_user = db_get_value ( 'strict_acl' , 'tusuario' , 'id_user' , $config [ 'id_user' ]);
2019-01-30 16:18:44 +01:00
$agent_a = ( bool ) check_acl ( $config [ 'id_user' ], 0 , 'AR' );
$agent_w = ( bool ) check_acl ( $config [ 'id_user' ], 0 , 'AW' );
2016-09-08 16:06:12 +02:00
$access = ( $agent_a === true ) ? 'AR' : (( $agent_w === true ) ? 'AW' : 'AR' );
2015-01-26 13:50:58 +01:00
2019-01-30 16:18:44 +01:00
$onheader = [];
2023-01-25 17:22:54 +01:00
$load_filter_id = ( int ) get_parameter ( 'filter_id' , 0 );
2023-10-02 16:42:32 +02:00
if ( empty ( $os_type_regex ) !== true ) {
$os = ( int ) db_get_value_sql ( 'SELECT id_os FROM tconfig_os WHERE `name` REGEXP "' . $os_type_regex . '"' );
}
2023-01-25 17:22:54 +01:00
if ( $load_filter_id > 0 ) {
$user_groups_fl = users_get_groups (
$config [ 'id_user' ],
'AR' ,
2023-03-01 16:10:18 +01:00
users_can_manage_group_all ( 'AR' ),
2023-01-25 17:22:54 +01:00
true
);
$sql = sprintf (
' SELECT id_filter , id_name
FROM tagent_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-08 17:17:17 +01:00
if ( isset ( $loaded_filter ) === false ) {
$loaded_filter [ 'id_filter' ] = 0 ;
}
2023-01-25 17:22:54 +01:00
if ( $loaded_filter [ 'id_filter' ] > 0 ) {
$query_filter [ 'id_filter' ] = $load_filter_id ;
$filter = db_get_row_filter ( 'tagent_filter' , $query_filter , false );
if ( $filter !== false ) {
$group_id = ( int ) $filter [ 'group_id' ];
$recursion = $filter [ 'recursion' ];
$status = $filter [ 'status' ];
$search = $filter [ 'search' ];
$os = $filter [ 'id_os' ];
$policies = json_decode ( $filter [ 'policies' ], true );
$search_custom = $filter [ 'search_custom' ];
$ag_custom_fields = $filter [ 'ag_custom_fields' ];
}
if ( is_array ( $ag_custom_fields ) === false ) {
$ag_custom_fields = json_decode ( io_safe_output ( $ag_custom_fields ), true );
}
if ( is_array ( $policies ) === false ) {
$policies = json_decode ( io_safe_output ( $policies ), true );
}
2023-06-29 16:09:07 +02:00
// Fav menu.
$fav_menu = [
'id_element' => $loaded_filter [ 'id_filter' ],
'url' => 'operation/agentes/estado_agente&pure=&load_filter=1&filter_id=' . $loaded_filter [ 'id_filter' ],
'label' => $loaded_filter [ 'id_name' ],
'section' => 'Agente' ,
];
2023-01-25 17:22:54 +01:00
}
2022-11-15 16:02:40 +01:00
if (( bool ) check_acl ( $config [ 'id_user' ], 0 , 'AW' ) === true ) {
2019-11-06 10:31:26 +01:00
// Prepare the tab system to the future.
2019-01-30 16:18:44 +01:00
$tab = 'setup' ;
2023-02-07 16:22:52 +01:00
// Options.
2019-01-30 16:18:44 +01:00
$setuptab [ 'godmode' ] = true ;
$setuptab [ 'active' ] = false ;
2023-02-07 16:22:52 +01:00
// Setup tab.
$setuptab [ 'text' ] = html_print_anchor (
[
'href' => ui_get_full_url ( 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente' ),
'content' => html_print_image (
'images/configuration@svg.svg' ,
true ,
[
'title' => __ ( 'Setup' ),
'class' => 'invert_filter main_menu_icon' ,
]
),
],
true
);
// Header button.
2019-01-30 16:18:44 +01:00
$onheader = [ 'setup' => $setuptab ];
2011-12-07 16:04:40 +01:00
}
2021-04-29 13:28:03 +02:00
// Header.
ui_print_standard_header (
2020-05-29 11:37:06 +02:00
__ ( 'Agent detail' ),
2021-03-11 15:40:23 +01:00
'images/agent.png' ,
2020-05-29 11:37:06 +02:00
false ,
'' ,
false ,
2021-04-29 13:28:03 +02:00
$onheader ,
[
[
'link' => '' ,
'label' => __ ( 'Monitoring' ),
],
[
'link' => '' ,
'label' => __ ( 'Views' ),
],
2023-06-29 16:09:07 +02:00
],
( empty ( $fav_menu ) === true ) ? [] : $fav_menu
2020-05-29 11:37:06 +02:00
);
2008-01-10 17:40:00 +01:00
2022-11-15 16:02:40 +01:00
if (( bool ) $strict_user === false ) {
if ( tags_has_user_acl_tags () === true ) {
2019-01-30 16:18:44 +01:00
ui_print_tags_warning ();
}
2013-01-10 17:00:30 +01:00
}
2019-11-06 10:31:26 +01:00
// User is deleting agent.
2022-11-15 16:02:40 +01:00
if ( isset ( $result_delete ) === true ) {
ui_print_result_message (
$result_delete ,
__ ( 'Sucessfully deleted agent' ),
__ ( 'There was an error message deleting the agent' )
);
2012-07-23 16:58:33 +02:00
}
2012-06-13 11:56:20 +02:00
2019-01-30 16:18:44 +01:00
$groups = users_get_groups ( false , $access );
2016-09-08 16:06:12 +02:00
2019-01-30 16:18:44 +01:00
$fields = [];
2015-06-08 13:13:09 +02:00
$fields [ AGENT_STATUS_NORMAL ] = __ ( 'Normal' );
2013-06-05 16:36:13 +02:00
$fields [ AGENT_STATUS_WARNING ] = __ ( 'Warning' );
$fields [ AGENT_STATUS_CRITICAL ] = __ ( 'Critical' );
2013-07-24 13:06:24 +02:00
$fields [ AGENT_STATUS_UNKNOWN ] = __ ( 'Unknown' );
2015-06-08 13:13:09 +02:00
$fields [ AGENT_STATUS_NOT_NORMAL ] = __ ( 'Not normal' );
2013-06-05 16:36:13 +02:00
$fields [ AGENT_STATUS_NOT_INIT ] = __ ( 'Not init' );
2011-12-07 12:58:41 +01:00
2022-11-15 16:02:40 +01:00
$searchForm = '' ;
2023-04-25 10:19:30 +02:00
$searchForm .= '<form method="post" action="?sec=view&sec2=operation/agentes/estado_agente">' ;
2011-12-07 12:58:41 +01:00
2022-11-15 16:02:40 +01:00
$table = new stdClass ();
2023-02-23 10:24:03 +01:00
$table -> width = '100%' ;
2023-02-23 11:00:38 +01:00
$table -> size = [];
2023-02-23 15:44:01 +01:00
$table -> size [ 0 ] = '50%' ;
$table -> size [ 1 ] = '50%' ;
2023-02-23 11:00:38 +01:00
$table -> class = 'filter-table-adv' ;
2023-11-14 17:04:31 +01:00
$table -> cellstyle [ 'group' ][ 0 ] = 'display: flex;width: 95% !important;' ;
2023-02-23 11:00:38 +01:00
$table -> data [ 'group' ][ 0 ] = html_print_label_input_block (
__ ( 'Group' ),
html_print_select_groups (
false ,
$access ,
true ,
'group_id' ,
$group_id ,
2024-03-15 10:02:21 +01:00
'' ,
2023-02-23 11:00:38 +01:00
'' ,
'' ,
true ,
false ,
true ,
'' ,
false
2023-11-14 17:04:31 +01:00
),
[ 'div_class' => 'w100p' ]
2023-02-23 10:24:03 +01:00
);
2023-02-23 11:00:38 +01:00
2023-02-23 12:34:41 +01:00
$table -> data [ 'group' ][ 0 ] .= html_print_label_input_block (
2023-02-23 11:00:38 +01:00
__ ( 'Recursion' ),
html_print_checkbox_switch (
'recursion' ,
1 ,
$recursion ,
true
2023-11-14 17:04:31 +01:00
)
2023-02-23 10:24:03 +01:00
);
2023-02-23 12:34:41 +01:00
$table -> data [ 'group' ][ 1 ] = html_print_label_input_block (
2023-02-23 10:24:03 +01:00
__ ( 'Status' ),
html_print_select (
$fields ,
'status' ,
$status ,
2024-03-15 10:02:21 +01:00
'' ,
2023-02-23 10:24:03 +01:00
__ ( 'All' ),
AGENT_STATUS_ALL ,
true ,
false ,
true ,
'' ,
2023-02-23 11:00:38 +01:00
false ,
'width: 100%'
2023-02-23 10:24:03 +01:00
)
);
2011-12-07 12:58:41 +01:00
2023-02-23 10:24:03 +01:00
$table -> data [ 'search_fields' ][ 0 ] = html_print_label_input_block (
__ ( 'Search' ),
html_print_input_text (
'search' ,
$search ,
'' ,
35 ,
255 ,
true
)
);
2017-10-25 12:04:14 +02:00
2023-02-23 10:24:03 +01:00
$table -> data [ 'search_fields' ][ 1 ] = html_print_label_input_block (
__ ( 'Search in custom fields' ),
html_print_input_text (
'search_custom' ,
$search_custom ,
'' ,
35 ,
255 ,
true
)
);
2017-10-25 12:04:14 +02:00
2023-03-03 14:16:06 +01:00
$pre_fields = db_get_all_rows_sql (
2023-03-03 08:20:44 +01:00
'select distinct(tagente.id_os),tconfig_os.name from tagente,tconfig_os where tagente.id_os = tconfig_os.id_os'
2023-03-03 14:16:06 +01:00
);
$fields = [];
foreach ( $pre_fields as $key => $value ) {
2023-01-25 17:22:54 +01:00
$fields [ $value [ 'id_os' ]] = $value [ 'name' ];
2023-03-03 14:16:06 +01:00
}
2023-01-25 17:22:54 +01:00
2023-03-03 14:16:06 +01:00
$table -> data [ 1 ][ 0 ] = html_print_label_input_block (
__ ( 'Operating System' ),
2023-11-14 17:04:31 +01:00
html_print_select ( $fields , 'os' , $os , '' , 'All' , 0 , true , false , true , 'w100p' , false , 'width:100%' )
2023-03-03 14:16:06 +01:00
);
2023-01-25 17:22:54 +01:00
2023-09-06 17:00:16 +02:00
$table -> data [ 1 ][ 1 ] = html_print_label_input_block (
__ ( 'Operating System version' ) . ui_print_help_tip ( __ ( 'Case insensitive regular expression, e.g. Rocky.* will match the following OS version: Rocky Linux 8.7' ), true ),
html_print_input_text (
'os_version_regex' ,
$os_version_regex ,
'' ,
35 ,
255 ,
true
)
);
2023-03-23 12:39:55 +01:00
if ( function_exists ( 'policies_get_policies' ) === true ) {
$pre_fields = policies_get_policies ( false , [ 'id' , 'name' ]);
$fields = [];
foreach ( $pre_fields as $value ) {
$fields [ $value [ 'id' ]] = $value [ 'name' ];
}
2023-03-03 14:16:06 +01:00
}
2023-01-25 17:22:54 +01:00
2024-03-14 10:03:08 +01:00
if ( enterprise_installed () === true ) {
$table -> data [ 2 ][ 1 ] = html_print_label_input_block (
__ ( 'Policies' ),
html_print_select (
$fields ,
'policies' ,
$policies ,
2024-03-26 12:21:57 +01:00
'' ,
2024-03-14 10:03:08 +01:00
__ ( 'All' ),
0 ,
true ,
false ,
true ,
'w100p' ,
false ,
'width: 100%'
)
);
}
2023-03-03 14:16:06 +01:00
$custom_fields = db_get_all_fields_in_table ( 'tagent_custom_fields' );
if ( $custom_fields === false ) {
2023-01-25 17:22:54 +01:00
$custom_fields = [];
2023-03-03 14:16:06 +01:00
}
2023-01-25 17:22:54 +01:00
2023-11-14 17:04:31 +01:00
$div_custom_fields = '<div class="flex-row w100p" style="justify-content: unset;">' ;
2023-03-03 14:16:06 +01:00
foreach ( $custom_fields as $custom_field ) {
2023-01-25 17:22:54 +01:00
$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 = '' ;
}
}
2023-11-14 17:04:31 +01:00
$div_custom_fields .= '<div class="div-col-4">' ;
2023-01-25 17:22:54 +01:00
$div_custom_fields .= '<div class="div-span">' ;
2023-11-14 17:04:31 +01:00
$div_custom_fields .= '<span class="span_as_label">' . $custom_field [ 'name' ] . '</span>' ;
2023-01-25 17:22:54 +01:00
$div_custom_fields .= '</div>' ;
2011-12-07 12:58:41 +01:00
2023-01-25 17:22:54 +01: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></div>' ;
2023-03-03 14:16:06 +01:00
}
2022-06-03 14:15:51 +02:00
2023-09-06 17:00:16 +02:00
$table -> colspan [ 3 ][ 0 ] = 2 ;
$table -> data [ 3 ][ 0 ] = ui_toggle (
2023-01-25 17:22:54 +01:00
$div_custom_fields ,
__ ( 'Agent custom fields' ),
'' ,
'' ,
true ,
true ,
'' ,
'white-box-content' ,
'white_table_graph'
2023-03-03 14:16:06 +01:00
);
2022-06-03 14:15:51 +02:00
2011-12-07 12:58:41 +01:00
2023-03-03 14:16:06 +01:00
$buttons = html_print_submit_button (
__ ( 'Filter' ),
'srcbutton' ,
false ,
[
'icon' => 'search' ,
'mode' => 'mini' ,
],
true
);
$buttons .= html_print_button (
2023-01-25 17:22:54 +01:00
__ ( 'Load filter' ),
'load-filter' ,
false ,
'' ,
2023-03-03 14:16:06 +01:00
[
'icon' => 'load' ,
'mode' => 'mini secondary' ,
],
2023-01-25 17:22:54 +01:00
true
2023-03-03 14:16:06 +01:00
);
2017-10-25 12:04:14 +02:00
2023-03-03 14:16:06 +01:00
$buttons .= html_print_button (
2023-02-28 17:06:31 +01:00
__ ( 'Manage filter' ),
2023-01-25 17:22:54 +01:00
'save-filter' ,
false ,
'' ,
2023-03-03 14:16:06 +01:00
[
'icon' => 'wand' ,
'mode' => 'mini secondary' ,
],
2023-01-25 17:22:54 +01:00
true
2023-03-03 14:16:06 +01:00
);
2009-04-09 23:06:17 +02:00
2022-11-15 16:02:40 +01:00
$searchForm .= html_print_table ( $table , true );
$searchForm .= html_print_div (
2022-10-21 13:47:41 +02:00
[
2022-11-15 16:02:40 +01:00
'class' => 'action-buttons' ,
2023-03-03 14:16:06 +01:00
'content' => $buttons ,
2022-11-15 16:02:40 +01:00
],
true
2019-01-30 16:18:44 +01:00
);
2022-11-15 16:02:40 +01:00
$searchForm .= '</form>' ;
2012-04-03 18:05:44 +02:00
2022-11-15 16:02:40 +01:00
ui_toggle (
$searchForm ,
2023-02-20 13:02:24 +01:00
'<span class="subsection_header_title">' . __ ( 'Filters' ) . '</span>' ,
2023-02-23 10:24:03 +01:00
'filter_form' ,
'' ,
true ,
false ,
'' ,
'white-box-content' ,
'box-flat white_table_graph fixed_filter_bar'
2022-11-15 16:02:40 +01:00
);
2013-05-23 17:42:32 +02:00
2022-11-15 16:02:40 +01:00
if ( empty ( $search ) === false ) {
2019-01-30 16:18:44 +01:00
$filter = [ 'string' => '%' . $search . '%' ];
} else {
$filter = [];
2008-06-30 10:11:10 +02:00
}
2010-07-19 16:57:46 +02:00
$sortField = get_parameter ( 'sort_field' );
$sort = get_parameter ( 'sort' , 'none' );
2019-04-05 13:18:38 +02:00
$selected = true ;
$selectNameUp = false ;
$selectNameDown = false ;
$selectOsUp = false ;
$selectOsDown = false ;
$selectIntervalUp = false ;
$selectIntervalDown = false ;
$selectGroupUp = false ;
$selectGroupDown = false ;
$selectDescriptionUp = false ;
$selectDescriptionDown = false ;
$selectLastContactUp = false ;
$selectLastContactDown = false ;
2023-02-08 12:58:23 +01:00
$selectRemoteUp = false ;
$selectRemoteDown = false ;
2023-01-25 17:22:54 +01:00
$selectLastStatusChangeUp = false ;
$selectLastStatusChangeDown = false ;
2010-07-19 16:57:46 +02:00
$order = null ;
switch ( $sortField ) {
2019-01-30 16:18:44 +01:00
case 'remote' :
switch ( $sort ) {
case 'up' :
$selectRemoteUp = $selected ;
$order = [
2022-02-04 13:26:03 +01:00
'field' => 'remote' ,
'field2' => 'nombre' ,
2019-01-30 16:18:44 +01:00
'order' => 'ASC' ,
];
break ;
case 'down' :
$selectRemoteDown = $selected ;
$order = [
2022-02-04 13:26:03 +01:00
'field' => 'remote' ,
'field2' => 'nombre' ,
2019-01-30 16:18:44 +01:00
'order' => 'DESC' ,
];
break ;
2019-11-06 10:31:26 +01:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
case 'name' :
switch ( $sort ) {
case 'up' :
$selectNameUp = $selected ;
$order = [
2022-02-04 13:26:03 +01:00
'field' => 'alias' ,
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'ASC' ,
];
break ;
case 'down' :
$selectNameDown = $selected ;
$order = [
2022-02-04 13:26:03 +01:00
'field' => 'alias' ,
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'DESC' ,
];
break ;
2019-11-06 10:31:26 +01:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
case 'os' :
switch ( $sort ) {
case 'up' :
$selectOsUp = $selected ;
$order = [
'field' => 'id_os' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'ASC' ,
];
break ;
case 'down' :
$selectOsDown = $selected ;
$order = [
'field' => 'id_os' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'DESC' ,
];
break ;
2019-11-06 10:31:26 +01:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
case 'interval' :
switch ( $sort ) {
case 'up' :
$selectIntervalUp = $selected ;
$order = [
'field' => 'intervalo' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'ASC' ,
];
break ;
case 'down' :
$selectIntervalDown = $selected ;
$order = [
'field' => 'intervalo' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'DESC' ,
];
break ;
2019-11-06 10:31:26 +01:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
case 'group' :
switch ( $sort ) {
case 'up' :
$selectGroupUp = $selected ;
$order = [
'field' => 'id_grupo' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'ASC' ,
];
break ;
case 'down' :
$selectGroupDown = $selected ;
$order = [
'field' => 'id_grupo' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'DESC' ,
];
break ;
2019-11-06 10:31:26 +01:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
case 'last_contact' :
switch ( $sort ) {
case 'up' :
$selectLastContactUp = $selected ;
$order = [
'field' => 'ultimo_contacto' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'DESC' ,
];
break ;
case 'down' :
$selectLastContactDown = $selected ;
$order = [
'field' => 'ultimo_contacto' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'ASC' ,
];
break ;
2019-11-06 10:31:26 +01:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
2023-01-25 17:22:54 +01:00
case 'last_status_change' :
switch ( $sort ) {
case 'up' :
$selectLastStatusChangeUp = $selected ;
$order = [
'field' => 'last_status_change' ,
'field2' => 'alias' ,
'order' => 'ASC' ,
];
break ;
case 'down' :
$selectLastStatusChangeDown = $selected ;
$order = [
'field' => 'last_status_change' ,
'field2' => 'alias' ,
'order' => 'DESC' ,
];
break ;
default :
// Default.
break ;
}
break ;
2019-01-30 16:18:44 +01:00
case 'description' :
switch ( $sort ) {
case 'up' :
2019-04-05 13:18:38 +02:00
$selectDescriptionUp = $selected ;
2019-01-30 16:18:44 +01:00
$order = [
'field' => 'comentarios' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'DESC' ,
];
break ;
case 'down' :
2019-04-05 13:18:38 +02:00
$selectDescriptionDown = $selected ;
2019-01-30 16:18:44 +01:00
$order = [
'field' => 'comentarios' ,
2022-02-04 13:26:03 +01:00
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'ASC' ,
];
break ;
2019-11-06 10:31:26 +01:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
default :
$selectNameUp = $selected ;
2019-04-05 13:18:38 +02:00
$selectNameDown = false ;
$selectOsUp = false ;
$selectOsDown = false ;
$selectIntervalUp = false ;
$selectIntervalDown = false ;
$selectGroupUp = false ;
$selectGroupDown = false ;
$selectDescriptionUp = false ;
$selectDescriptionDown = false ;
$selectLastContactUp = false ;
$selectLastContactDown = false ;
2023-01-25 17:22:54 +01:00
$selectLastStatusChangeUp = false ;
$selectLastStatusChangeDown = false ;
2019-01-30 16:18:44 +01:00
$order = [
2022-02-04 13:26:03 +01:00
'field' => 'alias' ,
'field2' => 'alias' ,
2019-01-30 16:18:44 +01:00
'order' => 'ASC' ,
];
break ;
2010-07-19 16:57:46 +02:00
}
2011-05-09 17:38:22 +02:00
$search_sql = '' ;
2019-01-30 16:18:44 +01:00
if ( $search != '' ) {
2022-02-04 13:26:03 +01:00
$sql = sprintf (
' SELECT DISTINCT taddress_agent . id_agent FROM taddress
INNER JOIN taddress_agent ON
taddress . id_a = taddress_agent . id_a
WHERE taddress . ip LIKE " %%%s%% " ' ,
$search
);
2016-09-05 13:50:22 +02:00
2019-01-30 16:18:44 +01:00
$id = db_get_all_rows_sql ( $sql );
2022-11-15 16:02:40 +01:00
if ( empty ( $id ) === false ) {
2019-01-30 16:18:44 +01:00
$aux = $id [ 0 ][ 'id_agent' ];
2022-02-04 13:26:03 +01:00
$search_sql = sprintf (
2023-03-31 13:27:30 +02:00
' AND ( nombre LIKE " %%%s%% "
OR alias LIKE " %%%s%% "
OR comentarios LIKE " %%%s%% "
OR EXISTS ( SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE " %%%s%% " )
OR tagente . id_agente = % d ' ,
$search ,
$search ,
$search ,
2022-02-04 13:26:03 +01:00
$search ,
$aux
);
$nagent_count = count ( $id );
if ( $nagent_count >= 2 ) {
for ( $i = 1 ; $i < $nagent_count ; $i ++ ) {
2019-01-30 16:18:44 +01:00
$aux = $id [ $i ][ 'id_agent' ];
2022-02-04 13:26:03 +01:00
$search_sql .= sprintf (
' OR tagente.id_agente = %d' ,
$aux
);
2019-01-30 16:18:44 +01:00
}
}
$search_sql .= ')' ;
} else {
2022-02-04 13:26:03 +01:00
$search_sql = sprintf (
' AND ( nombre
LIKE " %%%s%% " OR alias
LIKE " %%%s%% " OR comentarios LIKE " %%%s%% "
2022-03-25 11:04:14 +01:00
OR EXISTS ( SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE " %%%s%% " )) ' ,
2022-02-04 13:26:03 +01:00
$search ,
$search ,
$search ,
$search
);
2019-01-30 16:18:44 +01:00
}
2011-05-09 17:38:22 +02:00
}
2022-11-15 16:02:40 +01:00
if ( empty ( $search_custom ) === false ) {
2022-02-04 13:33:46 +01:00
$search_sql_custom = " AND EXISTS (SELECT * FROM tagent_custom_data
WHERE id_agent = id_agente AND description LIKE '%$search_custom%' ) " ;
} else {
$search_sql_custom = '' ;
}
2023-01-25 17:22:54 +01:00
// Filter by agent custom fields.
$sql_conditions_custom_fields = '' ;
if ( empty ( $ag_custom_fields ) === false ) {
$cf_filter = [];
foreach ( $ag_custom_fields as $field_id => $value ) {
if ( empty ( $value ) === false ) {
$cf_filter [] = '(tagent_custom_data.id_field = ' . $field_id . ' AND tagent_custom_data.description LIKE \'%' . $value . '%\')' ;
}
}
if ( empty ( $cf_filter ) === false ) {
$sql_conditions_custom_fields = ' AND tagente . id_agente IN (
SELECT tagent_custom_data . id_agent
FROM tagent_custom_data
WHERE '.implode(' AND ', $cf_filter).' ) ' ;
}
}
2019-11-06 10:31:26 +01:00
// Show only selected groups.
2010-04-22 18:51:23 +02:00
if ( $group_id > 0 ) {
2019-01-30 16:18:44 +01:00
$groups = [ $group_id ];
if ( $recursion ) {
2020-10-21 11:38:57 +02:00
$groups = groups_get_children_ids ( $group_id , true );
2019-01-30 16:18:44 +01:00
}
} else {
$groups = [];
$user_groups = users_get_groups ( $config [ 'id_user' ], $access );
$groups = array_keys ( $user_groups );
2009-04-09 23:06:17 +02:00
}
2008-06-09 19:51:18 +02:00
2023-11-14 17:04:31 +01:00
if ( is_array ( $policies )) {
$all_policies = in_array ( 0 , ( $policies ? ? []));
} else {
$all_policies = [];
}
2023-01-25 17:22:54 +01:00
$id_os_sql = '' ;
$policies_sql = '' ;
if ( $os > 0 ) {
$id_os_sql = ' AND id_os = ' . $os ;
}
2023-09-06 17:00:16 +02:00
if ( $os_version_regex !== '' ) {
$id_os_sql .= ' AND os_version REGEXP \'' . $os_version_regex . '\'' ;
}
2023-01-25 17:22:54 +01:00
if ( $all_policies === false && is_array ( $policies ) && count ( $policies ) > 0 ) {
$policies_sql = ' AND tpolicy_agents.id_policy IN (' . implode ( ',' , $policies ) . ')' ;
}
2015-01-26 13:50:58 +01:00
if ( $strict_user ) {
2019-01-30 16:18:44 +01:00
$count_filter = [
2022-02-01 15:18:45 +01:00
// 'order' => 'tagente.nombre ASC',
2023-01-25 17:22:54 +01:00
'order' => 'tagente.nombre ASC' ,
'disabled' => 0 ,
'status' => $status ,
'search' => $search ,
'id_os' => $id_os_sql ,
'policies' => $policies_sql ,
'other_condition' => $sql_conditions_custom_fields ,
2019-01-30 16:18:44 +01:00
];
$filter = [
2022-02-01 15:18:45 +01:00
// 'order' => 'tagente.nombre ASC',
2023-01-25 17:22:54 +01:00
'order' => 'tagente.nombre ASC' ,
'disabled' => 0 ,
'status' => $status ,
'search' => $search ,
'offset' => ( int ) get_parameter ( 'offset' ),
'limit' => ( int ) $config [ 'block_size' ],
'id_os' => $id_os_sql ,
'policies' => $policies_sql ,
'other_condition' => $sql_conditions_custom_fields ,
2019-01-30 16:18:44 +01:00
];
if ( $group_id > 0 ) {
$groups = [ $group_id ];
if ( $recursion ) {
2020-10-21 11:38:57 +02:00
$groups = groups_get_children_ids ( $group_id , true );
2019-01-30 16:18:44 +01:00
}
$filter [ 'id_group' ] = implode ( ',' , $groups );
$count_filter [ 'id_group' ] = $filter [ 'id_group' ];
}
$fields = [
'tagente.id_agente' ,
'tagente.id_grupo' ,
'tagente.id_os' ,
'tagente.ultimo_contacto' ,
'tagente.intervalo' ,
'tagente.comentarios description' ,
'tagente.quiet' ,
'tagente.normal_count' ,
'tagente.warning_count' ,
'tagente.critical_count' ,
'tagente.unknown_count' ,
'tagente.notinit_count' ,
'tagente.total_count' ,
'tagente.fired_count' ,
'tagente.nombre' ,
'tagente.alias' ,
];
$acltags = tags_get_user_groups_and_tags ( $config [ 'id_user' ], $access , $strict_user );
$total_agents = tags_get_all_user_agents ( false , $config [ 'id_user' ], $acltags , $count_filter , $fields , false , $strict_user , true );
$total_agents = count ( $total_agents );
$agents = tags_get_all_user_agents ( false , $config [ 'id_user' ], $acltags , $filter , $fields , false , $strict_user , true );
} else {
2023-01-25 17:22:54 +01:00
$count_filter = [
'disabled' => 0 ,
'id_grupo' => $groups ,
'search' => $search_sql ,
'search_custom' => $search_sql_custom ,
'status' => $status ,
'id_os' => $id_os_sql ,
'policies' => $policies_sql ,
'other_condition' => $sql_conditions_custom_fields ,
];
$filter = [
'order' => 'nombre ASC' ,
'id_grupo' => $groups ,
'disabled' => 0 ,
'status' => $status ,
'search_custom' => $search_sql_custom ,
'search' => $search_sql ,
'offset' => ( int ) get_parameter ( 'offset' ),
'limit' => ( int ) $config [ 'block_size' ],
'id_os' => $id_os_sql ,
'policies' => $policies_sql ,
'other_condition' => $sql_conditions_custom_fields ,
];
2019-01-30 16:18:44 +01:00
$total_agents = agents_count_agents_filter (
2023-01-25 17:22:54 +01:00
$count_filter ,
2019-01-30 16:18:44 +01:00
$access
);
2023-01-25 17:22:54 +01:00
$query_order = $order ;
if ( $order [ 'field' ] === 'last_status_change' ) {
$query_order = [
'field' => 'alias' ,
'field2' => 'alias' ,
'order' => 'ASC' ,
];
}
2019-01-30 16:18:44 +01:00
$agents = agents_get_agents (
2023-01-25 17:22:54 +01:00
$filter ,
2019-01-30 16:18:44 +01:00
[
'id_agente' ,
'id_grupo' ,
'nombre' ,
'alias' ,
'id_os' ,
'ultimo_contacto' ,
'intervalo' ,
'comentarios description' ,
'quiet' ,
'normal_count' ,
'warning_count' ,
'critical_count' ,
'unknown_count' ,
'notinit_count' ,
'total_count' ,
'fired_count' ,
'ultimo_contacto_remoto' ,
'remote' ,
'agent_version' ,
],
$access ,
2023-01-25 17:22:54 +01:00
$query_order
2019-01-30 16:18:44 +01:00
);
2015-01-26 13:50:58 +01:00
}
2006-03-27 05:37:27 +02:00
2019-01-30 16:18:44 +01:00
if ( empty ( $agents )) {
$agents = [];
2009-04-09 23:06:17 +02:00
}
2008-09-03 14:11:53 +02:00
2023-02-08 12:58:23 +01:00
if ( $config [ 'language' ] === 'ja'
|| $config [ 'language' ] === 'zh_CN'
|| $own_info [ 'language' ] === 'ja'
|| $own_info [ 'language' ] === 'zh_CN'
2019-11-06 10:31:26 +01:00
) {
// Adds a custom font size for Japanese and Chinese language.
$custom_font_size = 'custom_font_size' ;
2023-02-08 12:58:23 +01:00
} else {
$custom_font_size = '' ;
2019-09-05 12:01:25 +02:00
}
2019-04-05 13:18:38 +02:00
// Urls to sort the table.
$url_up_agente = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=name&sort=up' ;
$url_down_agente = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=name&sort=down' ;
$url_up_description = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=description&sort=up' ;
$url_down_description = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=description&sort=down' ;
$url_up_remote = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=remote&sort=up' ;
$url_down_remote = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=remote&sort=down' ;
$url_up_os = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=os&sort=up' ;
$url_down_os = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=os&sort=down' ;
$url_up_interval = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=interval&sort=up' ;
$url_down_interval = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=interval&sort=down' ;
$url_up_group = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=group&sort=up' ;
$url_down_group = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=group&sort=down' ;
$url_up_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=last_contact&sort=up' ;
$url_down_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=last_contact&sort=down' ;
2023-01-25 17:22:54 +01:00
$url_up_last_status_change = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=last_status_change&sort=up' ;
$url_down_last_status_change = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=' . $refr . '&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status=' . $status . '&sort_field=last_status_change&sort=down' ;
2019-04-05 13:18:38 +02:00
2008-06-30 10:11:10 +02:00
// Show data.
2023-02-07 16:22:52 +01:00
$tableAgents = new stdClass ();
$tableAgents -> cellpadding = 0 ;
$tableAgents -> cellspacing = 0 ;
$tableAgents -> id = 'agent_list' ;
$tableAgents -> class = 'info_table tactical_table' ;
2015-04-21 17:26:20 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head = [];
$tableAgents -> head [ 0 ] = '<span>' . __ ( 'Agent' ) . '</span>' ;
$tableAgents -> head [ 0 ] .= ui_get_sorting_arrows ( $url_up_agente , $url_down_agente , $selectNameUp , $selectNameDown );
2023-03-09 19:25:14 +01:00
$tableAgents -> size [ 0 ] = '10%' ;
2016-11-03 17:23:36 +01:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head [ 1 ] = '<span>' . __ ( 'Description' ) . '</span>' ;
2023-03-09 19:25:14 +01:00
$tableAgents -> head [ 1 ] .= ui_get_sorting_arrows ( $url_up_description , $url_down_description , $selectDescriptionUp , $selectDescriptionDown );
$tableAgents -> size [ 1 ] = '14%' ;
2015-04-21 17:26:20 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head [ 2 ] = '<span>' . __ ( 'OS' ) . '</span>' ;
$tableAgents -> head [ 2 ] .= ui_get_sorting_arrows ( $url_up_os , $url_down_os , $selectOsUp , $selectOsDown );
2023-03-10 12:40:21 +01:00
$tableAgents -> size [ 2 ] = '5%' ;
2015-04-21 17:26:20 +02:00
2023-05-08 14:26:28 +02:00
/*
$tableAgents -> head [ 3 ] = '<span>' . __ ( 'Interval' ) . '</span>' ;
$tableAgents -> head [ 3 ] .= ui_get_sorting_arrows ( $url_up_interval , $url_down_interval , $selectIntervalUp , $selectIntervalDown );
$tableAgents -> size [ 3 ] = '7%' ; */
2015-04-21 17:26:20 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head [ 4 ] = '<span>' . __ ( 'Group' ) . '</span>' ;
$tableAgents -> head [ 4 ] .= ui_get_sorting_arrows ( $url_up_group , $url_down_group , $selectGroupUp , $selectGroupDown );
2023-03-09 19:25:14 +01:00
$tableAgents -> size [ 4 ] = '7%' ;
2015-04-21 17:26:20 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head [ 5 ] = '<span>' . __ ( 'Type' ) . '</span>' ;
2023-03-09 19:25:14 +01:00
$tableAgents -> size [ 5 ] = '7%' ;
2015-04-21 17:26:20 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head [ 6 ] = '<span>' . __ ( 'Modules' ) . '</span>' ;
2023-03-09 19:25:14 +01:00
$tableAgents -> size [ 6 ] = '7%' ;
2015-04-21 17:26:20 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head [ 7 ] = '<span>' . __ ( 'Status' ) . '</span>' ;
$tableAgents -> size [ 7 ] = '4%' ;
2017-07-24 15:53:31 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head [ 8 ] = '<span>' . __ ( 'Alerts' ) . '</span>' ;
$tableAgents -> size [ 8 ] = '4%' ;
2009-04-09 23:06:17 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> head [ 9 ] = '<span>' . __ ( 'Last contact' ) . '</span>' ;
$tableAgents -> head [ 9 ] .= ui_get_sorting_arrows ( $url_up_last , $url_down_last , $selectLastContactUp , $selectLastContactDown );
2023-03-09 19:25:14 +01:00
$tableAgents -> size [ 9 ] = '7%' ;
2012-12-05 Miguel de Dios <miguel.dedios@artica.es>
* extensions/update_manager/lib/libupdate_manager_client.php,
extensions/update_manager/lib/libupdate_manager.php,
operation/agentes/ver_agente.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_agente.php,
operation/integria_incidents/incident.php,
operation/reporting/reporting_xml.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.elements.php,
include/functions_visual_map.php,
include/functions_visual_map_editor.php: uploaded the changes of
source code style previous to my next commit for to make the next
commit more easy.
* godmode/reporting/visual_console_builder.php: set empty string
for the new visualmap.
* include/ajax/visual_console_builder.ajax.php: fixed the regular
expresion to extract the url for the graph.
* include/functions_html.php: fixed into the function
"html_print_select_groups" lost code for to show the selectbox.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7230 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 15:20:47 +01:00
2023-03-10 12:40:21 +01:00
$tableAgents -> head [ 10 ] = '<span>' . __ ( 'L.S change' ) . '</span>' ;
2023-03-03 08:20:44 +01:00
$tableAgents -> head [ 10 ] .= ui_get_sorting_arrows ( $url_up_last_status_change , $url_down_last_status_change , $selectLastStatusChangeUp , $selectLastStatusChangeDown );
2023-03-10 12:40:21 +01:00
$tableAgents -> size [ 10 ] = '8%' ;
2023-01-25 17:22:54 +01:00
2023-03-10 12:40:21 +01:00
$tableAgents -> head [ 11 ] = '<span>' . __ ( 'Op' ) . '</span>' ;
$tableAgents -> size [ 11 ] = '6%' ;
2009-04-09 23:06:17 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> align = [];
2011-11-23 17:26:17 +01:00
2023-02-07 16:22:52 +01:00
$tableAgents -> align [ 2 ] = 'left' ;
2023-05-08 14:26:28 +02:00
// $tableAgents->align[3] = 'left';
2023-02-07 16:22:52 +01:00
$tableAgents -> align [ 4 ] = 'left' ;
$tableAgents -> align [ 5 ] = 'left' ;
$tableAgents -> align [ 6 ] = 'left' ;
$tableAgents -> align [ 7 ] = 'left' ;
$tableAgents -> align [ 8 ] = 'left' ;
$tableAgents -> align [ 9 ] = 'left' ;
2023-03-03 08:20:44 +01:00
$tableAgents -> align [ 10 ] = 'left' ;
2009-04-09 23:06:17 +02:00
2023-02-07 16:22:52 +01:00
$tableAgents -> style = [];
$tableAgents -> data = [];
2023-03-10 12:40:21 +01:00
$tableAgents -> cellclass = [];
2009-04-09 23:06:17 +02:00
2009-08-07 Miguel de Dios <miguel.dedios@artica.es>
* operation/visual_console/index.php,
pandora_console/operation/users/user.php, operation/incidents/incident.php,
operation/agentes/status_monitor.php, operation/agentes/estado_agente.php,
operation/agentes/alerts_status.php, include/styles/pandora.css,
include/styles/pandora_black.css,include/styles/pandora_blackmetal.css,
include/styles/pandora_width.css, include/styles/pandora_minimal.css,
include/styles/pandora_red.css: the table list now has rows with alternate
colours for easy see the data.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1833 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-10 11:55:53 +02:00
$rowPair = true ;
$iterator = 0 ;
2012-01-23 17:28:22 +01:00
foreach ( $agents as $agent ) {
2019-01-30 16:18:44 +01:00
$cluster = db_get_row_sql ( 'select id from tcluster where id_agent = ' . $agent [ 'id_agente' ]);
if ( $rowPair ) {
2023-02-07 16:22:52 +01:00
$tableAgents -> rowclass [ $iterator ] = 'rowPair' ;
2019-01-30 16:18:44 +01:00
} else {
2023-02-07 16:22:52 +01:00
$tableAgents -> rowclass [ $iterator ] = 'rowOdd' ;
2019-01-30 16:18:44 +01:00
}
$rowPair = ! $rowPair ;
$iterator ++ ;
$alert_img = agents_tree_view_alert_img ( $agent [ 'fired_count' ]);
$status_img = agents_tree_view_status_img (
$agent [ 'critical_count' ],
$agent [ 'warning_count' ],
$agent [ 'unknown_count' ],
$agent [ 'total_count' ],
$agent [ 'notinit_count' ]
);
$in_planned_downtime = db_get_sql (
' SELECT executed FROM tplanned_downtime
2017-10-18 11:15:51 +02:00
INNER JOIN tplanned_downtime_agents
ON tplanned_downtime . id = tplanned_downtime_agents . id_downtime
2019-01-30 16:18:44 +01:00
WHERE tplanned_downtime_agents . id_agent = '.$agent[' id_agente '].' AND tplanned_downtime . executed = 1 '
);
$data = [];
$data [ 0 ] = '<div class="left_' . $agent [ 'id_agente' ] . '">' ;
2023-03-09 19:25:14 +01:00
if ( $agent [ 'id_os' ] == CLUSTER_OS_ID ) {
$cluster = PandoraFMS\Cluster :: loadFromAgentId (
$agent [ 'id_agente' ]
);
2023-09-21 10:21:45 +02:00
$url_cluster = 'index.php?sec=reporting&sec2=operation/cluster/cluster' ;
$url = $url_cluster . '&op=view&id=' . $cluster -> id ();
2023-03-09 19:25:14 +01:00
} else {
$url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $agent [ 'id_agente' ];
}
2023-02-07 16:22:52 +01:00
$data [ 0 ] .= html_print_anchor (
[
2023-03-09 19:25:14 +01:00
'href' => ui_get_full_url ( $url ),
2023-02-07 16:22:52 +01:00
'content' => ui_print_truncate_text ( $agent [ 'alias' ], 'agent_medium' , false , true , true ),
],
true
);
2019-01-30 16:18:44 +01:00
if ( $agent [ 'quiet' ]) {
$data [ 0 ] .= ' ' ;
2021-03-11 15:40:23 +01:00
$data [ 0 ] .= html_print_image (
'images/dot_blue.png' ,
true ,
[
'border' => '0' ,
'title' => __ ( 'Quiet' ),
'alt' => '' ,
]
);
2019-01-30 16:18:44 +01:00
}
if ( $in_planned_downtime ) {
2021-03-11 15:40:23 +01:00
$data [ 0 ] .= ui_print_help_tip (
2021-05-10 11:06:43 +02:00
__ ( 'Agent in scheduled downtime' ),
2021-03-11 15:40:23 +01:00
true ,
2023-03-07 15:59:10 +01:00
'images/clock.svg'
2021-03-11 15:40:23 +01:00
);
2019-01-30 16:18:44 +01:00
$data [ 0 ] .= '</em>' ;
}
2023-03-09 19:25:14 +01:00
$data [ 0 ] .= '</div>' ;
2019-01-30 16:18:44 +01:00
2023-05-08 14:26:28 +02:00
$data [ 1 ] = '<span class="' . $custom_font_size . '">' . ui_print_truncate_text ( $agent [ 'description' ], 'description' , false , true , true , '[…]' , 'font-size:6.5pt' ) . '</span>' ;
2009-04-09 23:06:17 +02:00
2023-03-03 14:16:06 +01:00
$data [ 2 ] = '' ;
2019-01-30 16:18:44 +01:00
2023-02-07 16:22:52 +01:00
$data [ 2 ] = html_print_div (
[
'content' => ui_print_os_icon ( $agent [ 'id_os' ], false , true ),
],
true
);
2019-01-30 16:18:44 +01:00
2023-05-08 14:26:28 +02:00
/*
$data [ 3 ] = '<span>' . human_time_description_raw (
2021-03-11 15:40:23 +01:00
$agent [ 'intervalo' ]
2023-05-08 14:26:28 +02:00
) . '</span>' ; */
2019-11-18 10:51:09 +01:00
$data [ 4 ] = '<a href="' . $config [ 'homeurl' ] . 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr=60&group_id=' . $agent [ 'id_grupo' ] . '">' ;
2021-03-11 15:40:23 +01:00
$data [ 4 ] .= ui_print_group_icon (
$agent [ 'id_grupo' ],
true ,
'groups_small' ,
'' ,
2023-02-22 21:19:28 +01:00
false ,
false ,
false ,
'invert_filter main_menu_icon'
2021-03-11 15:40:23 +01:00
);
2019-11-18 10:51:09 +01:00
$data [ 4 ] .= '</a>' ;
2019-01-30 16:18:44 +01:00
$agent [ 'not_init_count' ] = $agent [ 'notinit_count' ];
$data [ 5 ] = ui_print_type_agent_icon (
$agent [ 'id_os' ],
$agent [ 'ultimo_contacto_remoto' ],
$agent [ 'ultimo_contacto' ],
$agent [ 'remote' ],
$agent [ 'agent_version' ]
);
2023-03-10 12:40:21 +01:00
if ( enterprise_installed ()) {
enterprise_include_once ( 'include/functions_config_agents.php' );
if ( enterprise_hook ( 'config_agents_has_remote_configuration' , [ $agent [ 'id_agente' ]])) {
$data [ 5 ] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente=' . $agent [ 'id_agente' ] . '&disk_conf=1">' . html_print_image (
'images/remote-configuration@svg.svg' ,
true ,
[
'align' => 'middle' ,
'title' => __ ( 'Remote config' ),
'class' => 'invert_filter main_menu_icon' ,
]
) . '</a>' ;
}
}
2019-01-30 16:18:44 +01:00
$data [ 6 ] = reporting_tiny_stats ( $agent , true , 'modules' , ':' , $strict_user );
$data [ 7 ] = $status_img ;
$data [ 8 ] = $alert_img ;
$data [ 9 ] = agents_get_interval_status ( $agent );
2023-01-25 17:22:54 +01:00
$last_status_change_agent = agents_get_last_status_change ( $agent [ 'id_agente' ]);
$time_elapsed = ! empty ( $last_status_change_agent ) ? human_time_comparation ( $last_status_change_agent ) : '<em>' . __ ( 'N/A' ) . '</em>' ;
$data [ 10 ] = $time_elapsed ;
$agent_event_filter = [
'id_agent' => $agent [ 'id_agente' ],
'event_view_hr' => 48 ,
'status' => - 1 ,
];
$fb64 = base64_encode ( json_encode ( $agent_event_filter ));
2023-03-10 12:40:21 +01:00
$tableAgents -> cellclass [][ 11 ] = 'table_action_buttons' ;
$data [ 11 ] = '<a href="index.php?sec=eventos&sec2=operation/events/events&fb64=' . $fb64 . '">' . html_print_image (
2023-03-07 15:59:10 +01:00
'images/event.svg' ,
2023-01-25 17:22:54 +01:00
true ,
[
'align' => 'middle' ,
'title' => __ ( 'Agent events' ),
2023-03-07 15:59:10 +01:00
'class' => 'main_menu_icon invert_filter' ,
2023-01-25 17:22:54 +01:00
]
) . '</a>' ;
2023-03-09 19:25:14 +01:00
if ( check_acl ( $config [ 'id_user' ], $agent [ 'id_grupo' ], 'AW' )) {
if ( $agent [ 'id_os' ] == CLUSTER_OS_ID ) {
$cluster = PandoraFMS\Cluster :: loadFromAgentId (
$agent [ 'id_agente' ]
);
$url = 'index.php?sec=reporting&sec2=' ;
$url .= 'operation/cluster/cluster' ;
$url = ui_get_full_url (
$url . '&op=update&id=' . $cluster -> id ()
);
} else {
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $agent [ 'id_agente' ];
}
2023-03-10 12:40:21 +01:00
$data [ 11 ] .= '<a href="' . $url . '">' . html_print_image (
2023-03-09 19:25:14 +01:00
'images/edit.svg' ,
true ,
[
'align' => 'middle' ,
'title' => __ ( 'Edit' ),
'class' => 'main_menu_icon invert_filter' ,
]
) . '</a>' ;
}
2023-02-07 16:22:52 +01:00
array_push ( $tableAgents -> data , $data );
2012-07-24 Miguel de Dios <miguel.dedios@artica.es>
* godmode/setup/file_manager.php, godmode/setup/news.php,
godmode/users/configure_user.php, godmode/users/user_list.php,
godmode/massive/massive_copy_modules.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_delete_action_alerts.php,
godmode/massive/massive_delete_alerts.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_nc_groups_form.php,
godmode/modules/manage_network_templates.php,
godmode/netflow/nf_edit.php, godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php, godmode/netflow/nf.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/agentes/estado_agente.php, operation/agentes/sla_view.php,
operation/agentes/tactical.php,
operation/agentes/estado_generalagente.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
operation/integria_incidents/incident_detail.php,
operation/gis_maps/index.php, operation/events/events_list.php,
operation/events/events.php, operation/messages/message_edit.php,
operation/messages/message_list.php,
operation/reporting/graph_viewer.php, operation/search_reports.php,
operation/netflow/nf_view.php: cleaned source code.
* godmode/massive/massive_operations.php,
godmode/massive/massive_edit_modules.php: fixed the massive edition
of "any" module in agents.
Fixes: #3543484
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6806 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-24 18:38:48 +02:00
}
2019-01-30 16:18:44 +01:00
2023-02-07 16:22:52 +01:00
if ( empty ( $tableAgents -> data ) === false ) {
2023-01-25 17:22:54 +01:00
if ( $order [ 'field' ] === 'last_status_change' ) {
2023-03-03 08:20:44 +01:00
$order_direction = $order [ 'order' ];
usort (
$table -> data ,
function ( $a , $b ) use ( $order_direction ) {
if ( $order_direction === 'ASC' ) {
return strtotime ( $a [ 10 ]) > strtotime ( $b [ 10 ]);
} else {
return strtotime ( $a [ 10 ]) < strtotime ( $b [ 10 ]);
2023-01-25 17:22:54 +01:00
}
2023-03-03 08:20:44 +01:00
}
);
2023-01-25 17:22:54 +01:00
}
2023-07-20 08:43:51 +02:00
$total_items = '<div class="total_pages">' . sprintf ( __ ( 'Total items: %s' ), $total_agents ) . '</div>' ;
echo $total_items ;
2023-02-07 16:22:52 +01:00
html_print_table ( $tableAgents );
2019-01-30 16:18:44 +01:00
2023-02-08 12:43:08 +01:00
$tablePagination = ui_pagination (
2019-01-30 16:18:44 +01:00
$total_agents ,
ui_get_url_refresh (
[
'group_id' => $group_id ,
'search' => $search ,
'sort_field' => $sortField ,
'sort' => $sort ,
'status' => $status ,
]
),
0 ,
0 ,
2019-03-27 17:03:55 +01:00
true ,
2023-02-08 12:43:08 +01:00
'offset' ,
false ,
2023-03-30 12:36:05 +02:00
'paging_simple_numbers'
2019-01-30 16:18:44 +01:00
);
2019-03-27 17:03:55 +01:00
2019-01-30 16:18:44 +01:00
unset ( $table );
} else {
ui_print_info_message ([ 'no_close' => true , 'message' => __ ( 'There are no defined agents' ) ]);
2023-02-08 12:43:08 +01:00
$tablePagination = '' ;
2022-11-23 13:26:54 +01:00
}
if (( bool ) check_acl ( $config [ 'id_user' ], 0 , 'AW' ) === true || ( bool ) check_acl ( $config [ 'id_user' ], 0 , 'AM' ) === true ) {
2019-01-30 16:18:44 +01:00
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">' ;
2022-11-23 13:26:54 +01:00
html_print_action_buttons (
html_print_submit_button (
__ ( 'Create agent' ),
'crt' ,
false ,
[ 'icon' => 'next' ],
true
),
[
2023-02-08 12:43:08 +01:00
'type' => 'data_table' ,
'class' => 'fixed_action_buttons' ,
'right_content' => $tablePagination ,
2022-11-23 13:26:54 +01:00
]
2022-10-25 13:13:52 +02:00
);
2019-01-30 16:18:44 +01:00
echo '</form>' ;
2009-04-09 23:06:17 +02:00
}
2022-11-23 13:26:54 +01:00
2023-01-25 17:22:54 +01:00
// 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>' ;
2007-02-22 17:45:10 +01:00
?>
2011-06-28 15:31:52 +02:00
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
2023-01-25 17:22:54 +01:00
var loading = 0 ;
/* Filter management */
$ ( '#button-load-filter' ) . click ( function ( event ) {
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/agent' ,
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/agent' ,
save_filter_modal : 1 ,
current_filter : $ ( '#latest_filter_id' ) . val ()
},
success : function ( data ){
$ ( '#save-modal-filter' )
. empty ()
. html ( data );
loading = 0 ;
}
});
}
}
});
2019-01-30 16:18:44 +01:00
$ ( " [class^='left'] " ) . mouseenter ( function () {
$ ( " .agent " + $ ( this )[ 0 ] . className ) . css ( 'visibility' , '' );
}) . mouseleave ( function () {
$ ( " .agent " + $ ( this )[ 0 ] . className ) . css ( 'visibility' , 'hidden' );
});
2011-06-28 15:31:52 +02:00
});
2022-03-25 11:04:14 +01:00
</ script >