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
*
* ______ ___ _______ _______ ________
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
* Copyright ( c ) 2005 - 2021 Artica Soluciones Tecnologicas
* Please see http :// pandorafms . org for full contribution list
* 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' );
* 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
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
2019-01-30 16:18:44 +01:00
if ( is_ajax ()) {
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' );
if ( $get_actions_alert_template ) {
$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 ));
switch ( $config [ 'dbtype' ]) {
case 'mysql' :
$sql = sprintf (
" SELECT t1.id, t1.name,
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql,
extras/pandoradb_migrate_v3.2_to_v4.0.sql: changed the default value for
zero/null date "0000-00-00 00:00:00" to "01-01-1970 00:00:00".
* include/functions_graph.php,include/db/postgresql.php,
include/functions_modules.php, include/functions_agents.php,
operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php, operation/servers/view_server.php,
operation/gis_maps/ajax.php, godmode/db/db_sanity.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/configurar_agente.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_alert.php: small fixeds for the support the
PostgreSQL engine.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-05 17:20:49 +02:00
( SELECT COUNT ( t2 . id )
2015-05-04 18:27:23 +02:00
FROM talert_templates t2
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql,
extras/pandoradb_migrate_v3.2_to_v4.0.sql: changed the default value for
zero/null date "0000-00-00 00:00:00" to "01-01-1970 00:00:00".
* include/functions_graph.php,include/db/postgresql.php,
include/functions_modules.php, include/functions_agents.php,
operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php, operation/servers/view_server.php,
operation/gis_maps/ajax.php, godmode/db/db_sanity.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/configurar_agente.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_alert.php: small fixeds for the support the
PostgreSQL engine.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-05 17:20:49 +02:00
WHERE t2 . id = % d
AND t2 . id_alert_action = t1 . id ) as 'sort_order'
2015-05-04 18:27:23 +02:00
FROM talert_actions t1
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql,
extras/pandoradb_migrate_v3.2_to_v4.0.sql: changed the default value for
zero/null date "0000-00-00 00:00:00" to "01-01-1970 00:00:00".
* include/functions_graph.php,include/db/postgresql.php,
include/functions_modules.php, include/functions_agents.php,
operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php, operation/servers/view_server.php,
operation/gis_maps/ajax.php, godmode/db/db_sanity.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/configurar_agente.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_alert.php: small fixeds for the support the
PostgreSQL engine.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-05 17:20:49 +02:00
WHERE id_group IN ( % s )
2019-01-30 16:18:44 +01:00
ORDER BY sort_order DESC " ,
$id_template ,
$filter_groups
);
break ;
case 'oracle' :
$sql = sprintf (
' SELECT t1 . id , t1 . name ,
2011-05-17 17:59:40 +02:00
( 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 )
2019-01-30 16:18:44 +01:00
ORDER BY sort_order DESC ' ,
$id_template ,
$filter_groups
);
break ;
case 'postgresql' :
$sql = sprintf (
' SELECT t1 . id , t1 . name ,
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql,
extras/pandoradb_migrate_v3.2_to_v4.0.sql: changed the default value for
zero/null date "0000-00-00 00:00:00" to "01-01-1970 00:00:00".
* include/functions_graph.php,include/db/postgresql.php,
include/functions_modules.php, include/functions_agents.php,
operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php, operation/servers/view_server.php,
operation/gis_maps/ajax.php, godmode/db/db_sanity.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/configurar_agente.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_alert.php: small fixeds for the support the
PostgreSQL engine.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-05 17:20:49 +02:00
( SELECT COUNT ( t2 . id )
2015-05-04 18:27:23 +02:00
FROM talert_templates t2
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql,
extras/pandoradb_migrate_v3.2_to_v4.0.sql: changed the default value for
zero/null date "0000-00-00 00:00:00" to "01-01-1970 00:00:00".
* include/functions_graph.php,include/db/postgresql.php,
include/functions_modules.php, include/functions_agents.php,
operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php, operation/servers/view_server.php,
operation/gis_maps/ajax.php, godmode/db/db_sanity.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/configurar_agente.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_alert.php: small fixeds for the support the
PostgreSQL engine.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-05 17:20:49 +02:00
WHERE t2 . id = % d
AND t2 . id_alert_action = t1 . id ) as sort_order
2015-05-04 18:27:23 +02:00
FROM talert_actions t1
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql,
extras/pandoradb_migrate_v3.2_to_v4.0.sql: changed the default value for
zero/null date "0000-00-00 00:00:00" to "01-01-1970 00:00:00".
* include/functions_graph.php,include/db/postgresql.php,
include/functions_modules.php, include/functions_agents.php,
operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php, operation/servers/view_server.php,
operation/gis_maps/ajax.php, godmode/db/db_sanity.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/configurar_agente.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_alert.php: small fixeds for the support the
PostgreSQL engine.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-05 17:20:49 +02:00
WHERE id_group IN ( % s )
2019-01-30 16:18:44 +01:00
ORDER BY sort_order DESC ' ,
$id_template ,
$filter_groups
);
break ;
}
$rows = db_get_all_rows_sql ( $sql );
if ( $rows !== false ) {
echo json_encode ( $rows );
} else {
echo 'false' ;
}
return ;
}
if ( $get_agent_module_last_value ) {
$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' ]
);
}
}
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 );
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 = [];
if ( check_acl ( $config [ 'id_user' ], 0 , 'AW' )) {
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' ;
2019-11-06 10:31:26 +01:00
// Setup tab.
2021-03-11 15:40:23 +01:00
$setuptab [ 'text' ] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente">' . html_print_image (
'images/setup.png' ,
true ,
[
'title' => __ ( 'Setup' ),
'class' => 'invert_filter' ,
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
$setuptab [ 'godmode' ] = true ;
$setuptab [ 'active' ] = false ;
$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' ),
],
]
2020-05-29 11:37:06 +02:00
);
2008-01-10 17:40:00 +01:00
2015-01-26 13:50:58 +01:00
if ( ! $strict_user ) {
2019-01-30 16:18:44 +01:00
if ( tags_has_user_acl_tags ()) {
ui_print_tags_warning ();
}
2013-01-10 17:00:30 +01:00
}
2019-11-06 10:31:26 +01:00
// User is deleting agent.
2012-06-13 11:56:20 +02:00
if ( isset ( $result_delete )) {
2019-01-30 16:18:44 +01:00
if ( $result_delete ) {
ui_print_success_message ( __ ( 'Sucessfully deleted agent' ));
} else {
ui_print_error_message ( __ ( '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
echo '<form method="post" action="?sec=view&sec2=operation/agentes/estado_agente&group_id=' . $group_id . '">' ;
2006-03-27 05:37:27 +02:00
2021-03-11 15:40:23 +01:00
echo '<table cellpadding="4" cellspacing="4" class="databox filters bolder mrgn_btn_10px" width="100%">' ;
2015-04-01 13:24:53 +02:00
2022-06-03 14:15:51 +02:00
echo '<tr><td class="nowrap w100px padding-right-2-imp">' ;
2013-05-23 17:42:32 +02:00
2022-06-03 14:15:51 +02:00
echo __ ( 'Group' ) . ' ' . ' ' . ' ' ;
2006-03-27 05:37:27 +02:00
2019-01-30 16:18:44 +01:00
$groups = users_get_groups ( false , $access );
2016-09-08 16:06:12 +02:00
2017-05-29 14:31:46 +02:00
html_print_select_groups ( false , $access , true , 'group_id' , $group_id , 'this.form.submit()' , '' , '' , false , false , true , '' , false );
2012-03-28 18:56:45 +02:00
2022-06-03 14:15:51 +02:00
echo '</td><td class="nowrap">' . ' ' . ' ' . ' ' . ' ' . ' ' ;
2012-03-28 18:56:45 +02:00
2022-06-03 14:15:51 +02:00
echo __ ( 'Recursion' ) . ' ' . ' ' . ' ' ;
2019-01-30 16:18:44 +01:00
html_print_checkbox ( 'recursion' , 1 , $recursion , false , false , 'this.form.submit()' );
2011-07-11 06:28:21 +02:00
2020-09-28 16:11:26 +02:00
echo '</td><td class="nowrap">' ;
2009-04-09 23:06:17 +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-06-03 14:15:51 +02:00
echo __ ( 'Status' ) . ' ' . ' ' . ' ' ;
2019-01-30 16:18:44 +01:00
html_print_select ( $fields , 'status' , $status , 'this.form.submit()' , __ ( 'All' ), AGENT_STATUS_ALL , false , false , true , '' , false , 'width: 90px;' );
2011-12-07 12:58:41 +01:00
2022-06-03 14:15:51 +02:00
echo '</td><td class="nowrap w100px">' ;
echo __ ( 'Search' ) . ' ' . ' ' . ' ' ;
html_print_input_text ( 'search' , $search , '' , 15 );
echo '</td><td class="nowrap w100px">' ;
2011-12-07 12:58:41 +01:00
2022-06-03 14:15:51 +02:00
echo __ ( 'Search in custom fields' ) . ' ' . ' ' . ' ' ;
2019-01-30 16:18:44 +01:00
html_print_input_text ( 'search_custom' , $search_custom , '' , 15 );
2017-10-25 12:04:14 +02:00
2020-09-28 16:11:26 +02:00
echo '</td><td class="nowrap">' ;
2017-10-25 12:04:14 +02:00
2019-01-30 16:18:44 +01:00
html_print_submit_button (
__ ( 'Search' ),
'srcbutton' ,
'' ,
[ 'class' => 'sub search' ]
);
2009-04-09 23:06:17 +02:00
2021-03-11 15:40:23 +01:00
echo '</td>' ;
2012-04-03 18:05:44 +02:00
2015-04-01 13:24:53 +02:00
echo '</tr></table></form>' ;
2013-05-23 17:42:32 +02:00
2019-01-30 16:18:44 +01:00
if ( $search != '' ) {
$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 ;
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 ;
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 ;
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 );
if ( $id != '' ) {
$aux = $id [ 0 ][ 'id_agent' ];
2022-02-04 13:26:03 +01:00
$search_sql = sprintf (
' AND ( `nombre` LIKE "%%%s%%" OR tagente.id_agente = %d' ,
$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-02-04 13:33:46 +01:00
if ( ! empty ( $search_custom )) {
$search_sql_custom = " AND EXISTS (SELECT * FROM tagent_custom_data
WHERE id_agent = id_agente AND description LIKE '%$search_custom%' ) " ;
} else {
$search_sql_custom = '' ;
}
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
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',
2019-01-30 16:18:44 +01:00
'order' => 'tagente.nombre ASC' ,
'disabled' => 0 ,
'status' => $status ,
'search' => $search ,
];
$filter = [
2022-02-01 15:18:45 +01:00
// 'order' => 'tagente.nombre ASC',
2019-01-30 16:18:44 +01:00
'order' => 'tagente.nombre ASC' ,
'disabled' => 0 ,
'status' => $status ,
'search' => $search ,
'offset' => ( int ) get_parameter ( 'offset' ),
'limit' => ( int ) $config [ 'block_size' ],
];
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 {
$total_agents = agents_count_agents_filter (
[
'disabled' => 0 ,
'id_grupo' => $groups ,
'search' => $search_sql ,
'search_custom' => $search_sql_custom ,
'status' => $status ,
],
$access
);
$agents = agents_get_agents (
[
2022-02-04 13:26:03 +01:00
'order' => 'nombre ' . ' ASC' ,
2019-01-30 16:18:44 +01:00
'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_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 ,
$order
);
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
2019-11-06 10:31:26 +01:00
if ( $config [ 'language' ] == 'ja'
|| $config [ 'language' ] == 'zh_CN'
|| $own_info [ 'language' ] == 'ja'
|| $own_info [ 'language' ] == 'zh_CN'
) {
// Adds a custom font size for Japanese and Chinese language.
$custom_font_size = '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' ;
2019-11-06 10:31:26 +01:00
// Prepare pagination.
2019-01-30 16:18:44 +01:00
ui_pagination (
$total_agents ,
ui_get_url_refresh ([ 'group_id' => $group_id , 'recursion' => $recursion , 'search' => $search , 'sort_field' => $sortField , 'sort' => $sort , 'status' => $status ])
);
2008-06-30 10:11:10 +02:00
// Show data.
2015-06-11 20:17:54 +02:00
$table = new stdClass ();
2015-04-21 17:26:20 +02:00
$table -> cellpadding = 0 ;
$table -> cellspacing = 0 ;
2019-01-30 16:18:44 +01:00
$table -> width = '100%' ;
2019-03-27 17:03:55 +01:00
$table -> class = 'info_table' ;
2009-04-09 23:06:17 +02:00
2019-01-30 16:18:44 +01:00
$table -> head = [];
2019-04-05 13:18:38 +02:00
$table -> head [ 0 ] = __ ( 'Agent' ) . ui_get_sorting_arrows ( $url_up_agente , $url_down_agente , $selectNameUp , $selectNameDown );
2021-03-15 15:30:56 +01:00
$table -> size [ 0 ] = '12%' ;
2015-04-21 17:26:20 +02:00
2019-04-05 13:18:38 +02:00
$table -> head [ 1 ] = __ ( 'Description' ) . ui_get_sorting_arrows ( $url_up_description , $url_down_description , $selectDescriptionUp , $selectDescriptionDown );
2019-01-30 16:18:44 +01:00
$table -> size [ 1 ] = '16%' ;
2016-11-03 17:23:36 +01:00
2019-04-05 13:18:38 +02:00
$table -> head [ 10 ] = __ ( 'Remote' ) . ui_get_sorting_arrows ( $url_up_remote , $url_down_remote , $selectRemoteUp , $selectRemoteDown );
2019-01-30 16:18:44 +01:00
$table -> size [ 10 ] = '9%' ;
2015-04-21 17:26:20 +02:00
2019-04-05 13:18:38 +02:00
$table -> head [ 2 ] = __ ( 'OS' ) . ui_get_sorting_arrows ( $url_up_os , $url_down_os , $selectOsUp , $selectOsDown );
2019-01-30 16:18:44 +01:00
$table -> size [ 2 ] = '8%' ;
2015-04-21 17:26:20 +02:00
2019-04-05 13:18:38 +02:00
$table -> head [ 3 ] = __ ( 'Interval' ) . ui_get_sorting_arrows ( $url_up_interval , $url_down_interval , $selectIntervalUp , $selectIntervalDown );
2019-01-30 16:18:44 +01:00
$table -> size [ 3 ] = '10%' ;
2015-04-21 17:26:20 +02:00
2019-04-05 13:18:38 +02:00
$table -> head [ 4 ] = __ ( 'Group' ) . ui_get_sorting_arrows ( $url_up_group , $url_down_group , $selectGroupUp , $selectGroupDown );
2019-01-30 16:18:44 +01:00
$table -> size [ 4 ] = '8%' ;
2015-04-21 17:26:20 +02:00
2017-07-24 15:53:31 +02:00
$table -> head [ 5 ] = __ ( 'Type' );
2019-01-30 16:18:44 +01:00
$table -> size [ 5 ] = '8%' ;
2015-04-21 17:26:20 +02:00
2017-07-24 15:53:31 +02:00
$table -> head [ 6 ] = __ ( 'Modules' );
2019-01-30 16:18:44 +01:00
$table -> size [ 6 ] = '10%' ;
2015-04-21 17:26:20 +02:00
2017-07-24 15:53:31 +02:00
$table -> head [ 7 ] = __ ( 'Status' );
2019-01-30 16:18:44 +01:00
$table -> size [ 7 ] = '4%' ;
2015-04-21 17:26:20 +02:00
2017-07-24 15:53:31 +02:00
$table -> head [ 8 ] = __ ( 'Alerts' );
2019-01-30 16:18:44 +01:00
$table -> size [ 8 ] = '4%' ;
2017-07-24 15:53:31 +02:00
2019-04-05 13:18:38 +02:00
$table -> head [ 9 ] = __ ( 'Last contact' ) . ui_get_sorting_arrows ( $url_up_last , $url_down_last , $selectLastContactUp , $selectLastContactDown );
2019-01-30 16:18:44 +01:00
$table -> size [ 9 ] = '15%' ;
2009-04-09 23:06:17 +02:00
2019-01-30 16:18:44 +01:00
$table -> align = [];
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
2019-01-30 16:18:44 +01:00
$table -> align [ 2 ] = 'left' ;
$table -> align [ 3 ] = 'left' ;
$table -> align [ 4 ] = 'left' ;
$table -> align [ 5 ] = 'left' ;
$table -> align [ 6 ] = 'left' ;
$table -> align [ 7 ] = 'left' ;
$table -> align [ 8 ] = 'left' ;
$table -> align [ 9 ] = 'left' ;
2011-11-23 17:26:17 +01:00
2019-01-30 16:18:44 +01:00
$table -> style = [];
2009-04-09 23:06:17 +02:00
2019-01-30 16:18:44 +01:00
$table -> data = [];
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 ) {
$table -> rowclass [ $iterator ] = 'rowPair' ;
} else {
$table -> rowclass [ $iterator ] = 'rowOdd' ;
}
$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' ] . '">' ;
2020-12-10 12:06:56 +01:00
$data [ 0 ] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $agent [ 'id_agente' ] . '"><b><span class="' . $custom_font_size . ' title ="' . $agent [ 'nombre' ] . '">' . ui_print_truncate_text ( $agent [ 'alias' ], 'agent_medium' , false , true , true ) . '</span></b></a>' ;
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 ,
2021-05-10 11:06:43 +02:00
'images/minireloj-16.png'
2021-03-11 15:40:23 +01:00
);
2019-01-30 16:18:44 +01:00
$data [ 0 ] .= '</em>' ;
}
$data [ 0 ] .= '<div class="agentleft_' . $agent [ 'id_agente' ] . '" style="visibility: hidden; clear: left;">' ;
2020-05-22 12:14:01 +02:00
if ( $agent [ 'id_os' ] == CLUSTER_OS_ID ) {
2022-12-20 15:43:05 +01:00
$cluster = PandoraFMS\Cluster :: loadFromAgentId (
$agent [ 'id_agente' ]
);
$url = 'index.php?sec=reporting&sec2=' ;
$url .= 'operation/cluster/cluster' ;
$url = ui_get_full_url (
$url . '&op=view&id=' . $cluster -> id ()
);
$data [ 0 ] .= '<a href="' . $url . '">' . __ ( 'View' ) . '</a>' ;
2019-01-30 16:18:44 +01:00
} else {
$data [ 0 ] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $agent [ 'id_agente' ] . '">' . __ ( 'View' ) . '</a>' ;
}
if ( check_acl ( $config [ 'id_user' ], $agent [ 'id_grupo' ], 'AW' )) {
$data [ 0 ] .= ' | ' ;
2020-05-22 12:14:01 +02:00
if ( $agent [ 'id_os' ] == CLUSTER_OS_ID ) {
2022-12-20 15:43:05 +01:00
$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 ()
);
$data [ 0 ] .= '<a href="' . $url . '">' . __ ( 'Edit' ) . '</a>' ;
2019-01-30 16:18:44 +01:00
} else {
$data [ 0 ] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $agent [ 'id_agente' ] . '">' . __ ( 'Edit' ) . '</a>' ;
}
}
$data [ 0 ] .= '</div></div>' ;
2019-11-06 10:31:26 +01:00
$data [ 1 ] = '<span class="' . $custom_font_size . '">' . ui_print_truncate_text ( $agent [ 'description' ], 'description' , false , true , true , '[…]' ) . '</span>' ;
2009-04-09 23:06:17 +02:00
2019-01-30 16:18:44 +01:00
$data [ 10 ] = '' ;
if ( enterprise_installed ()) {
enterprise_include_once ( 'include/functions_config_agents.php' );
if ( enterprise_hook ( 'config_agents_has_remote_configuration' , [ $agent [ 'id_agente' ]])) {
2021-03-11 15:40:23 +01:00
$data [ 10 ] = '<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/application_edit.png' ,
true ,
[
'align' => 'middle' ,
'title' => __ ( 'Remote config' ),
'class' => 'invert_filter' ,
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
}
}
$data [ 2 ] = ui_print_os_icon ( $agent [ 'id_os' ], false , true );
2021-03-11 15:40:23 +01:00
$data [ 3 ] = '<span>' . human_time_description_raw (
$agent [ 'intervalo' ]
) . '</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' ,
'' ,
false
);
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' ]
);
$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 );
// This old code was returning "never" on agents without modules, BAD !!
// And does not print outdated agents in red. WRONG !!!!
// $data[7] = ui_print_timestamp ($agent_info["last_contact"], true);
array_push ( $table -> 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
if ( ! empty ( $table -> data )) {
html_print_table ( $table );
ui_pagination (
$total_agents ,
ui_get_url_refresh (
[
'group_id' => $group_id ,
'search' => $search ,
'sort_field' => $sortField ,
'sort' => $sort ,
'status' => $status ,
]
),
0 ,
0 ,
false ,
'offset' ,
2019-03-27 17:03:55 +01:00
true ,
'pagination-bottom'
2019-01-30 16:18:44 +01:00
);
2019-03-27 17:03:55 +01:00
if ( check_acl ( $config [ 'id_user' ], 0 , 'AW' ) || check_acl ( $config [ 'id_user' ], 0 , 'AM' )) {
2021-03-11 15:40:23 +01:00
echo '<div class="right float-right">' ;
2019-03-27 17:03:55 +01:00
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">' ;
html_print_submit_button ( __ ( 'Create agent' ), 'crt' , false , 'class="sub next"' );
echo '</form>' ;
echo '</div>' ;
}
2019-01-30 16:18:44 +01:00
unset ( $table );
} else {
ui_print_info_message ([ 'no_close' => true , 'message' => __ ( 'There are no defined agents' ) ]);
2021-03-11 15:40:23 +01:00
echo '<div class="right float-right">' ;
2019-01-30 16:18:44 +01:00
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">' ;
html_print_submit_button ( __ ( 'Create agent' ), 'crt' , false , 'class="sub next"' );
echo '</form>' ;
echo '</div>' ;
2009-04-09 23:06:17 +02:00
}
2007-02-22 17:45:10 +01:00
?>
2011-06-28 15:31:52 +02:00
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
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 >