2006-07-09 02:33:33 +02:00
< ? php
2008-08-22 20:07:32 +02:00
2009-06-08 20:21:21 +02:00
// Pandora FMS - http://pandorafms.com
// ==================================================
2010-03-02 17:41:27 +01:00
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
2009-06-08 20:21:21 +02:00
// Please see http://pandorafms.org for full contribution list
2008-04-01 15:53:11 +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.
2019-04-09 10:46:37 +02:00
// Load global vars.
2010-03-03 18:10:37 +01:00
global $config ;
2019-01-30 16:18:44 +01:00
enterprise_include ( 'godmode/agentes/configurar_agente.php' );
enterprise_include ( 'include/functions_policies.php' );
enterprise_include_once ( 'include/functions_modules.php' );
require_once $config [ 'homedir' ] . '/include/functions_agents.php' ;
require_once $config [ 'homedir' ] . '/include/functions_cron.php' ;
2012-08-14 14:52:29 +02:00
ui_require_javascript_file ( 'encode_decode_base64' );
2008-08-11 Esteban Sanchez <estebans@artica.es>
* include/functions_db.php: Added __ as an alias of lang_string().
* include/functions_reporting_pdf.php,
include/functions_reporting.php, include/functions.php,
include/functions_visual_map.php, index.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/incidents/incident_note.php,
operation/incidents/incident_search.php,
operation/incidents/incident_statistics.php,
operation/snmpconsole/snmp_alert.php,
operation/snmpconsole/snmp_view.php, operation/users/user.php,
operation/users/user_edit.php, operation/users/user_statistics.php,
operation/events/event_statistics.php, operation/events/events.php,
operation/visual_console/render_view.php,
operation/visual_console/index.php, operation/extensions.php,
operation/agentes/estado_alertas.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_grupo.php, operation/agentes/export_csv.php,
operation/agentes/datos_agente.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/bulbs.php,
operation/agentes/status_events.php, operation/agentes/sla_view.php,
operation/agentes/exportdata.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php, operation/agentes/estadisticas.php,
operation/agentes/tactical.php, operation/agentes/networkmap.php,
operation/messages/message.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
operation/reporting/custom_reporting.php,
operation/servers/view_server.php,
operation/servers/view_server_detail.php, operation/menu.php,
reporting/fgraph.php, reporting/stat_win.php, ajax.php,
general/logoff.php, general/pandora_help.php, general/footer.php,
general/noaccess.php, general/logon_failed.php,
general/links_menu.php, general/login_page.php, general/logon_ok.php,
general/header.php, general/main_menu.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/setup/news.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/profiles/profile_list.php,
godmode/admin_access_logs.php, godmode/db/db_info_data.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_network.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/alert_manager.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/alert_manager_editor.php,
godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/agent_disk_conf_editor.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php,
godmode/agentes/agent_manager.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_templates_form.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/map_builder.php,
godmode/reporting/graph_builder.php, godmode/servers/plugin.php,
godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/modify_alert.php, godmode/alerts/configure_alert.php,
godmode/menu.php: Replaced $id_user with $config['id_user']. Use __a
instead of $lang_label to future use of gettext. Style
corrections.
* godmode/agentes/planned_downtime.php: Rewritten to use Pandora
functions and adopt the UI style. Replaced lang_string with __().
* pandoradb.sql: Fields in tplanned_downtime renamed to fit
guidelines.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1005 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-08-11 12:59:07 +02:00
2019-01-30 16:18:44 +01:00
check_login ();
2008-08-11 Esteban Sanchez <estebans@artica.es>
* include/functions_db.php: Added __ as an alias of lang_string().
* include/functions_reporting_pdf.php,
include/functions_reporting.php, include/functions.php,
include/functions_visual_map.php, index.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/incidents/incident_note.php,
operation/incidents/incident_search.php,
operation/incidents/incident_statistics.php,
operation/snmpconsole/snmp_alert.php,
operation/snmpconsole/snmp_view.php, operation/users/user.php,
operation/users/user_edit.php, operation/users/user_statistics.php,
operation/events/event_statistics.php, operation/events/events.php,
operation/visual_console/render_view.php,
operation/visual_console/index.php, operation/extensions.php,
operation/agentes/estado_alertas.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_grupo.php, operation/agentes/export_csv.php,
operation/agentes/datos_agente.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/bulbs.php,
operation/agentes/status_events.php, operation/agentes/sla_view.php,
operation/agentes/exportdata.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php, operation/agentes/estadisticas.php,
operation/agentes/tactical.php, operation/agentes/networkmap.php,
operation/messages/message.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
operation/reporting/custom_reporting.php,
operation/servers/view_server.php,
operation/servers/view_server_detail.php, operation/menu.php,
reporting/fgraph.php, reporting/stat_win.php, ajax.php,
general/logoff.php, general/pandora_help.php, general/footer.php,
general/noaccess.php, general/logon_failed.php,
general/links_menu.php, general/login_page.php, general/logon_ok.php,
general/header.php, general/main_menu.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/setup/news.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/profiles/profile_list.php,
godmode/admin_access_logs.php, godmode/db/db_info_data.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_network.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/alert_manager.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/alert_manager_editor.php,
godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/agent_disk_conf_editor.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php,
godmode/agentes/agent_manager.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_templates_form.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/map_builder.php,
godmode/reporting/graph_builder.php, godmode/servers/plugin.php,
godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/modify_alert.php, godmode/alerts/configure_alert.php,
godmode/menu.php: Replaced $id_user with $config['id_user']. Use __a
instead of $lang_label to future use of gettext. Style
corrections.
* godmode/agentes/planned_downtime.php: Rewritten to use Pandora
functions and adopt the UI style. Replaced lang_string with __().
* pandoradb.sql: Fields in tplanned_downtime renamed to fit
guidelines.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1005 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-08-11 12:59:07 +02:00
2019-04-09 10:46:37 +02:00
// Get tab parameter to check ACL in each tabs.
2019-01-30 16:18:44 +01:00
$tab = get_parameter ( 'tab' , 'main' );
2013-01-14 16:11:07 +01:00
2019-04-09 10:46:37 +02:00
// See if id_agente is set (either POST or GET, otherwise -1.
2019-01-30 16:18:44 +01:00
$id_agente = ( int ) get_parameter ( 'id_agente' );
2009-04-13 17:05:21 +02:00
$group = 0 ;
2019-01-30 16:18:44 +01:00
$all_groups = [ $group ];
2018-03-27 16:38:17 +02:00
if ( $id_agente ) {
2019-01-30 16:18:44 +01:00
$group = agents_get_agent_group ( $id_agente );
$all_groups = agents_get_all_groups_agent ( $id_agente , $group );
2018-03-27 16:38:17 +02:00
}
2008-09-29 17:36:03 +02:00
2019-01-30 16:18:44 +01:00
if ( ! check_acl_one_of_groups ( $config [ 'id_user' ], $all_groups , 'AW' )) {
$access_granted = false ;
switch ( $tab ) {
case 'alert' :
case 'module' :
if ( check_acl_one_of_groups ( $config [ 'id_user' ], $all_groups , 'AD' )) {
$access_granted = true ;
}
break ;
default :
2019-04-09 10:46:37 +02:00
// Default.
2019-01-30 16:18:44 +01:00
break ;
}
if ( ! $access_granted ) {
db_pandora_audit (
'ACL Violation' ,
'Trying to access agent manager'
);
include 'general/noaccess.php' ;
return ;
}
2008-09-29 17:36:03 +02:00
}
2007-02-27 20:03:56 +01:00
2019-01-30 16:18:44 +01:00
require_once 'include/functions_modules.php' ;
require_once 'include/functions_alerts.php' ;
require_once 'include/functions_reporting.php' ;
2009-05-27 12:31:27 +02:00
2019-04-09 10:46:37 +02:00
// Get passed variables.
2013-01-29 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/reporting_builder.php,
godmode/agentes/configurar_agente.php, godmode/menu.php,
include/functions_ui.php, include/functions_agents.php,
include/functions_alerts.php, include/functions_menu.php,
include/functions_networkmap.php,
include/help/en/help_alert_type.php,
include/help/es/help_alert_type.php,
include/functions_reporting.php,
operation/agentes/alerts_status.functions.php,
operation/agentes/alerts_status.php: erased the ocurrences about
the deprecated alert compounds.
Fixes: #3602487
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7543 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-29 15:42:55 +01:00
$alerttype = get_parameter ( 'alerttype' );
2019-01-30 16:18:44 +01:00
$id_agent_module = ( int ) get_parameter ( 'id_agent_module' );
2008-03-06 Sancho Lerena <slerena@gmail.com>
Pandora FMS 2.0 development first commit. 1.4 version is now 2.0
* pandoradb_data.sql: Added correct tnetwork_components, fixed
ttipo_modulo (categoria values).
* include/styles/pandora.css: Added some server icons, tab style
for module editor has been improved.
* include/functions_db.php: added new functions, lang_string and
check_login, and a first review of several functions that currently
need change for new config session parameters in array $config[]
* include/javascript/pandora.js: Added a new global include for
spare javascript functions before included into a few pages.
* include/languages/language_en.php: New tokens.
* include/help*: New contextual help system.
* include/config_process.php: New way to manage config.
* include/functions.php: Added new functions to manage global
* operation/agentes/estado_ultimopaquete.php: removed old javascript
code from there.
* operation/agentes/estado_agente.php: Removed references to deprecated
field "agent_type".
* operation/agentes/tactical.php: Some code cleanup and progressbar
issues merged from 1.3.1 branch. Need to add support to new server
types and new module types.
* operation/servers/view_server.php: Added support to new servers, code
cleanup.
* reporting/fgraph.php: Code cleanup, changes to use new config method,
and a lot of style change.
* general/pandora_help.php: New source for contextual help in the way
of moodle.
* general/footer.php, general/noaccess.php: Code cleanup and uses of
new config.
* module_manager_editor: New editors for each module family. Need
finish and implement EDITION of data, now only inserts data.
* godmode/agentes/agent_manager.php: Implemented new server assigment
and edition.
* godmode/agentes/configurar_agente.php: Small changes that affects
module management, visualization and agent management.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@739 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-03-07 17:22:16 +01:00
2019-04-09 10:46:37 +02:00
// Init vars.
2019-01-30 16:18:44 +01:00
$descripcion = '' ;
$comentarios = '' ;
$campo_1 = '' ;
$campo_2 = '' ;
$campo_3 = '' ;
2008-09-12 17:40:00 +02:00
$maximo = 0 ;
$minimo = 0 ;
2019-01-30 16:18:44 +01:00
$nombre_agente = '' ;
2016-09-26 10:58:42 +02:00
$alias = get_parameter ( 'alias' , '' );
2017-03-06 15:22:01 +01:00
$alias_as_name = 0 ;
2013-01-29 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/reporting_builder.php,
godmode/agentes/configurar_agente.php, godmode/menu.php,
include/functions_ui.php, include/functions_agents.php,
include/functions_alerts.php, include/functions_menu.php,
include/functions_networkmap.php,
include/help/en/help_alert_type.php,
include/help/es/help_alert_type.php,
include/functions_reporting.php,
operation/agentes/alerts_status.functions.php,
operation/agentes/alerts_status.php: erased the ocurrences about
the deprecated alert compounds.
Fixes: #3602487
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7543 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-29 15:42:55 +01:00
$direccion_agente = get_parameter ( 'direccion' , '' );
2013-05-01 14:09:57 +02:00
$direccion_agente = trim ( io_safe_output ( $direccion_agente ));
$direccion_agente = io_safe_input ( $direccion_agente );
2019-01-09 16:20:24 +01:00
$unique_ip = 0 ;
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
$intervalo = SECONDS_5MINUTES ;
2012-02-03 13:33:45 +01:00
$ff_interval = 0 ;
2012-08-21 Miguel de Dios <miguel.dedios@artica.es>
* extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/module_manager.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php: added in the modules the same
feature to set agent in "Quiet" mode.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6898 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-21 20:57:48 +02:00
$quiet_module = 0 ;
2018-06-26 13:23:12 +02:00
$cps_module = 0 ;
2019-01-30 16:18:44 +01:00
$id_server = '' ;
2007-02-27 20:03:56 +01:00
$max_alerts = 0 ;
2007-08-23 17:52:42 +02:00
$modo = 1 ;
2007-02-27 20:03:56 +01:00
$update_module = 0 ;
2019-01-30 16:18:44 +01:00
$modulo_id_agente = '' ;
$modulo_id_tipo_modulo = '' ;
$modulo_nombre = '' ;
$modulo_descripcion = '' ;
$alerta_id_aam = '' ;
$alerta_campo1 = '' ;
$alerta_campo2 = '' ;
$alerta_campo3 = '' ;
$alerta_dis_max = '' ;
$alerta_dis_min = '' ;
2008-09-12 17:40:00 +02:00
$alerta_min_alerts = 0 ;
$alerta_max_alerts = 1 ;
2019-01-30 16:18:44 +01:00
$alerta_time_threshold = '' ;
$alerta_descripcion = '' ;
$disabled = '' ;
2008-09-12 17:40:00 +02:00
$id_parent = 0 ;
2019-01-30 16:18:44 +01:00
$modulo_max = '' ;
$modulo_min = '' ;
$module_interval = '' ;
$module_ff_interval = '' ;
$tcp_port = '' ;
$tcp_send = '' ;
$tcp_rcv = '' ;
$snmp_oid = '' ;
$ip_target = '' ;
$snmp_community = '' ;
$combo_snmp_oid = '' ;
2007-03-12 18:58:52 +01:00
$agent_created_ok = 0 ;
$create_agent = 0 ;
2019-01-30 16:18:44 +01:00
$alert_text = '' ;
$time_from = '' ;
$time_to = '' ;
$alerta_campo2_rec = '' ;
$alerta_campo3_rec = '' ;
$alert_id_agent = '' ;
2008-09-12 17:40:00 +02:00
$alert_d1 = 1 ;
$alert_d2 = 1 ;
$alert_d3 = 1 ;
$alert_d4 = 1 ;
$alert_d5 = 1 ;
$alert_d6 = 1 ;
$alert_d7 = 1 ;
$alert_recovery = 0 ;
$alert_priority = 0 ;
2009-04-13 17:05:21 +02:00
$server_name = '' ;
2008-06-26 Esteban Sanchez <estebans@artica.es>
* ajax.php: Sed id_user in config array.
* godmode/menu.php, general/header.php, operation/menu.php: Replaced
lang_label with lang_string().
* general/logon_ok.php: Reduced one indentation level.
* godmode/agentes/agent_manager.php: Replaced lang_label with
lang_string(). Use pandora functions.
* include/functions_html.php, godmode/agentes/configurar_agente.php:
Tab and blankspaces style correction.
* godmode/reporting/map_builder.php: Complete rewritten to provide an
intuitive way of build the maps. It's cool, useful and very simple.
* godmode/reporting/reporting_builder.php: Deleted an output debug.
* godmode/setup/setup.php: Rewritten to use pandora functions. Added a
colorpicker for color settings.
* include/config.php: Reset pandora password. We must solve things
with this file...
* include/functions.php: Check if input is an array on safe_input().
Use filename as id in array returned by list_files().
* include/functions_db.php: Renamed return_coordinate_* functions.
Style correction.
* include/javascript/jquery.js: Updated to 1.2.6.
* include/javascript/jquery.ui.datepicker.js: Code minimized.
* include/javascript/pandora.js: Style correction.
* include/javascript/wz_jsgraphics.js: Added a class to the elements
of a line, so it can be modified using javascript.
* /include/styles/pandora.css: Added style to some tables dropdowns.
Added new styles relative to visual map editor.
* operation/reporting/reporting_viewer.php: Style correction. Added
jQuery UI.
* operation/visual_console/index.php: Use Pandora functions.
* operation/visual_console/render_view.php: Drawing the map is now on
functions_visual_map.php. Added a countdown if a refresh time is set.
Use pandora functions. Style correction.
* reporting/fgraph.php: Style correction. Use graphic_error() if
there's no data on grafico_modulo_sparse().
* images/trash.png: Added to repository. Image used on trash area on
visual map editor.
* images/console/background/africa.jpg,
images/console/background/asia.jpg,
images/console/background/europe.jpg,
images/console/background/north_america.jpg,
images/console/background/oceania.jpg,
images/console/background/shouth_america.jpg,
images/console/background/world.jpg: Added to repository. Useful and
cool map backgrounds.
* include/functions_visual_map.php: Added to repository. Implements
visual map functions like drawing the map.
* include/javascript/jquery.colorpicker.js: Added to repository.
Implements a color picker widget.
* /include/javascript/jquery.countdown.js: Added to repository.
Implements a countdown widget.
* include/javascript/jquery.ui.core.js: Added to repository. jQuery UI
core.
* include/javascript/jquery.ui.draggable.js: Added to repository.
jQuery draggable plugin.
* include/javascript/jquery.ui.droppable.js: Added to repository.
jQuery droppable plugin.
* include/javascript/pandora_visual_console.js: Added to repository.
Function useful to visual map interface.
* include/languages/countdown_*.js: Added to repository. Countdown
localization.
* include/languages/date_es_la.js, include/languages/date_gl.js,
include/languages/time_es_la.js, include/languages/time_gl.js: Added
to repository. Missing localizations.
* include/styles/color-picker.css: Added to repository. Colorpicker
style sheet.
* include/styles/countdown.css: Added to repository. Countdown style
sheet.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@899 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-26 15:26:48 +02:00
$grupo = 0 ;
2019-01-30 16:18:44 +01:00
$id_os = 9 ;
2019-04-09 10:46:37 +02:00
// Windows.
2019-01-30 16:18:44 +01:00
$custom_id = '' ;
2009-09-01 17:25:18 +02:00
$cascade_protection = 0 ;
2017-01-25 13:59:14 +01:00
$cascade_protection_modules = 0 ;
2017-10-17 16:58:05 +02:00
$safe_mode = 0 ;
$safe_mode_module = 0 ;
2010-02-04 10:42:46 +01:00
$icon_path = '' ;
$update_gis_data = 0 ;
2019-01-30 16:18:44 +01:00
$unit = '' ;
$id_tag = [];
2011-06-28 15:31:52 +02:00
$tab_description = '' ;
2012-01-23 19:36:22 +01:00
$url_description = '' ;
2012-08-21 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.oracle.sql, operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php,
operation/agentes/ver_agente.php,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
godmode/agentes/agent_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/configurar_agente.php, pandoradb.sql,
pandoradb.postgreSQL.sql: added the feature to set a agent in
"Quiet" mode.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6896 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-21 19:12:02 +02:00
$quiet = 0 ;
2012-08-14 14:52:29 +02:00
$macros = '' ;
2018-06-26 13:23:12 +02:00
$cps = 0 ;
2007-03-12 18:58:52 +01:00
2019-01-30 16:18:44 +01:00
$create_agent = ( bool ) get_parameter ( 'create_agent' );
$module_macros = [];
2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php: Agent module editions
rewritten. The interface should be clearer now and SNMP walking much
more faster, since it's done with AJAX. Some cleanup might be needed
yet.
* godmode/agentes/module_manager_editor_common.php: Added to
repository. Common part for agent module editors.
* images/edit.png, images/spinner.gif: Added to repository.
* include/javascript/jquery.form.js: Added to repository. jQuery form
plugin.
* include/javascript/jquery.pandora.js: Added to repository. Special
Pandora addons for jQuery library.
* include/javascript/pandora.js: Added an extension to Array
javascript objects to check if an array has an element.
* include/styles/pandora.css: Added styling for new module editors.
* include/functions_db.php: Added get_moduletype_description().
* index.php: Added Pandora jQuery extensions.
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text
useless field from talert_templates.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-02-02 16:40:31 +01:00
2019-04-09 10:46:37 +02:00
// Create agent.
2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php: Agent module editions
rewritten. The interface should be clearer now and SNMP walking much
more faster, since it's done with AJAX. Some cleanup might be needed
yet.
* godmode/agentes/module_manager_editor_common.php: Added to
repository. Common part for agent module editors.
* images/edit.png, images/spinner.gif: Added to repository.
* include/javascript/jquery.form.js: Added to repository. jQuery form
plugin.
* include/javascript/jquery.pandora.js: Added to repository. Special
Pandora addons for jQuery library.
* include/javascript/pandora.js: Added an extension to Array
javascript objects to check if an array has an element.
* include/styles/pandora.css: Added styling for new module editors.
* include/functions_db.php: Added get_moduletype_description().
* index.php: Added Pandora jQuery extensions.
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text
useless field from talert_templates.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-02-02 16:40:31 +01:00
if ( $create_agent ) {
2019-01-30 16:18:44 +01:00
$mssg_warning = 0 ;
2019-02-22 12:30:27 +01:00
$alias_safe_output = io_safe_output ( get_parameter ( 'alias' , '' ));
2019-04-01 15:18:56 +02:00
$alias = io_safe_input ( trim ( preg_replace ( '/[\/\\\|%#&$]/' , '' , $alias_safe_output )));
2019-01-30 16:18:44 +01:00
$alias_as_name = ( int ) get_parameter_post ( 'alias_as_name' , 0 );
$direccion_agente = ( string ) get_parameter_post ( 'direccion' , '' );
2019-02-06 18:06:49 +01:00
$unique_ip = ( int ) get_parameter_post ( 'unique_ip' , 0 );
2019-01-30 16:18:44 +01:00
2019-04-09 10:46:37 +02:00
// Safe_output only validate ip.
2019-01-30 16:18:44 +01:00
$direccion_agente = trim ( io_safe_output ( $direccion_agente ));
if ( ! validate_address ( $direccion_agente )) {
$mssg_warning = 1 ;
}
2019-04-09 10:46:37 +02:00
// Safe-input before validate ip.
2019-01-30 16:18:44 +01:00
$direccion_agente = io_safe_input ( $direccion_agente );
$nombre_agente = hash ( 'sha256' , $alias . '|' . $direccion_agente . '|' . time () . '|' . sprintf ( '%04d' , rand ( 0 , 10000 )));
$grupo = ( int ) get_parameter_post ( 'grupo' );
$intervalo = ( string ) get_parameter_post ( 'intervalo' , SECONDS_5MINUTES );
$comentarios = ( string ) get_parameter_post ( 'comentarios' , '' );
$modo = ( int ) get_parameter_post ( 'modo' );
$id_parent = ( int ) get_parameter_post ( 'id_agent_parent' );
$server_name = ( string ) get_parameter_post ( 'server_name' );
$id_os = ( int ) get_parameter_post ( 'id_os' );
$disabled = ( int ) get_parameter_post ( 'disabled' );
$custom_id = ( string ) get_parameter_post ( 'custom_id' , '' );
$cascade_protection = ( int ) get_parameter_post ( 'cascade_protection' , 0 );
$cascade_protection_module = ( int ) get_parameter_post ( 'cascade_protection_module' , 0 );
$safe_mode = ( int ) get_parameter_post ( 'safe_mode' , 0 );
$safe_mode_module = ( int ) get_parameter_post ( 'safe_mode_module' , 0 );
$icon_path = ( string ) get_parameter_post ( 'icon_path' , '' );
$update_gis_data = ( int ) get_parameter_post ( 'update_gis_data' , 0 );
$url_description = ( string ) get_parameter ( 'url_description' );
$quiet = ( int ) get_parameter ( 'quiet' , 0 );
2019-05-27 14:12:53 +02:00
$cps = ( int ) get_parameter_switch ( 'cps' , - 1 );
2019-01-30 16:18:44 +01:00
$secondary_groups = ( string ) get_parameter ( 'secondary_hidden' , '' );
$fields = db_get_all_fields_in_table ( 'tagent_custom_fields' );
if ( $fields === false ) {
$fields = [];
}
$field_values = [];
foreach ( $fields as $field ) {
$field_values [ $field [ 'id_field' ]] = ( string ) get_parameter_post ( 'customvalue_' . $field [ 'id_field' ], '' );
}
2019-04-09 10:46:37 +02:00
// Check if agent exists (BUG WC-50518-2).
2019-01-30 16:18:44 +01:00
if ( $alias == '' ) {
$agent_creation_error = __ ( 'No agent alias specified' );
$agent_created_ok = 0 ;
} else {
if ( $alias_as_name ) {
$sql = 'SELECT nombre FROM tagente WHERE nombre = "' . $alias . '"' ;
$exists_alias = db_get_row_sql ( $sql );
$nombre_agente = $alias ;
}
2019-02-06 18:06:49 +01:00
if ( $unique_ip && $direccion_agente != '' ) {
$sql = 'SELECT direccion FROM tagente WHERE direccion = "' . $direccion_agente . '"' ;
$exists_ip = db_get_row_sql ( $sql );
}
if ( ! $exists_alias && ! $exists_ip ) {
2019-01-30 16:18:44 +01:00
$id_agente = db_process_sql_insert (
'tagente' ,
[
'nombre' => $nombre_agente ,
'alias' => $alias ,
'alias_as_name' => $alias_as_name ,
'direccion' => $direccion_agente ,
'id_grupo' => $grupo ,
'intervalo' => $intervalo ,
'comentarios' => $comentarios ,
'modo' => $modo ,
'id_os' => $id_os ,
'disabled' => $disabled ,
'cascade_protection' => $cascade_protection ,
'cascade_protection_module' => $cascade_protection_module ,
'server_name' => $server_name ,
'id_parent' => $id_parent ,
'custom_id' => $custom_id ,
'icon_path' => $icon_path ,
'update_gis_data' => $update_gis_data ,
'url_address' => $url_description ,
'quiet' => $quiet ,
'cps' => $cps ,
]
);
enterprise_hook ( 'update_agent' , [ $id_agente ]);
} else {
$id_agente = false ;
}
if ( $id_agente !== false ) {
2019-04-09 10:46:37 +02:00
// Create custom fields for this agent.
2019-01-30 16:18:44 +01:00
foreach ( $field_values as $key => $value ) {
$update_custom = db_process_sql_insert (
'tagent_custom_data' ,
[
'id_field' => $key ,
'id_agent' => $id_agente ,
'description' => $value ,
]
);
}
2019-04-09 10:46:37 +02:00
// Create address for this agent in taddress.
2019-01-30 16:18:44 +01:00
if ( $direccion_agente != '' ) {
agents_add_address ( $id_agente , $direccion_agente );
}
$agent_created_ok = true ;
$tpolicy_group_old = db_get_all_rows_sql (
' SELECT id_policy FROM tpolicy_groups
WHERE id_group = ' . $grupo
);
if ( $tpolicy_group_old ) {
foreach ( $tpolicy_group_old as $key => $old_group ) {
db_process_sql_insert (
'tpolicy_agents' ,
[
'id_policy' => $old_group [ 'id_policy' ],
'id_agent' => $id_agente ,
]
);
}
}
$info = '{"Name":"' . $nombre_agente . ' " ,
" IP " : " '. $direccion_agente .' " ,
" Group " : " '. $grupo .' " ,
" Interval " : " '. $intervalo .' " ,
" Comments " : " '. $comentarios .' " ,
" Mode " : " '. $modo .' " ,
" ID_parent: " : " '. $id_parent .' " ,
" Server " : " '. $server_name .' " ,
" ID os " : " '. $id_os .' " ,
" Disabled " : " '. $disabled .' " ,
" Custom ID " : " '. $custom_id .' " ,
" Cascade protection " : " '. $cascade_protection .' " ,
" Cascade protection module " : " '. $cascade_protection_module .' " ,
" Icon path " : " '. $icon_path .' " ,
" Update GIS data " : " '. $update_gis_data .' " ,
" Url description " : " '. $url_description .' " ,
" Quiet " : " '.(int) $quiet .' " ,
" Cps " : " '.(int) $cps .' " } ' ;
2019-04-09 10:46:37 +02:00
// Create the secondary groups.
2019-01-30 16:18:44 +01:00
enterprise_hook (
'agents_update_secondary_groups' ,
[
$id_agente ,
explode ( ',' , $secondary_groups ),
[],
]
);
$unsafe_alias = io_safe_output ( $alias );
db_pandora_audit (
'Agent management' ,
" Created agent $unsafe_alias " ,
false ,
true ,
$info
);
} else {
$id_agente = 0 ;
$agent_creation_error = __ ( 'Could not be created' );
if ( $exists_alias ) {
$agent_creation_error = __ ( 'Could not be created, because name already exists' );
2019-02-06 18:06:49 +01:00
} else if ( $exists_ip ) {
$agent_creation_error = __ ( 'Could not be created, because IP already exists' );
2019-01-30 16:18:44 +01:00
}
}
}
2007-03-12 18:58:52 +01:00
}
2007-03-02 18:56:07 +01:00
2019-04-09 10:46:37 +02:00
// Show tabs.
2019-01-30 16:18:44 +01:00
$img_style = [
'class' => 'top' ,
'width' => 16 ,
];
2007-03-12 18:58:52 +01:00
2009-04-13 17:05:21 +02:00
if ( $id_agente ) {
2019-04-09 10:46:37 +02:00
// View tab.
2019-01-30 16:18:44 +01:00
$viewtab [ 'text' ] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente . '">' . html_print_image ( 'images/operation.png' , true , [ 'title' => __ ( 'View' )]) . '</a>' ;
if ( $tab == 'view' ) {
$viewtab [ 'active' ] = true ;
} else {
$viewtab [ 'active' ] = false ;
}
$viewtab [ 'operation' ] = 1 ;
2019-04-09 10:46:37 +02:00
// Main tab.
2019-01-30 16:18:44 +01:00
$maintab [ 'text' ] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=' . $id_agente . '">' . html_print_image ( 'images/gm_setup.png' , true , [ 'title' => __ ( 'Setup' )]) . '</a>' ;
if ( $tab == 'main' ) {
$maintab [ 'active' ] = true ;
} else {
$maintab [ 'active' ] = false ;
}
2019-04-09 10:46:37 +02:00
// Module tab.
2019-01-30 16:18:44 +01:00
$moduletab [ 'text' ] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente=' . $id_agente . '">' . html_print_image ( 'images/gm_modules.png' , true , [ 'title' => __ ( 'Modules' )]) . '</a>' ;
if ( $tab == 'module' ) {
$moduletab [ 'active' ] = true ;
} else {
$moduletab [ 'active' ] = false ;
}
2019-04-09 10:46:37 +02:00
// Alert tab.
2019-01-30 16:18:44 +01:00
$alerttab [ 'text' ] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=' . $id_agente . '">' . html_print_image ( 'images/gm_alerts.png' , true , [ 'title' => __ ( 'Alerts' )]) . '</a>' ;
if ( $tab == 'alert' ) {
$alerttab [ 'active' ] = true ;
} else {
$alerttab [ 'active' ] = false ;
}
2019-04-09 10:46:37 +02:00
// Template tab.
2019-01-30 16:18:44 +01:00
$templatetab [ 'text' ] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente=' . $id_agente . '">' . html_print_image ( 'images/templates.png' , true , [ 'title' => __ ( 'Module templates' )]) . '</a>' ;
if ( $tab == 'template' ) {
$templatetab [ 'active' ] = true ;
} else {
$templatetab [ 'active' ] = false ;
}
2019-04-09 10:46:37 +02:00
// Inventory.
2019-01-30 16:18:44 +01:00
$inventorytab = enterprise_hook ( 'inventory_tab' );
if ( $inventorytab == - 1 ) {
$inventorytab = '' ;
}
$has_remote_conf = enterprise_hook (
'config_agents_has_remote_configuration' ,
[ $id_agente ]
);
if ( $has_remote_conf === ENTERPRISE_NOT_HOOK ) {
$has_remote_conf = false ;
}
if ( $has_remote_conf === true ) {
2019-04-09 10:46:37 +02:00
// Plugins.
2019-01-30 16:18:44 +01:00
$pluginstab = enterprise_hook ( 'plugins_tab' );
if ( $pluginstab == - 1 ) {
$pluginstab = '' ;
}
} else {
$pluginstab = '' ;
}
2019-04-09 10:46:37 +02:00
// Collection.
2019-01-30 16:18:44 +01:00
$collectiontab = enterprise_hook ( 'collection_tab' );
if ( $collectiontab == - 1 ) {
$collectiontab = '' ;
}
2019-04-09 10:46:37 +02:00
// Group tab.
2019-01-30 16:18:44 +01:00
$grouptab [ 'text' ] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group=' . $group . '">' . html_print_image ( 'images/group.png' , true , [ 'title' => __ ( 'Group' )]) . '</a>' ;
$grouptab [ 'active' ] = false ;
$gistab = [];
2019-04-09 10:46:37 +02:00
// GIS tab.
2019-01-30 16:18:44 +01:00
if ( $config [ 'activate_gis' ]) {
$gistab [ 'text' ] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente=' . $id_agente . '">' . html_print_image ( 'images/gm_gis.png' , true , [ 'title' => __ ( 'GIS data' )]) . '</a>' ;
if ( $tab == 'gis' ) {
$gistab [ 'active' ] = true ;
} else {
$gistab [ 'active' ] = false ;
}
}
2019-04-09 10:46:37 +02:00
// Agent wizard tab.
2019-01-30 16:18:44 +01:00
$agent_wizard [ 'text' ] = '<a href="javascript:" class="agent_wizard_tab">' . html_print_image ( 'images/wand_agent.png' , true , [ 'title' => __ ( 'Agent wizard' )]) . '</a>' ;
2019-04-09 10:46:37 +02:00
// Hidden subtab layer.
2019-01-30 16:18:44 +01:00
$agent_wizard [ 'sub_menu' ] = '<ul class="mn subsubmenu" style="display:none; float:none;">' ;
$agent_wizard [ 'sub_menu' ] .= '<li class="nomn tab_godmode" style="text-align: center;">' ;
$agent_wizard [ 'sub_menu' ] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_explorer&id_agente=' . $id_agente . '">' . html_print_image ( 'images/wand_snmp.png' , true , [ 'title' => __ ( 'SNMP Wizard' )]) . '</a>' ;
$agent_wizard [ 'sub_menu' ] .= '</li>' ;
$agent_wizard [ 'sub_menu' ] .= '<li class="nomn tab_godmode" style="text-align: center;">' ;
$agent_wizard [ 'sub_menu' ] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_interfaces_explorer&id_agente=' . $id_agente . '">' . html_print_image ( 'images/wand_interfaces.png' , true , [ 'title' => __ ( 'SNMP Interfaces wizard' )]) . '</a>' ;
$agent_wizard [ 'sub_menu' ] .= '</li>' ;
$agent_wizard [ 'sub_menu' ] .= '<li class="nomn tab_godmode" style="text-align: center;">' ;
$agent_wizard [ 'sub_menu' ] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=wmi_explorer&id_agente=' . $id_agente . '">' . html_print_image ( 'images/wand_wmi.png' , true , [ 'title' => __ ( 'WMI Wizard' )]) . '</a>' ;
$agent_wizard [ 'sub_menu' ] .= '</li>' ;
$agent_wizard [ 'sub_menu' ] .= '</ul>' ;
if ( $tab == 'agent_wizard' ) {
$agent_wizard [ 'active' ] = true ;
} else {
$agent_wizard [ 'active' ] = false ;
}
$total_incidents = agents_get_count_incidents ( $id_agente );
2019-04-09 10:46:37 +02:00
// Incident tab.
2019-01-30 16:18:44 +01:00
if ( $total_incidents > 0 ) {
$incidenttab [ 'text' ] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente=' . $id_agente . '">' . html_print_image ( 'images/book_edit.png' , true , [ 'title' => __ ( 'Incidents' )]) . '</a>' ;
if ( $tab == 'incident' ) {
$incidenttab [ 'active' ] = true ;
} else {
$incidenttab [ 'active' ] = false ;
}
}
if ( check_acl_one_of_groups ( $config [ 'id_user' ], $all_groups , 'AW' )) {
if ( $has_remote_conf ) {
$agent_name = agents_get_name ( $id_agente );
$agent_name = io_safe_output ( $agent_name );
$agent_md5 = md5 ( $agent_name , false );
$remote_configuration_tab [ 'text' ] = '<a href="index.php?' . 'sec=gagente&' . 'sec2=godmode/agentes/configurar_agente&' . 'tab=remote_configuration&' . 'id_agente=' . $id_agente . '&' . 'disk_conf=' . $agent_md5 . '">' . html_print_image (
'images/remote_configuration.png' ,
true ,
[ 'title' => __ ( 'Remote configuration' )]
) . '</a>' ;
if ( $tab == 'remote_configuration' ) {
$remote_configuration_tab [ 'active' ] = true ;
} else {
$remote_configuration_tab [ 'active' ] = false ;
}
$onheader = [
'view' => $viewtab ,
'separator' => '' ,
'main' => $maintab ,
'remote_configuration' => $remote_configuration_tab ,
'module' => $moduletab ,
'alert' => $alerttab ,
'template' => $templatetab ,
'inventory' => $inventorytab ,
'pluginstab' => $pluginstab ,
'collection' => $collectiontab ,
'group' => $grouptab ,
'gis' => $gistab ,
'agent_wizard' => $agent_wizard ,
];
} else {
$onheader = [
'view' => $viewtab ,
'separator' => '' ,
'main' => $maintab ,
'module' => $moduletab ,
'alert' => $alerttab ,
'template' => $templatetab ,
'inventory' => $inventorytab ,
'pluginstab' => $pluginstab ,
'collection' => $collectiontab ,
'group' => $grouptab ,
'gis' => $gistab ,
'agent_wizard' => $agent_wizard ,
];
}
2019-04-09 10:46:37 +02:00
// Only if the agent has incidents associated show incidents tab.
2019-01-30 16:18:44 +01:00
if ( $total_incidents ) {
$onheader [ 'incident' ] = $incidenttab ;
}
} else {
$onheader = [
'view' => $viewtab ,
'separator' => '' ,
'module' => $moduletab ,
'alert' => $alerttab ,
];
}
2019-04-09 10:46:37 +02:00
// Extensions tabs.
2019-01-30 16:18:44 +01:00
foreach ( $config [ 'extensions' ] as $extension ) {
if ( isset ( $extension [ 'extension_god_tab' ])) {
if ( check_acl ( $config [ 'id_user' ], $group , $extension [ 'extension_god_tab' ][ 'acl' ])) {
$image = $extension [ 'extension_god_tab' ][ 'icon' ];
$name = $extension [ 'extension_god_tab' ][ 'name' ];
$id = $extension [ 'extension_god_tab' ][ 'id' ];
$id_extension = get_parameter ( 'id_extension' , '' );
if ( $id_extension == $id ) {
$active = true ;
} else {
$active = false ;
}
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=extension&id_agente=' . $id_agente . '&id_extension=' . $id ;
$extension_tab = [
'text' => '<a href="' . $url . '">' . html_print_image ( $image , true , [ 'title' => $name ]) . '</a>' ,
'active' => $active ,
];
$onheader = ( $onheader + [ $id => $extension_tab ]);
}
}
}
$help_header = '' ;
2019-04-24 13:53:18 +02:00
// This add information to the header.
2019-01-30 16:18:44 +01:00
switch ( $tab ) {
case 'main' :
$tab_description = '- ' . __ ( 'Setup' );
2019-04-24 13:53:18 +02:00
$help_header = 'main_tab' ;
2019-01-30 16:18:44 +01:00
break ;
case 'collection' :
$tab_description = '- ' . __ ( 'Collection' );
break ;
case 'inventory' :
$tab_description = '- ' . __ ( 'Inventory' );
$help_header = 'inventory_tab' ;
break ;
case 'plugins' :
$tab_description = '- ' . __ ( 'Agent plugins' );
$help_header = 'plugins_tab' ;
break ;
case 'module' :
$type_module_t = get_parameter ( 'moduletype' , '' );
$tab_description = '- ' . __ ( 'Modules' );
if ( $type_module_t == 'webux' ) {
$help_header = 'wux_console' ;
2019-04-30 12:28:11 +02:00
} else {
$help_header = 'local_module_tab' ;
2019-01-30 16:18:44 +01:00
}
break ;
case 'alert' :
$tab_description = '- ' . __ ( 'Alert' );
$help_header = 'manage_alert_list' ;
break ;
case 'template' :
$tab_description = '- ' . __ ( 'Templates' );
break ;
case 'gis' :
$tab_description = '- ' . __ ( 'Gis' );
$help_header = 'gis_tab' ;
break ;
case 'incident' :
$tab_description = '- ' . __ ( 'Incidents' );
break ;
case 'remote_configuration' :
$tab_description = '- ' . __ ( 'Remote configuration' );
break ;
case 'agent_wizard' :
switch ( get_parameter ( 'wizard_section' )) {
case 'snmp_explorer' :
$tab_description = '- ' . __ ( 'SNMP Wizard' );
2019-04-29 14:36:02 +02:00
$help_header = 'agent_snmp_explorer_tab' ;
2019-01-30 16:18:44 +01:00
break ;
case 'snmp_interfaces_explorer' :
$tab_description = '- ' . __ ( 'SNMP Interfaces wizard' );
2019-04-29 14:36:02 +02:00
$help_header = 'agent_snmp_interfaces_explorer_tab' ;
2019-01-30 16:18:44 +01:00
break ;
case 'wmi_explorer' :
$tab_description = '- ' . __ ( 'WMI Wizard' );
2019-04-29 14:36:02 +02:00
$help_header = 'agent_snmp_wmi_explorer_tab' ;
2019-01-30 16:18:44 +01:00
break ;
2019-04-09 10:46:37 +02:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
case 'extension' :
$id_extension = get_parameter ( 'id_extension' , '' );
switch ( $id_extension ) {
case 'snmp_explorer' :
$tab_description = '- ' . __ ( 'SNMP explorer' );
$help_header = 'snmp_explorer' ;
break ;
2019-04-09 10:46:37 +02:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
break ;
default :
2019-05-07 11:34:09 +02:00
// Default.
2019-01-30 16:18:44 +01:00
break ;
}
ui_print_page_header (
agents_get_alias ( $id_agente ),
'images/setup.png' ,
false ,
$help_header ,
true ,
$onheader ,
false ,
'' ,
$config [ 'item_title_size_text' ]
);
} else {
2019-04-09 10:46:37 +02:00
// Create agent.
2019-01-30 16:18:44 +01:00
ui_print_page_header (
__ ( 'Agent manager' ),
'images/bricks.png' ,
false ,
'create_agent' ,
true
);
2010-03-04 17:22:25 +01:00
}
2007-03-02 18:56:07 +01:00
2009-09-25 18:21:20 +02:00
$delete_conf_file = ( bool ) get_parameter ( 'delete_conf_file' );
if ( $delete_conf_file ) {
2019-01-30 16:18:44 +01:00
$correct = false ;
2019-04-09 10:46:37 +02:00
// Delete remote configuration.
2019-01-30 16:18:44 +01:00
if ( isset ( $config [ 'remote_config' ])) {
$agent_md5 = md5 ( io_safe_output ( agents_get_name ( $id_agente , 'none' )), false );
if ( file_exists ( $config [ 'remote_config' ] . '/md5/' . $agent_md5 . '.md5' )) {
2019-04-09 10:46:37 +02:00
// Agent remote configuration editor.
2019-01-30 16:18:44 +01:00
$file_name = $config [ 'remote_config' ] . '/conf/' . $agent_md5 . '.conf' ;
$correct = @ unlink ( $file_name );
$file_name = $config [ 'remote_config' ] . '/md5/' . $agent_md5 . '.md5' ;
$correct = @ unlink ( $file_name );
}
}
ui_print_result_message (
$correct ,
__ ( 'Conf file deleted successfully' ),
__ ( 'Could not delete conf file' )
);
2009-09-25 18:21:20 +02:00
}
2019-04-09 10:46:37 +02:00
// Show agent creation results.
2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php: Agent module editions
rewritten. The interface should be clearer now and SNMP walking much
more faster, since it's done with AJAX. Some cleanup might be needed
yet.
* godmode/agentes/module_manager_editor_common.php: Added to
repository. Common part for agent module editors.
* images/edit.png, images/spinner.gif: Added to repository.
* include/javascript/jquery.form.js: Added to repository. jQuery form
plugin.
* include/javascript/jquery.pandora.js: Added to repository. Special
Pandora addons for jQuery library.
* include/javascript/pandora.js: Added an extension to Array
javascript objects to check if an array has an element.
* include/styles/pandora.css: Added styling for new module editors.
* include/functions_db.php: Added get_moduletype_description().
* index.php: Added Pandora jQuery extensions.
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text
useless field from talert_templates.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-02-02 16:40:31 +01:00
if ( $create_agent ) {
2019-01-30 16:18:44 +01:00
if ( ! isset ( $agent_creation_error )) {
$agent_creation_error = __ ( 'Could not be created' );
}
ui_print_result_message (
$agent_created_ok ,
__ ( 'Successfully created' ),
$agent_creation_error
);
if ( $mssg_warning ) {
ui_print_warning_message ( __ ( 'The ip or dns name entered cannot be resolved' ));
}
2007-03-12 18:58:52 +01:00
}
2019-04-09 10:46:37 +02:00
// Fix / Normalize module data.
2019-01-30 16:18:44 +01:00
if ( isset ( $_GET [ 'fix_module' ])) {
$id_module = get_parameter_get ( 'fix_module' , 0 );
2019-04-09 10:46:37 +02:00
// Get info about this module.
2019-01-30 16:18:44 +01:00
$media = reporting_get_agentmodule_data_average ( $id_module , 30758400 );
2019-04-09 10:46:37 +02:00
// Get average over the year.
2019-01-30 16:18:44 +01:00
$media *= 1.3 ;
$error = '' ;
$result = true ;
2019-04-09 10:46:37 +02:00
// If the value of media is 0 or something went wrong, don't delete.
2019-01-30 16:18:44 +01:00
if ( ! empty ( $media )) {
$where = [
'datos' => '>' . $media ,
'id_agente_modulo' => $id_module ,
];
$res = db_process_sql_delete ( 'tagente_datos' , $where );
if ( $res === false ) {
$result = false ;
$error = modules_get_agentmodule_name ( $id_module );
} else if ( $res <= 0 ) {
$result = false ;
$error = ' - ' . __ ( 'No data to normalize' );
}
} else {
$result = false ;
$error = ' - ' . __ ( 'No data to normalize' );
}
ui_print_result_message (
$result ,
__ ( 'Deleted data above %f' , $media ),
__ ( 'Error normalizing module %s' , $error )
);
2007-04-21 18:14:11 +02:00
}
2019-01-30 16:18:44 +01:00
$update_agent = ( bool ) get_parameter ( 'update_agent' );
2010-08-25 14:04:42 +02:00
2019-04-09 10:46:37 +02:00
// Update AGENT.
2019-01-30 16:18:44 +01:00
if ( $update_agent ) {
2019-04-09 10:46:37 +02:00
// If modified some agent paramenter.
2019-01-30 16:18:44 +01:00
$mssg_warning = 0 ;
$id_agente = ( int ) get_parameter_post ( 'id_agente' );
$nombre_agente = str_replace ( '`' , '‘' , ( string ) get_parameter_post ( 'agente' , '' ));
2019-02-22 12:30:27 +01:00
$alias_safe_output = io_safe_output ( get_parameter ( 'alias' , '' ));
2019-04-01 15:18:56 +02:00
$alias = io_safe_input ( trim ( preg_replace ( '/[\/\\\|%#&$]/' , '' , $alias_safe_output )));
2019-01-30 16:18:44 +01:00
$alias_as_name = ( int ) get_parameter_post ( 'alias_as_name' , 0 );
$direccion_agente = ( string ) get_parameter_post ( 'direccion' , '' );
2019-02-06 18:06:49 +01:00
$unique_ip = ( int ) get_parameter_post ( 'unique_ip' , 0 );
2019-04-09 10:46:37 +02:00
// Safe_output only validate ip.
2019-01-30 16:18:44 +01:00
$direccion_agente = trim ( io_safe_output ( $direccion_agente ));
if ( ! validate_address ( $direccion_agente )) {
$mssg_warning = 1 ;
}
2019-04-09 10:46:37 +02:00
// Safe-input before validate ip.
2019-01-30 16:18:44 +01:00
$direccion_agente = io_safe_input ( $direccion_agente );
$address_list = ( string ) get_parameter_post ( 'address_list' , '' );
if ( $address_list != $direccion_agente
&& $direccion_agente == agents_get_address ( $id_agente )
&& $address_list != agents_get_address ( $id_agente )
) {
2019-04-09 10:46:37 +02:00
/*
* If we selected another IP in the drop down list to be 'primary' :
* a ) field is not the same as selectbox
* b ) field has not changed from current IP
* c ) selectbox is not the current IP .
*/
2019-01-30 16:18:44 +01:00
if ( ! empty ( $address_list )) {
$direccion_agente = $address_list ;
}
}
$grupo = ( int ) get_parameter_post ( 'grupo' , 0 );
$intervalo = ( int ) get_parameter_post ( 'intervalo' , SECONDS_5MINUTES );
$comentarios = str_replace ( '`' , '‘' , ( string ) get_parameter_post ( 'comentarios' , '' ));
$modo = ( int ) get_parameter_post ( 'modo' , 0 );
2019-04-09 10:46:37 +02:00
// Mode: Learning, Normal or Autodisabled.
2019-01-30 16:18:44 +01:00
$id_os = ( int ) get_parameter_post ( 'id_os' );
$disabled = ( bool ) get_parameter_post ( 'disabled' );
$server_name = ( string ) get_parameter_post ( 'server_name' , '' );
$id_parent = ( int ) get_parameter_post ( 'id_agent_parent' );
$custom_id = ( string ) get_parameter_post ( 'custom_id' , '' );
$cascade_protection = ( int ) get_parameter_post ( 'cascade_protection' , 0 );
$cascade_protection_module = ( int ) get_parameter ( 'cascade_protection_module' , 0 );
$safe_mode_module = ( int ) get_parameter ( 'safe_mode_module' , 0 );
$icon_path = ( string ) get_parameter_post ( 'icon_path' , '' );
$update_gis_data = ( int ) get_parameter_post ( 'update_gis_data' , 0 );
$url_description = ( string ) get_parameter ( 'url_description' );
$quiet = ( int ) get_parameter ( 'quiet' , 0 );
2019-05-27 14:12:53 +02:00
$cps = get_parameter_switch ( 'cps' , - 1 );
2019-01-30 16:18:44 +01:00
$old_values = db_get_row ( 'tagente' , 'id_agente' , $id_agente );
$fields = db_get_all_fields_in_table ( 'tagent_custom_fields' );
if ( $fields === false ) {
$fields = [];
}
$field_values = [];
foreach ( $fields as $field ) {
$field_values [ $field [ 'id_field' ]] = ( string ) get_parameter_post ( 'customvalue_' . $field [ 'id_field' ], '' );
}
foreach ( $field_values as $key => $value ) {
$old_value = db_get_all_rows_filter (
'tagent_custom_data' ,
[
'id_agent' => $id_agente ,
'id_field' => $key ,
]
);
if ( $old_value === false ) {
2019-04-09 10:46:37 +02:00
// Create custom field if not exist.
2019-01-30 16:18:44 +01:00
$update_custom = db_process_sql_insert (
'tagent_custom_data' ,
[
'id_field' => $key ,
'id_agent' => $id_agente ,
'description' => $value ,
]
);
} else {
$update_custom = db_process_sql_update (
'tagent_custom_data' ,
[ 'description' => $value ],
[
'id_field' => $key ,
'id_agent' => $id_agente ,
]
);
if ( $update_custom == 1 ) {
$update_custom_result = 1 ;
}
}
}
if ( $mssg_warning ) {
ui_print_warning_message ( __ ( 'The ip or dns name entered cannot be resolved' ));
}
2019-04-09 10:46:37 +02:00
// Verify if there is another agent with the same name but different ID.
2019-01-30 16:18:44 +01:00
if ( $alias == '' ) {
ui_print_error_message ( __ ( 'No agent alias specified' ));
2019-04-09 10:46:37 +02:00
// If there is an agent with the same name, but a different ID.
2019-01-30 16:18:44 +01:00
}
2019-02-06 18:06:49 +01:00
if ( $unique_ip && $direccion_agente != '' ) {
$sql = 'SELECT direccion FROM tagente WHERE direccion = "' . $direccion_agente . '"' ;
$exists_ip = db_get_row_sql ( $sql );
}
2019-01-30 16:18:44 +01:00
if ( $grupo <= 0 ) {
ui_print_error_message ( __ ( 'The group id %d is incorrect.' , $grupo ));
2019-02-06 18:06:49 +01:00
} else if ( $exists_ip ) {
ui_print_error_message ( __ ( 'Duplicate main IP address' ));
2019-01-30 16:18:44 +01:00
} else {
2019-04-09 10:46:37 +02:00
// If different IP is specified than previous, add the IP.
2019-01-30 16:18:44 +01:00
if ( $direccion_agente != ''
&& $direccion_agente != agents_get_address ( $id_agente )
) {
agents_add_address ( $id_agente , $direccion_agente );
}
$action_delete_ip = ( bool ) get_parameter ( 'delete_ip' , false );
2019-04-09 10:46:37 +02:00
// If IP is set for deletion, delete first.
2019-01-30 16:18:44 +01:00
if ( $action_delete_ip ) {
$delete_ip = get_parameter_post ( 'address_list' );
$direccion_agente = agents_delete_address ( $id_agente , $delete_ip );
}
$values = [
'disabled' => $disabled ,
'id_parent' => $id_parent ,
'id_os' => $id_os ,
'modo' => $modo ,
'alias' => $alias ,
'alias_as_name' => $alias_as_name ,
'direccion' => $direccion_agente ,
'id_grupo' => $grupo ,
'intervalo' => $intervalo ,
'comentarios' => $comentarios ,
'cascade_protection' => $cascade_protection ,
'cascade_protection_module' => $cascade_protection_module ,
'server_name' => $server_name ,
'custom_id' => $custom_id ,
'icon_path' => $icon_path ,
'update_gis_data' => $update_gis_data ,
'url_address' => $url_description ,
'url_address' => $url_description ,
'quiet' => $quiet ,
'cps' => $cps ,
'safe_mode_module' => $safe_mode_module ,
];
if ( $config [ 'metaconsole_agent_cache' ] == 1 ) {
$values [ 'update_module_count' ] = 1 ;
// Force an update of the agent cache.
}
$group_old = db_get_sql ( 'SELECT id_grupo FROM tagente WHERE id_agente =' . $id_agente );
$tpolicy_group_old = db_get_all_rows_sql (
' SELECT id_policy FROM tpolicy_groups
WHERE id_group = ' . $group_old
);
$result = db_process_sql_update ( 'tagente' , $values , [ 'id_agente' => $id_agente ]);
2019-02-06 20:12:17 +01:00
if ( $result === false && $update_custom_result == false ) {
2019-01-30 16:18:44 +01:00
ui_print_error_message (
__ ( 'There was a problem updating the agent' )
);
} else {
2019-04-09 10:46:37 +02:00
// Update the agent from the metaconsole cache.
2019-01-30 16:18:44 +01:00
enterprise_include_once ( 'include/functions_agents.php' );
enterprise_hook ( 'agent_update_from_cache' , [ $id_agente , $values , $server_name ]);
2019-04-09 10:46:37 +02:00
// Update the configuration files.
2019-01-30 16:18:44 +01:00
if ( $old_values [ 'intervalo' ] != $intervalo ) {
enterprise_hook (
'config_agents_update_config_token' ,
[
$id_agente ,
'interval' ,
$intervalo ,
]
);
}
if ( $old_values [ 'disabled' ] != $disabled ) {
enterprise_hook (
'config_agents_update_config_token' ,
[
$id_agente ,
'standby' ,
$disabled ? '1' : '0' ,
]
);
2019-02-12 14:52:18 +01:00
// Validate alerts for disabled agents.
if ( $disabled ) {
alerts_validate_alert_agent ( $id_agente );
}
2019-01-30 16:18:44 +01:00
}
if ( $tpolicy_group_old ) {
foreach ( $tpolicy_group_old as $key => $value ) {
$tpolicy_agents_old = db_get_sql (
' SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value[' id_policy '].' AND id_agent = ' . $id_agente
);
if ( $tpolicy_agents_old ) {
$result2 = db_process_sql_update (
'tpolicy_agents' ,
[ 'pending_delete' => 1 ],
[
'id_agent' => $id_agente ,
'id_policy' => $value [ 'id_policy' ],
]
);
}
}
}
$tpolicy_group = db_get_all_rows_sql (
' SELECT id_policy FROM tpolicy_groups
WHERE id_group = ' . $grupo
);
if ( $tpolicy_group ) {
foreach ( $tpolicy_group as $key => $value ) {
$tpolicy_agents = db_get_sql (
' SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value[' id_policy '].' AND id_agent = ' . $id_agente
);
if ( ! $tpolicy_agents ) {
db_process_sql_insert (
'tpolicy_agents' ,
[
'id_policy' => $value [ 'id_policy' ],
'id_agent' => $id_agente ,
]
);
} else {
$result3 = db_process_sql_update (
'tpolicy_agents' ,
[ 'pending_delete' => 0 ],
[
'id_agent' => $id_agente ,
'id_policy' => $value [ 'id_policy' ],
]
);
}
}
}
$info = ' {
" id_agente " : " '. $id_agente .' " ,
" alias " : " '. $alias .' " ,
" Group " : " '. $grupo .' " ,
" Interval " : " '. $intervalo .' " ,
" Comments " : " '. $comentarios .' " ,
" Mode " : " '. $modo .' " ,
" ID OS " : " '. $id_os .' " ,
" Disabled " : " '. $disabled .' " ,
" Server Name " : " '. $server_name .' " ,
" ID parent " : " '. $id_parent .' " ,
" Custom ID " : " '. $custom_id .' " ,
" Cascade Protection " : " '. $cascade_protection .' " ,
" Cascade protection module " : " '. $cascade_protection_module .' " ,
" Icon Path " : " '. $icon_path .' " ,
" Update GIS data " : " '. $update_gis_data .' " ,
" Url description " : " '. $url_description .' " ,
" Quiet " : " '.(int) $quiet .' " ,
" Cps " : " '.(int) $cps .' " } ' ;
enterprise_hook ( 'update_agent' , [ $id_agente ]);
ui_print_success_message ( __ ( 'Successfully updated' ));
db_pandora_audit (
'Agent management' ,
" Updated agent $alias " ,
false ,
false ,
$info
);
}
}
2007-02-27 20:03:56 +01:00
}
2006-03-27 05:37:27 +02:00
2007-02-27 20:03:56 +01:00
// Read agent data
2019-04-09 10:46:37 +02:00
// This should be at the end of all operation checks, to read the changes - $id_agente doesn't have to be retrieved.
2009-04-13 17:05:21 +02:00
if ( $id_agente ) {
2019-04-09 10:46:37 +02:00
// This has been done in the beginning of the page, but if an agent was created, this id might change.
2019-01-30 16:18:44 +01:00
$id_grupo = agents_get_agent_group ( $id_agente );
if ( ! check_acl_one_of_groups ( $config [ 'id_user' ], $all_groups , 'AW' ) && ! check_acl_one_of_groups ( $config [ 'id_user' ], $all_groups , 'AD' )) {
db_pandora_audit ( 'ACL Violation' , 'Trying to admin an agent without access' );
include 'general/noaccess.php' ;
exit ;
}
2019-03-06 11:25:47 +01:00
$agent = db_get_row ( 'tagente' , 'id_agente' , $id_agente , false , false );
2019-01-30 16:18:44 +01:00
if ( empty ( $agent )) {
2019-04-09 10:46:37 +02:00
// Close out the page.
2019-01-30 16:18:44 +01:00
ui_print_error_message ( __ ( 'There was a problem loading the agent' ));
return ;
}
$intervalo = $agent [ 'intervalo' ];
2019-04-09 10:46:37 +02:00
// Define interval in seconds.
2019-01-30 16:18:44 +01:00
$nombre_agente = $agent [ 'nombre' ];
if ( empty ( $alias )) {
$alias = $agent [ 'alias' ];
if ( empty ( $alias )) {
$alias = $nombre_agente ;
}
}
$alias_as_name = $agent [ 'alias_as_name' ];
$direccion_agente = $agent [ 'direccion' ];
$grupo = $agent [ 'id_grupo' ];
$ultima_act = $agent [ 'ultimo_contacto' ];
$comentarios = $agent [ 'comentarios' ];
$server_name = $agent [ 'server_name' ];
$modo = $agent [ 'modo' ];
$id_os = $agent [ 'id_os' ];
$disabled = $agent [ 'disabled' ];
$id_parent = $agent [ 'id_parent' ];
$custom_id = $agent [ 'custom_id' ];
$cascade_protection = $agent [ 'cascade_protection' ];
$cascade_protection_module = $agent [ 'cascade_protection_module' ];
$icon_path = $agent [ 'icon_path' ];
$update_gis_data = $agent [ 'update_gis_data' ];
$url_description = $agent [ 'url_address' ];
$quiet = $agent [ 'quiet' ];
$cps = $agent [ 'cps' ];
$safe_mode_module = $agent [ 'safe_mode_module' ];
$safe_mode = ( $safe_mode_module ) ? 1 : 0 ;
2007-02-27 20:03:56 +01:00
}
2019-01-30 16:18:44 +01:00
$update_module = ( bool ) get_parameter ( 'update_module' );
$create_module = ( bool ) get_parameter ( 'create_module' );
$delete_module = ( bool ) get_parameter ( 'delete_module' );
$enable_module = ( int ) get_parameter ( 'enable_module' );
$disable_module = ( int ) get_parameter ( 'disable_module' );
2019-04-09 10:46:37 +02:00
// It is the id_agent_module to duplicate.
2019-01-30 16:18:44 +01:00
$duplicate_module = ( int ) get_parameter ( 'duplicate_module' );
$edit_module = ( bool ) get_parameter ( 'edit_module' );
2008-09-29 17:36:03 +02:00
2019-04-09 10:46:37 +02:00
// GET DATA for MODULE UPDATE OR MODULE INSERT.
2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php: Agent module editions
rewritten. The interface should be clearer now and SNMP walking much
more faster, since it's done with AJAX. Some cleanup might be needed
yet.
* godmode/agentes/module_manager_editor_common.php: Added to
repository. Common part for agent module editors.
* images/edit.png, images/spinner.gif: Added to repository.
* include/javascript/jquery.form.js: Added to repository. jQuery form
plugin.
* include/javascript/jquery.pandora.js: Added to repository. Special
Pandora addons for jQuery library.
* include/javascript/pandora.js: Added an extension to Array
javascript objects to check if an array has an element.
* include/styles/pandora.css: Added styling for new module editors.
* include/functions_db.php: Added get_moduletype_description().
* index.php: Added Pandora jQuery extensions.
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text
useless field from talert_templates.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-02-02 16:40:31 +01:00
if ( $update_module || $create_module ) {
2019-01-30 16:18:44 +01:00
$id_grupo = agents_get_agent_group ( $id_agente );
$all_groups = agents_get_all_groups_agent ( $id_agente , $id_grupo );
if ( ! check_acl_one_of_groups ( $config [ 'id_user' ], $all_groups , 'AW' )) {
db_pandora_audit (
'ACL Violation' ,
'Trying to create a module without admin rights'
);
include 'general/noaccess.php' ;
exit ;
}
$id_agent_module = ( int ) get_parameter ( 'id_agent_module' );
$id_module_type = ( int ) get_parameter ( 'id_module_type' );
$name = ( string ) get_parameter ( 'name' );
$description = ( string ) get_parameter ( 'description' );
$id_module_group = ( int ) get_parameter ( 'id_module_group' );
$flag = ( bool ) get_parameter ( 'flag' );
2019-04-09 10:46:37 +02:00
/*
* Don 't read as (float) because it lost it' s decimals when put into MySQL
* where are very big and PHP uses scientific notation , p . e :
* 1.23E-10 is 0.000000000123 .
*/
2019-01-30 16:18:44 +01:00
$post_process = ( string ) get_parameter ( 'post_process' , 0.0 );
if ( get_parameter ( 'prediction_module' )) {
$prediction_module = 1 ;
} else {
$prediction_module = 0 ;
}
$max_timeout = ( int ) get_parameter ( 'max_timeout' );
$max_retries = ( int ) get_parameter ( 'max_retries' );
$min = ( int ) get_parameter_post ( 'min' );
$max = ( int ) get_parameter ( 'max' );
$interval = ( int ) get_parameter ( 'module_interval' , $intervalo );
$ff_interval = ( int ) get_parameter ( 'module_ff_interval' );
$quiet_module = ( int ) get_parameter ( 'quiet_module' );
$cps_module = ( int ) get_parameter ( 'cps_module' );
$id_plugin = ( int ) get_parameter ( 'id_plugin' );
$id_export = ( int ) get_parameter ( 'id_export' );
$disabled = ( bool ) get_parameter ( 'disabled' );
$tcp_send = ( string ) get_parameter ( 'tcp_send' );
$tcp_rcv = ( string ) get_parameter ( 'tcp_rcv' );
$tcp_port = ( int ) get_parameter ( 'tcp_port' );
2019-04-09 10:46:37 +02:00
// Correction in order to not insert 0 as port.
2019-01-30 16:18:44 +01:00
$is_port_empty = get_parameter ( 'tcp_port' , '' );
if ( $is_port_empty === '' ) {
$tcp_port = null ;
}
$configuration_data = ( string ) get_parameter ( 'configuration_data' );
$old_configuration_data = ( string ) get_parameter ( 'old_configuration_data' );
$new_configuration_data = '' ;
$custom_string_1_default = '' ;
$custom_string_2_default = '' ;
$custom_string_3_default = '' ;
$custom_integer_1_default = 0 ;
$custom_integer_2_default = 0 ;
if ( $update_module ) {
$module = modules_get_agentmodule ( $id_agent_module );
$custom_string_1_default = $module [ 'custom_string_1' ];
$custom_string_2_default = $module [ 'custom_string_2' ];
$custom_string_3_default = $module [ 'custom_string_3' ];
$custom_integer_1_default = $module [ 'custom_integer_1' ];
$custom_integer_2_default = $module [ 'custom_integer_2' ];
}
if ( $id_module_type == 25 ) {
2019-04-09 10:46:37 +02:00
// web analysis, from MODULE_WUX.
2019-01-30 16:18:44 +01:00
$custom_string_1 = base64_encode (( string ) get_parameter ( 'custom_string_1' , $custom_string_1_default ));
$custom_integer_1 = ( int ) get_parameter ( 'custom_integer_1' , $custom_integer_1_default );
} else {
$custom_string_1 = ( string ) get_parameter ( 'custom_string_1' , $custom_string_1_default );
$custom_integer_1 = ( int ) get_parameter ( 'prediction_module' , $custom_integer_1_default );
}
$custom_string_2 = ( string ) get_parameter ( 'custom_string_2' , $custom_string_2_default );
$custom_string_3 = ( string ) get_parameter ( 'custom_string_3' , $custom_string_3_default );
$custom_integer_2 = ( int ) get_parameter ( 'custom_integer_2' , 0 );
2019-04-09 10:46:37 +02:00
// Get macros.
2019-01-30 16:18:44 +01:00
$macros = ( string ) get_parameter ( 'macros' );
2019-05-22 19:14:01 +02:00
$macros_names = ( array ) get_parameter ( 'macro_name' , []);
2019-01-30 16:18:44 +01:00
if ( ! empty ( $macros )) {
$macros = json_decode ( base64_decode ( $macros ), true );
foreach ( $macros as $k => $m ) {
$m_hide = '0' ;
if ( isset ( $m [ 'hide' ])) {
$m_hide = $m [ 'hide' ];
}
2019-05-22 19:14:01 +02:00
if ( $update_module ) {
if ( $m_hide == '1' ) {
$macros [ $k ][ 'value' ] = io_input_password ( get_parameter ( $m [ 'macro' ], '' ));
} else {
$macros [ $k ][ 'value' ] = get_parameter ( $m [ 'macro' ], '' );
}
2019-01-30 16:18:44 +01:00
} else {
2019-05-22 19:14:01 +02:00
if ( $m_hide == '1' ) {
$macros [ $k ][ 'value' ] = io_input_password ( $macros_names [ $k ]);
} else {
$macros [ $k ][ 'value' ] = $macros_names [ $k ];
}
2019-01-30 16:18:44 +01:00
}
}
$macros = io_json_mb_encode ( $macros );
$conf_array = explode ( " \n " , io_safe_output ( $configuration_data ));
foreach ( $conf_array as $line ) {
if ( preg_match ( '/^module_name\s*(.*)/' , $line , $match )) {
$new_configuration_data .= 'module_name ' . io_safe_output ( $name ) . " \n " ;
}
2019-04-09 10:46:37 +02:00
// We delete from conf all the module macros starting with _field.
2019-01-30 16:18:44 +01:00
else if ( ! preg_match ( '/^module_macro_field.*/' , $line , $match )) {
$new_configuration_data .= " $line\n " ;
}
}
$values_macros = [];
$values_macros [ 'macros' ] = base64_encode ( $macros );
$macros_for_data = enterprise_hook (
'config_agents_get_macros_data_conf' ,
[ $values_macros ]
);
if ( $macros_for_data != '' ) {
$new_configuration_data = str_replace ( 'module_end' , $macros_for_data . 'module_end' , $new_configuration_data );
}
$configuration_data = str_replace (
'\\' ,
'\' ,
io_safe_input ( $new_configuration_data )
);
}
// Services are an enterprise feature,
// so we got the parameters using this function.
enterprise_hook ( 'get_service_synthetic_parameters' );
$agent_name = ( string ) get_parameter (
'agent_name' ,
agents_get_name ( $id_agente )
);
$snmp_community = ( string ) get_parameter ( 'snmp_community' );
$snmp_oid = ( string ) get_parameter ( 'snmp_oid' );
2019-04-09 10:46:37 +02:00
// Change double quotes by single.
2019-01-30 16:18:44 +01:00
$snmp_oid = preg_replace ( '/"/' , ''' , $snmp_oid );
if ( empty ( $snmp_oid )) {
2019-04-09 10:46:37 +02:00
// The user did not set any OID manually but did a SNMP walk.
2019-01-30 16:18:44 +01:00
$snmp_oid = ( string ) get_parameter ( 'select_snmp_oid' );
}
if ( $id_module_type >= 15 && $id_module_type <= 18 ) {
2019-04-09 10:46:37 +02:00
// New support for snmp v3.
2019-01-30 16:18:44 +01:00
$tcp_send = ( string ) get_parameter ( 'snmp_version' );
$plugin_user = ( string ) get_parameter ( 'snmp3_auth_user' );
$plugin_pass = io_input_password (( string ) get_parameter ( 'snmp3_auth_pass' ));
$plugin_parameter = ( string ) get_parameter ( 'snmp3_auth_method' );
$custom_string_1 = ( string ) get_parameter ( 'snmp3_privacy_method' );
$custom_string_2 = io_input_password (( string ) get_parameter ( 'snmp3_privacy_pass' ));
$custom_string_3 = ( string ) get_parameter ( 'snmp3_security_level' );
} else {
$plugin_user = ( string ) get_parameter ( 'plugin_user' );
if ( get_parameter ( 'id_module_component_type' ) == 7 ) {
$plugin_pass = ( int ) get_parameter ( 'plugin_pass' );
} else {
$plugin_pass = io_input_password (( string ) get_parameter ( 'plugin_pass' ));
}
$plugin_parameter = ( string ) get_parameter ( 'plugin_parameter' );
}
$parent_module_id = ( int ) get_parameter ( 'parent_module_id' );
$ip_target = ( string ) get_parameter ( 'ip_target' );
if ( $ip_target == '' ) {
$ip_target = 'auto' ;
}
$custom_id = ( string ) get_parameter ( 'custom_id' );
$history_data = ( int ) get_parameter ( 'history_data' );
$dynamic_interval = ( int ) get_parameter ( 'dynamic_interval' );
$dynamic_max = ( int ) get_parameter ( 'dynamic_max' );
$dynamic_min = ( int ) get_parameter ( 'dynamic_min' );
$dynamic_two_tailed = ( int ) get_parameter ( 'dynamic_two_tailed' );
$min_warning = ( float ) get_parameter ( 'min_warning' );
$max_warning = ( float ) get_parameter ( 'max_warning' );
$str_warning = ( string ) get_parameter ( 'str_warning' );
$min_critical = ( float ) get_parameter ( 'min_critical' );
$max_critical = ( float ) get_parameter ( 'max_critical' );
$str_critical = ( string ) get_parameter ( 'str_critical' );
$ff_event = ( int ) get_parameter ( 'ff_event' );
$ff_event_normal = ( int ) get_parameter ( 'ff_event_normal' );
$ff_event_warning = ( int ) get_parameter ( 'ff_event_warning' );
$ff_event_critical = ( int ) get_parameter ( 'ff_event_critical' );
2019-03-27 18:16:53 +01:00
$ff_type = ( int ) get_parameter ( 'ff_type' );
2019-01-30 16:18:44 +01:00
$each_ff = ( int ) get_parameter ( 'each_ff' );
$ff_timeout = ( int ) get_parameter ( 'ff_timeout' );
$unit = ( string ) get_parameter ( 'unit_select' );
if ( $unit == 'none' ) {
$unit = ( string ) get_parameter ( 'unit_text' );
}
$id_tag = ( array ) get_parameter ( 'id_tag_selected' );
$serialize_ops = ( string ) get_parameter ( 'serialize_ops' );
$critical_instructions = ( string ) get_parameter ( 'critical_instructions' );
$warning_instructions = ( string ) get_parameter ( 'warning_instructions' );
$unknown_instructions = ( string ) get_parameter ( 'unknown_instructions' );
$critical_inverse = ( int ) get_parameter ( 'critical_inverse' );
$warning_inverse = ( int ) get_parameter ( 'warning_inverse' );
$id_category = ( int ) get_parameter ( 'id_category' );
$hour_from = get_parameter ( 'hour_from' );
$minute_from = get_parameter ( 'minute_from' );
$mday_from = get_parameter ( 'mday_from' );
$month_from = get_parameter ( 'month_from' );
$wday_from = get_parameter ( 'wday_from' );
$hour_to = get_parameter ( 'hour_to' );
$minute_to = get_parameter ( 'minute_to' );
$mday_to = get_parameter ( 'mday_to' );
$month_to = get_parameter ( 'month_to' );
$wday_to = get_parameter ( 'wday_to' );
$http_user = get_parameter ( 'http_user' );
$http_pass = get_parameter ( 'http_pass' );
if ( $hour_to != '*' ) {
$hour_to = '-' . $hour_to ;
} else {
$hour_to = '' ;
}
if ( $minute_to != '*' ) {
$minute_to = '-' . $minute_to ;
} else {
$minute_to = '' ;
}
if ( $mday_to != '*' ) {
$mday_to = '-' . $mday_to ;
} else {
$mday_to = '' ;
}
if ( $month_to != '*' ) {
$month_to = '-' . $month_to ;
} else {
$month_to = '' ;
}
if ( $wday_to != '*' ) {
$wday_to = '-' . $wday_to ;
} else {
$wday_to = '' ;
}
$cron_interval = $minute_from . $minute_to . ' ' . $hour_from . $hour_to . ' ' . $mday_from . $mday_to . ' ' . $month_from . $month_to . ' ' . $wday_from . $wday_to ;
if ( ! cron_check_syntax ( $cron_interval )) {
$cron_interval = '' ;
}
if ( $prediction_module != MODULE_PREDICTION_SYNTHETIC ) {
unset ( $serialize_ops );
enterprise_hook (
'modules_delete_synthetic_operations' ,
[ $id_agent_module ]
);
}
$active_snmp_v3 = get_parameter ( 'active_snmp_v3' );
if ( $active_snmp_v3 ) {
// LOST CODE?
}
$throw_unknown_events = ( bool ) get_parameter ( 'throw_unknown_events' , false );
// Set the event type that can show.
$disabled_types_event = [ EVENTS_GOING_UNKNOWN => ( int ) $throw_unknown_events ];
$disabled_types_event = io_json_mb_encode ( $disabled_types_event );
$module_macro_names = ( array ) get_parameter ( 'module_macro_names' , []);
$module_macro_values = ( array ) get_parameter ( 'module_macro_values' , []);
$module_macros = modules_get_module_macros_json ( $module_macro_names , $module_macro_values );
2019-04-09 10:46:37 +02:00
// Make changes in the conf file if necessary.
2019-01-30 16:18:44 +01:00
enterprise_include_once ( 'include/functions_config_agents.php' );
$module_in_policy = enterprise_hook ( 'policies_is_module_in_policy' , [ $id_agent_module ]);
$module_linked = enterprise_hook ( 'policies_is_module_linked' , [ $id_agent_module ]);
2019-05-03 12:14:23 +02:00
if (( ! $module_in_policy && ! $module_linked && $update_module )
|| ( $module_in_policy && ! $module_linked && $update_module )
2019-01-30 16:18:44 +01:00
) {
enterprise_hook (
2019-04-09 10:46:37 +02:00
'config_agents_update_module_in_conf' ,
2019-01-30 16:18:44 +01:00
[
$id_agente ,
io_safe_output ( $old_configuration_data ),
io_safe_output ( $configuration_data ),
$disabled ,
]
);
2019-05-03 12:14:23 +02:00
} else {
2019-01-30 16:18:44 +01:00
enterprise_hook (
'config_agents_write_module_in_conf' ,
[
$id_agente ,
io_safe_output ( $old_configuration_data ),
io_safe_output ( $configuration_data ),
$disabled ,
]
);
}
2007-02-27 20:03:56 +01:00
}
2007-03-06 14:18:49 +01:00
2019-04-09 10:46:37 +02:00
// MODULE UPDATE.
2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php: Agent module editions
rewritten. The interface should be clearer now and SNMP walking much
more faster, since it's done with AJAX. Some cleanup might be needed
yet.
* godmode/agentes/module_manager_editor_common.php: Added to
repository. Common part for agent module editors.
* images/edit.png, images/spinner.gif: Added to repository.
* include/javascript/jquery.form.js: Added to repository. jQuery form
plugin.
* include/javascript/jquery.pandora.js: Added to repository. Special
Pandora addons for jQuery library.
* include/javascript/pandora.js: Added an extension to Array
javascript objects to check if an array has an element.
* include/styles/pandora.css: Added styling for new module editors.
* include/functions_db.php: Added get_moduletype_description().
* index.php: Added Pandora jQuery extensions.
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text
useless field from talert_templates.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-02-02 16:40:31 +01:00
if ( $update_module ) {
2019-01-30 16:18:44 +01:00
$id_agent_module = ( int ) get_parameter ( 'id_agent_module' );
$values = [
'id_agente_modulo' => $id_agent_module ,
'descripcion' => $description ,
'id_module_group' => $id_module_group ,
'nombre' => $name ,
'max' => $max ,
'min' => $min ,
'module_interval' => $interval ,
'module_ff_interval' => $ff_interval ,
'tcp_port' => $tcp_port ,
'tcp_send' => $tcp_send ,
'tcp_rcv' => $tcp_rcv ,
'snmp_community' => $snmp_community ,
'snmp_oid' => $snmp_oid ,
'ip_target' => $ip_target ,
'flag' => $flag ,
'disabled' => $disabled ,
'id_export' => $id_export ,
'plugin_user' => $plugin_user ,
'plugin_pass' => $plugin_pass ,
'plugin_parameter' => $plugin_parameter ,
'id_plugin' => $id_plugin ,
'post_process' => $post_process ,
'prediction_module' => $prediction_module ,
'max_timeout' => $max_timeout ,
'max_retries' => $max_retries ,
'custom_id' => $custom_id ,
'history_data' => $history_data ,
'dynamic_interval' => $dynamic_interval ,
'dynamic_max' => $dynamic_max ,
'dynamic_min' => $dynamic_min ,
'dynamic_two_tailed' => $dynamic_two_tailed ,
'parent_module_id' => $parent_module_id ,
'min_warning' => $min_warning ,
'max_warning' => $max_warning ,
'str_warning' => $str_warning ,
'min_critical' => $min_critical ,
'max_critical' => $max_critical ,
'str_critical' => $str_critical ,
'custom_string_1' => $custom_string_1 ,
'custom_string_2' => $custom_string_2 ,
'custom_string_3' => $custom_string_3 ,
'custom_integer_1' => $custom_integer_1 ,
'custom_integer_2' => $custom_integer_2 ,
'min_ff_event' => $ff_event ,
'min_ff_event_normal' => $ff_event_normal ,
'min_ff_event_warning' => $ff_event_warning ,
'min_ff_event_critical' => $ff_event_critical ,
2019-03-27 18:16:53 +01:00
'ff_type' => $ff_type ,
2019-01-30 16:18:44 +01:00
'each_ff' => $each_ff ,
'ff_timeout' => $ff_timeout ,
'unit' => io_safe_output ( $unit ),
'macros' => $macros ,
'quiet' => $quiet_module ,
'cps' => $cps_module ,
'critical_instructions' => $critical_instructions ,
'warning_instructions' => $warning_instructions ,
'unknown_instructions' => $unknown_instructions ,
'critical_inverse' => $critical_inverse ,
'warning_inverse' => $warning_inverse ,
'cron_interval' => $cron_interval ,
'id_category' => $id_category ,
'disabled_types_event' => addslashes ( $disabled_types_event ),
'module_macros' => $module_macros ,
];
if ( $id_module_type == 30 || $id_module_type == 31 || $id_module_type == 32 || $id_module_type == 33 ) {
$plugin_parameter_split = explode ( '
' , $values [ 'plugin_parameter' ]);
$values [ 'plugin_parameter' ] = '' ;
foreach ( $plugin_parameter_split as $key => $value ) {
if ( $key == 1 ) {
$values [ 'plugin_parameter' ] .= 'http_auth_user ' . $http_user . '
' ;
$values [ 'plugin_parameter' ] .= 'http_auth_pass ' . $http_pass . '
' ;
$values [ 'plugin_parameter' ] .= $value . '
' ;
} else {
$values [ 'plugin_parameter' ] .= $value . '
' ;
}
}
}
2019-04-09 10:46:37 +02:00
// In local modules, the interval is updated by agent.
2019-01-30 16:18:44 +01:00
$module_kind = ( int ) get_parameter ( 'moduletype' );
if ( $module_kind == MODULE_DATA ) {
unset ( $values [ 'module_interval' ]);
}
if ( $prediction_module == MODULE_PREDICTION_SYNTHETIC
&& $serialize_ops == ''
) {
$result = false ;
} else {
$check_dynamic = db_get_row_sql (
' SELECT dynamic_interval , dynamic_max , dynamic_min , dynamic_two_tailed
FROM tagente_modulo WHERE id_agente_modulo = ' . $id_agent_module
);
if (( $check_dynamic [ 'dynamic_interval' ] == $dynamic_interval )
&& ( $check_dynamic [ 'dynamic_max' ] == $dynamic_max )
&& ( $check_dynamic [ 'dynamic_min' ] == $dynamic_min )
&& ( $check_dynamic [ 'dynamic_two_tailed' ] == $dynamic_two_tailed )
) {
$result = modules_update_agent_module ( $id_agent_module , $values , false , $id_tag );
} else {
$values [ 'dynamic_next' ] = 0 ;
$result = modules_update_agent_module ( $id_agent_module , $values , false , $id_tag );
}
}
if ( is_error ( $result )) {
switch ( $result ) {
case ERR_EXIST :
$msg = __ ( 'There was a problem updating module. Another module already exists with the same name.' );
break ;
case ERR_INCOMPLETE :
$msg = __ ( 'There was a problem updating module. Some required fields are missed: (name)' );
break ;
case ERR_NOCHANGES :
$msg = __ ( 'There was a problem updating module. "No change"' );
break ;
case ERR_DB :
case ERR_GENERIC :
default :
$msg = __ ( 'There was a problem updating module. Processing error' );
break ;
}
$result = false ;
ui_print_error_message ( $msg );
$edit_module = true ;
db_pandora_audit (
'Agent management' ,
" Fail to try update module ' $name ' for agent " . $agent [ 'alias' ]
);
} else {
if ( $prediction_module == 3 ) {
enterprise_hook (
'modules_create_synthetic_operations' ,
[
$id_agent_module ,
$serialize_ops ,
]
);
}
2019-04-09 10:46:37 +02:00
// Update the module interval.
2019-01-30 16:18:44 +01:00
cron_update_module_interval ( $id_agent_module , $cron_interval );
ui_print_success_message ( __ ( 'Module successfully updated' ));
$id_agent_module = false ;
$edit_module = false ;
$agent = db_get_row ( 'tagente' , 'id_agente' , $id_agente );
db_pandora_audit (
'Agent management' ,
" Updated module ' $name ' for agent " . $agent [ 'alias' ],
false ,
false ,
io_json_mb_encode ( $values )
);
}
2006-03-27 05:37:27 +02:00
}
2019-04-09 10:46:37 +02:00
// MODULE INSERT.
2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php: Agent module editions
rewritten. The interface should be clearer now and SNMP walking much
more faster, since it's done with AJAX. Some cleanup might be needed
yet.
* godmode/agentes/module_manager_editor_common.php: Added to
repository. Common part for agent module editors.
* images/edit.png, images/spinner.gif: Added to repository.
* include/javascript/jquery.form.js: Added to repository. jQuery form
plugin.
* include/javascript/jquery.pandora.js: Added to repository. Special
Pandora addons for jQuery library.
* include/javascript/pandora.js: Added an extension to Array
javascript objects to check if an array has an element.
* include/styles/pandora.css: Added styling for new module editors.
* include/functions_db.php: Added get_moduletype_description().
* index.php: Added Pandora jQuery extensions.
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text
useless field from talert_templates.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-02-02 16:40:31 +01:00
if ( $create_module ) {
2019-01-30 16:18:44 +01:00
if ( isset ( $_POST [ 'combo_snmp_oid' ])) {
$combo_snmp_oid = get_parameter_post ( 'combo_snmp_oid' );
}
if ( $snmp_oid == '' ) {
$snmp_oid = $combo_snmp_oid ;
}
$id_module = ( int ) get_parameter ( 'id_module' );
// Commented because can't create prediction modules
/*
if ( $id_module == 5 ) {
$prediction_module = 1 ;
}
*/
switch ( $config [ 'dbtype' ]) {
case 'oracle' :
if ( empty ( $description ) || ! isset ( $description )) {
$description = ' ' ;
}
break ;
2019-04-09 10:46:37 +02:00
default :
// Default.
break ;
2019-01-30 16:18:44 +01:00
}
$values = [
'id_tipo_modulo' => $id_module_type ,
'descripcion' => $description ,
'max' => $max ,
'min' => $min ,
'snmp_oid' => $snmp_oid ,
'snmp_community' => $snmp_community ,
'id_module_group' => $id_module_group ,
'module_interval' => $interval ,
'module_ff_interval' => $ff_interval ,
'ip_target' => $ip_target ,
'tcp_port' => $tcp_port ,
'tcp_rcv' => $tcp_rcv ,
'tcp_send' => $tcp_send ,
'id_export' => $id_export ,
'plugin_user' => $plugin_user ,
'plugin_pass' => $plugin_pass ,
'plugin_parameter' => $plugin_parameter ,
'id_plugin' => $id_plugin ,
'post_process' => $post_process ,
'prediction_module' => $prediction_module ,
'max_timeout' => $max_timeout ,
'max_retries' => $max_retries ,
'disabled' => $disabled ,
'id_modulo' => $id_module ,
'custom_id' => $custom_id ,
'history_data' => $history_data ,
'dynamic_interval' => $dynamic_interval ,
'dynamic_max' => $dynamic_max ,
'dynamic_min' => $dynamic_min ,
'dynamic_two_tailed' => $dynamic_two_tailed ,
'parent_module_id' => $parent_module_id ,
'min_warning' => $min_warning ,
'max_warning' => $max_warning ,
'str_warning' => $str_warning ,
'min_critical' => $min_critical ,
'max_critical' => $max_critical ,
'str_critical' => $str_critical ,
'custom_string_1' => $custom_string_1 ,
'custom_string_2' => $custom_string_2 ,
'custom_string_3' => $custom_string_3 ,
'custom_integer_1' => $custom_integer_1 ,
'custom_integer_2' => $custom_integer_2 ,
'min_ff_event' => $ff_event ,
'min_ff_event_normal' => $ff_event_normal ,
'min_ff_event_warning' => $ff_event_warning ,
'min_ff_event_critical' => $ff_event_critical ,
2019-03-27 18:16:53 +01:00
'ff_type' => $ff_type ,
2019-01-30 16:18:44 +01:00
'each_ff' => $each_ff ,
'ff_timeout' => $ff_timeout ,
'unit' => io_safe_output ( $unit ),
'macros' => $macros ,
'quiet' => $quiet_module ,
'cps' => $cps_module ,
'critical_instructions' => $critical_instructions ,
'warning_instructions' => $warning_instructions ,
'unknown_instructions' => $unknown_instructions ,
'critical_inverse' => $critical_inverse ,
'warning_inverse' => $warning_inverse ,
'cron_interval' => $cron_interval ,
'id_category' => $id_category ,
'disabled_types_event' => addslashes ( $disabled_types_event ),
'module_macros' => $module_macros ,
];
if ( $id_module_type == 30 || $id_module_type == 31 || $id_module_type == 32 || $id_module_type == 33 ) {
$plugin_parameter_split = explode ( '
' , $values [ 'plugin_parameter' ]);
$values [ 'plugin_parameter' ] = '' ;
foreach ( $plugin_parameter_split as $key => $value ) {
if ( $key == 1 ) {
$values [ 'plugin_parameter' ] .= 'http_auth_user ' . $http_user . '
' ;
$values [ 'plugin_parameter' ] .= 'http_auth_pass ' . $http_pass . '
' ;
$values [ 'plugin_parameter' ] .= $value . '
' ;
} else {
$values [ 'plugin_parameter' ] .= $value . '
' ;
}
}
}
if ( $prediction_module == 3 && $serialize_ops == '' ) {
$id_agent_module = false ;
} else {
$id_agent_module = modules_create_agent_module (
$id_agente ,
$name ,
$values ,
false ,
$id_tag
);
}
if ( is_error ( $id_agent_module )) {
switch ( $id_agent_module ) {
case ERR_EXIST :
$msg = __ ( 'There was a problem adding module. Another module already exists with the same name.' );
break ;
case ERR_INCOMPLETE :
$msg = __ ( 'There was a problem adding module. Some required fields are missed : (name)' );
break ;
case ERR_DB :
case ERR_GENERIC :
default :
$msg = __ ( 'There was a problem adding module. Processing error' );
break ;
}
$id_agent_module = false ;
ui_print_error_message ( $msg );
$edit_module = true ;
$moduletype = $id_module ;
db_pandora_audit (
'Agent management' ,
" Fail to try added module ' $name ' for agent " . $agent [ 'alias' ]
);
} else {
if ( $prediction_module == 3 ) {
enterprise_hook ( 'modules_create_synthetic_operations' , [ $id_agent_module , $serialize_ops ]);
}
2019-04-09 10:46:37 +02:00
// Update the module interval.
2019-01-30 16:18:44 +01:00
cron_update_module_interval ( $id_agent_module , $cron_interval );
ui_print_success_message ( __ ( 'Module added successfully' ));
$id_agent_module = false ;
$edit_module = false ;
$info = '' ;
$agent = db_get_row ( 'tagente' , 'id_agente' , $id_agente );
db_pandora_audit (
'Agent management' ,
" Added module ' $name ' for agent " . $agent [ 'alias' ],
false ,
true ,
io_json_mb_encode ( $values )
);
}
2006-03-27 05:37:27 +02:00
}
2007-03-12 18:58:52 +01:00
2007-02-27 20:03:56 +01:00
// MODULE DELETION
2019-04-09 10:46:37 +02:00
// =================.
2019-01-30 16:18:44 +01:00
if ( $delete_module ) {
// DELETE agent module !
$id_borrar_modulo = ( int ) get_parameter_get ( 'delete_module' , 0 );
$module_data = db_get_row_sql (
' SELECT tam . id_agente , tam . nombre
2015-06-10 15:40:59 +02:00
FROM tagente_modulo tam , tagente_estado tae
WHERE tam . id_agente_modulo = tae . id_agente_modulo
2019-01-30 16:18:44 +01:00
AND tam . id_agente_modulo = ' . $id_borrar_modulo
);
$id_grupo = ( int ) agents_get_agent_group ( $id_agente );
$all_groups = agents_get_all_groups_agent ( $id_agente , $id_grupo );
if ( ! check_acl_one_of_groups ( $config [ 'id_user' ], $all_groups , 'AW' )) {
db_pandora_audit (
'ACL Violation' ,
'Trying to delete a module without admin rights'
);
include 'general/noaccess.php' ;
exit ;
}
if ( empty ( $module_data ) || $id_borrar_modulo < 1 ) {
db_pandora_audit (
'HACK Attempt' ,
'Expected variable from form is not correct'
);
include 'general/noaccess.php' ;
exit ;
}
enterprise_include_once ( 'include/functions_config_agents.php' );
enterprise_hook ( 'config_agents_delete_module_in_conf' , [ modules_get_agentmodule_agent ( $id_borrar_modulo ), modules_get_agentmodule_name ( $id_borrar_modulo )]);
2019-04-09 10:46:37 +02:00
// Init transaction.
2019-01-30 16:18:44 +01:00
$error = 0 ;
// First delete from tagente_modulo -> if not successful, increment
// error. NOTICE that we don't delete all data here, just marking for deletion
// and delete some simple data.
$values = [
'nombre' => 'pendingdelete' ,
'disabled' => 1 ,
'delete_pending' => 1 ,
];
$result = db_process_sql_update (
'tagente_modulo' ,
$values ,
[ 'id_agente_modulo' => $id_borrar_modulo ]
);
if ( $result === false ) {
$error ++ ;
} else {
2019-04-09 10:46:37 +02:00
// Set flag to update module status count.
2019-01-30 16:18:44 +01:00
db_process_sql (
' UPDATE tagente
2013-09-05 18:35:49 +02:00
SET update_module_count = 1 , update_alert_count = 1
2019-01-30 16:18:44 +01:00
WHERE id_agente = '.$module_data[' id_agente ' ]
);
}
$result = db_process_sql_delete (
'tagente_estado' ,
[ 'id_agente_modulo' => $id_borrar_modulo ]
);
if ( $result === false ) {
$error ++ ;
}
$result = db_process_sql_delete (
'tagente_datos_inc' ,
[ 'id_agente_modulo' => $id_borrar_modulo ]
);
if ( $result === false ) {
$error ++ ;
}
if ( alerts_delete_alert_agent_module (
false ,
[ 'id_agent_module' => $id_borrar_modulo ]
) === false
) {
$error ++ ;
}
$result = db_process_delete_temp (
'ttag_module' ,
'id_agente_modulo' ,
$id_borrar_modulo
);
if ( $result === false ) {
$error ++ ;
}
// Trick to detect if we are deleting a synthetic module (avg or arithmetic)
2019-04-09 10:46:37 +02:00
// If result is empty then module doesn't have this type of submodules.
2019-01-30 16:18:44 +01:00
$ops_json = enterprise_hook ( 'modules_get_synthetic_operations' , [ $id_borrar_modulo ]);
$result_ops_synthetic = json_decode ( $ops_json );
if ( ! empty ( $result_ops_synthetic )) {
$result = enterprise_hook ( 'modules_delete_synthetic_operations' , [ $id_borrar_modulo ]);
if ( $result === false ) {
$error ++ ;
}
2019-04-09 10:46:37 +02:00
} else {
2019-01-30 16:18:44 +01:00
$result_components = enterprise_hook ( 'modules_get_synthetic_components' , [ $id_borrar_modulo ]);
$count_components = 1 ;
if ( ! empty ( $result_components )) {
2019-04-09 10:46:37 +02:00
// Get number of components pending to delete to know when it's needed to update orders.
2019-01-30 16:18:44 +01:00
$num_components = count ( $result_components );
$last_target_module = 0 ;
foreach ( $result_components as $id_target_module ) {
2019-04-09 10:46:37 +02:00
// Detects change of component or last component to update orders.
2019-01-30 16:18:44 +01:00
if (( $count_components == $num_components )
2019-04-09 10:46:37 +02:00
|| ( $last_target_module != $id_target_module )
2019-01-30 16:18:44 +01:00
) {
$update_orders = true ;
} else {
$update_orders = false ;
}
$result = enterprise_hook ( 'modules_delete_synthetic_operations' , [ $id_target_module , $id_borrar_modulo , $update_orders ]);
if ( $result === false ) {
$error ++ ;
}
$count_components ++ ;
$last_target_module = $id_target_module ;
}
}
}
2019-04-09 10:46:37 +02:00
// Check for errors.
2019-01-30 16:18:44 +01:00
if ( $error != 0 ) {
ui_print_error_message ( __ ( 'There was a problem deleting the module' ));
} else {
echo ' < script type = " text/javascript " >
2018-08-03 15:18:03 +02:00
location = " index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='. $id_agente .' " ;
alert ( " '.__('Module deleted succesfully').' " );
</ script > ' ;
2018-08-03 14:40:51 +02:00
2019-01-30 16:18:44 +01:00
$agent = db_get_row ( 'tagente' , 'id_agente' , $id_agente );
db_pandora_audit (
'Agent management' ,
" Deleted module ' " . $module_data [ 'nombre' ] . " ' for agent " . $agent [ 'alias' ]
);
}
2006-03-27 05:37:27 +02:00
}
2010-10-14 19:07:50 +02:00
// MODULE DUPLICATION
2019-04-09 10:46:37 +02:00
// ==================.
2019-01-30 16:18:44 +01:00
if ( ! empty ( $duplicate_module )) {
// DUPLICATE agent module !
$id_duplicate_module = $duplicate_module ;
$original_name = modules_get_agentmodule_name ( $id_duplicate_module );
$copy_name = io_safe_input ( sprintf ( __ ( 'copy of %s' ), io_safe_output ( $original_name )));
$cont = 0 ;
$exists = true ;
while ( $exists ) {
$exists = ( bool ) db_get_value (
'id_agente_modulo' ,
'tagente_modulo' ,
'nombre' ,
$copy_name
);
if ( $exists ) {
$cont ++ ;
$copy_name = io_safe_input (
sprintf ( __ ( 'copy of %s (%d)' ), io_safe_output ( $original_name ), $cont )
);
}
}
$result = modules_copy_agent_module_to_agent (
$id_duplicate_module ,
modules_get_agentmodule_agent ( $id_duplicate_module ),
$copy_name
);
$agent = db_get_row ( 'tagente' , 'id_agente' , $id_agente );
if ( $result ) {
db_pandora_audit (
'Agent management' ,
" Duplicate module ' " . $id_duplicate_module . " ' for agent " . $agent [ 'alias' ] . ' with the new id for clon ' . $result
);
} else {
db_pandora_audit (
'Agent management' ,
" Fail to try duplicate module ' " . $id_duplicate_module . " ' for agent " . $agent [ 'alias' ]
);
}
2010-10-14 19:07:50 +02:00
}
2013-01-14 16:11:07 +01:00
// MODULE ENABLE/DISABLE
2019-04-09 10:46:37 +02:00
// =====================.
2013-06-07 11:36:26 +02:00
if ( $enable_module ) {
2019-01-30 16:18:44 +01:00
$result = modules_change_disabled ( $enable_module , 0 );
$modulo_nombre = db_get_row_sql ( 'SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = ' . $enable_module . '' );
$modulo_nombre = $modulo_nombre [ 'nombre' ];
if ( $result === NOERR ) {
enterprise_hook ( 'config_agents_enable_module_conf' , [ $id_agente , $enable_module ]);
db_pandora_audit ( 'Module management' , 'Enable #' . $enable_module . ' | ' . $modulo_nombre . ' | ' . $agent [ 'alias' ]);
} else {
db_pandora_audit ( 'Module management' , 'Fail to enable #' . $enable_module . ' | ' . $modulo_nombre . ' | ' . $agent [ 'alias' ]);
}
ui_print_result_message (
$result ,
__ ( 'Successfully enabled' ),
__ ( 'Could not be enabled' )
);
2013-01-14 16:11:07 +01:00
}
2013-06-07 11:36:26 +02:00
if ( $disable_module ) {
2019-01-30 16:18:44 +01:00
$result = modules_change_disabled ( $disable_module , 1 );
$modulo_nombre = db_get_row_sql ( 'SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = ' . $disable_module . '' );
$modulo_nombre = $modulo_nombre [ 'nombre' ];
if ( $result === NOERR ) {
enterprise_hook ( 'config_agents_disable_module_conf' , [ $id_agente , $disable_module ]);
db_pandora_audit ( 'Module management' , 'Disable #' . $disable_module . ' | ' . $modulo_nombre . ' | ' . $agent [ 'alias' ]);
} else {
db_pandora_audit ( 'Module management' , 'Fail to disable #' . $disable_module . ' | ' . $modulo_nombre . ' | ' . $agent [ 'alias' ]);
}
ui_print_result_message (
$result ,
__ ( 'Successfully disabled' ),
__ ( 'Could not be disabled' )
);
2013-01-14 16:11:07 +01:00
}
2010-02-10 14:08:33 +01:00
// UPDATE GIS
2019-04-09 10:46:37 +02:00
// ==========.
2010-02-10 14:08:33 +01:00
$updateGIS = get_parameter ( 'update_gis' , 0 );
if ( $updateGIS ) {
2019-01-30 16:18:44 +01:00
$updateGisData = get_parameter ( 'update_gis_data' );
$lastLatitude = get_parameter ( 'latitude' );
$lastLongitude = get_parameter ( 'longitude' );
$lastAltitude = get_parameter ( 'altitude' );
$idAgente = get_parameter ( 'id_agente' );
$previusAgentGISData = db_get_row_sql (
'
2013-06-07 11:36:26 +02:00
SELECT *
FROM tgis_data_status
2019-01-30 16:18:44 +01:00
WHERE tagente_id_agente = ' . $idAgente
);
db_process_sql_update (
'tagente' ,
[ 'update_gis_data' => $updateGisData ],
[ 'id_agente' => $idAgente ]
);
if ( $previusAgentGISData !== false ) {
db_process_sql_insert (
'tgis_data_history' ,
[
'longitude' => $previusAgentGISData [ 'stored_longitude' ],
'latitude' => $previusAgentGISData [ 'stored_latitude' ],
'altitude' => $previusAgentGISData [ 'stored_altitude' ],
'start_timestamp' => $previusAgentGISData [ 'start_timestamp' ],
'end_timestamp' => date ( 'Y-m-d H:i:s' ),
'description' => __ ( 'Save by %s Console' , get_product_name ()),
'manual_placement' => $previusAgentGISData [ 'manual_placement' ],
'number_of_packages' => $previusAgentGISData [ 'number_of_packages' ],
'tagente_id_agente' => $previusAgentGISData [ 'tagente_id_agente' ],
]
);
db_process_sql_update (
'tgis_data_status' ,
[
'tagente_id_agente' => $idAgente ,
'current_longitude' => $lastLongitude ,
'current_latitude' => $lastLatitude ,
'current_altitude' => $lastAltitude ,
'stored_longitude' => $lastLongitude ,
'stored_latitude' => $lastLatitude ,
'stored_altitude' => $lastAltitude ,
'start_timestamp' => date ( 'Y-m-d H:i:s' ),
'manual_placement' => 1 ,
'description' => __ ( 'Update by %s Console' , get_product_name ()),
],
[ 'tagente_id_agente' => $idAgente ]
);
} else {
db_process_sql_insert (
'tgis_data_status' ,
[
'tagente_id_agente' => $idAgente ,
'current_longitude' => $lastLongitude ,
'current_latitude' => $lastLatitude ,
'current_altitude' => $lastAltitude ,
'stored_longitude' => $lastLongitude ,
'stored_latitude' => $lastLatitude ,
'stored_altitude' => $lastAltitude ,
'manual_placement' => 1 ,
'description' => __ ( 'Insert by %s Console' , get_product_name ()),
]
);
}
2010-02-10 14:08:33 +01:00
}
2007-03-12 18:58:52 +01:00
// -----------------------------------
2007-03-02 18:56:07 +01:00
// Load page depending on tab selected
// -----------------------------------
2007-02-27 20:03:56 +01:00
switch ( $tab ) {
2019-01-30 16:18:44 +01:00
case 'main' :
include 'agent_manager.php' ;
break ;
case 'module' :
if ( $id_agent_module || $edit_module ) {
include 'module_manager_editor.php' ;
} else {
include 'module_manager.php' ;
}
break ;
case 'alert' :
2019-04-09 10:46:37 +02:00
// Because $id_agente is set, it will show only agent alerts.
// This var is for not display create button on alert list.
2019-01-30 16:18:44 +01:00
$dont_display_alert_create_bttn = true ;
include 'godmode/alerts/alert_list.php' ;
break ;
case 'template' :
include 'agent_template.php' ;
break ;
case 'gis' :
include 'agent_conf_gis.php' ;
break ;
case 'incident' :
include 'agent_incidents.php' ;
break ;
case 'remote_configuration' :
enterprise_include ( 'godmode/agentes/agent_disk_conf_editor.php' );
break ;
case 'extension' :
$found = false ;
foreach ( $config [ 'extensions' ] as $extension ) {
if ( isset ( $extension [ 'extension_god_tab' ])) {
$id = $extension [ 'extension_god_tab' ][ 'id' ];
$function = $extension [ 'extension_god_tab' ][ 'function' ];
$id_extension = get_parameter ( 'id_extension' , '' );
if ( $id_extension == $id ) {
call_user_func_array ( $function , []);
$found = true ;
}
}
}
if ( ! $found ) {
ui_print_error_message ( __ ( 'Invalid tab specified' ));
}
break ;
case 'agent_wizard' :
include 'agent_wizard.php' ;
break ;
default :
if ( enterprise_hook ( 'switch_agent_tab' , [ $tab ])) {
// This will make sure that blank pages will have at least some
2019-04-09 10:46:37 +02:00
// debug info in them - do not translate debug.
2019-01-30 16:18:44 +01:00
ui_print_error_message ( __ ( 'Invalid tab specified' ));
}
break ;
2006-03-27 05:37:27 +02:00
}
2013-07-09 09:39:14 +02:00
2012-08-29 13:58:36 +02:00
?>
2015-04-15 10:26:48 +02:00
2013-07-09 09:39:14 +02:00
< script type = " text/javascript " >
2019-01-30 16:18:44 +01:00
/* <![CDATA[ */
var wizard_tab_showed = 0 ;
$ ( document ) . ready ( function () {
$ ( 'body' ) . append ( '<div id="dialog"></div>' );
// Control the tab and subtab hover. When mouse leave one,
// check if is hover the other before hide the subtab
$ ( '.agent_wizard_tab' ) . hover ( agent_wizard_tab_show , agent_wizard_tab_hide );
$ ( '#module_form' ) . submit ( function () {
var aget_id_os = '<?php echo agents_get_os(modules_get_agentmodule_agent(get_parameter(' id_agent_module '))); ?>' ;
if ( '<?php echo html_entity_decode(modules_get_agentmodule_name(get_parameter(' id_agent_module '))); ?>' != $ ( '#text-name' ) . val () &&
'<?php echo agents_get_os(modules_get_agentmodule_agent(get_parameter(' id_agent_module '))); ?>' == 19 ){
event . preventDefault ();
$ ( " #dialog " ) . dialog ({
resizable : true ,
draggable : true ,
modal : true ,
height : 240 ,
width : 600 ,
title : 'Changing the module name of a satellite agent' ,
open : function (){
$ ( '#dialog' ) . html ( '<br><table><tr><td><img src="images/icono-warning-triangulo.png" style="float:left;margin-left:25px;"></td><td><p style="float:right;font-style:nunito;font-size:11pt;margin-right:50px;margin-left:40px;"><span style="font-weight:bold;font-size:12pt;">Warning</span> <br>The names of the modules of a satellite should not be altered manually. Unless you are absolutely certain of the process, do not alter these names.</p></td></tr></table>' );
},
buttons : [{
text : " Ok " ,
click : function () {
$ ( '#module_form' ) . submit ();
}
},
{
text : " Cancel " ,
click : function () {
$ ( this ) . dialog ( " close " );
return false ;
}
}]
});
}
var module_type_snmp = '<?php echo modules_get_agentmodule_type(get_parameter(' id_agent_module ')); ?>' ;
if ( '<?php echo html_entity_decode(modules_get_agentmodule_name(get_parameter(' id_agent_module '))); ?>' != $ ( '#text-name' ) . val () && (
module_type_snmp == 15 || module_type_snmp == 16 || module_type_snmp == 17 || module_type_snmp == 18 )){
event . preventDefault ();
$ ( " #dialog " ) . dialog ({
resizable : true ,
draggable : true ,
modal : true ,
height : 240 ,
width : 650 ,
title : 'Changing snmp module name' ,
open : function (){
$ ( '#dialog' ) . html ( '<br><table><tr><td><img src="images/icono-warning-triangulo.png" style="float:left;margin-left:25px;margin-top:30px;"></td><td><p style="float:right;font-style:nunito;font-size:11pt;margin-right:50px;margin-left:40px;"><span style="font-weight:bold;font-size:12pt;">Warning</span> <br> If you change the name of this module, various features associated with this module, such as network maps, interface graphs or other network modules, may no longer work. If you are not completely sure of the process, please do not change the name of the module. </p></td></tr></table>' );
},
buttons : [{
text : " Ok " ,
click : function () {
$ ( '#module_form' ) . submit ();
}
},
{
text : " Cancel " ,
click : function () {
$ ( this ) . dialog ( " close " );
return false ;
}
}]
});
}
});
2018-05-11 16:13:56 +02:00
});
2019-01-30 16:18:44 +01:00
// Set the position and width of the subtab
/*
function agent_wizard_tab_setup () {
$ ( '#agent_wizard_subtabs' ) . css ( 'left' , $ ( '.agent_wizard_tab' ) . offset () . left - 5 )
$ ( '#agent_wizard_subtabs' ) . css ( 'top' , $ ( '.agent_wizard_tab' ) . offset () . top + $ ( '.agent_wizard_tab' ) . height () + 7 )
$ ( '#agent_wizard_subtabs' ) . css ( 'width' , $ ( '.agent_wizard_tab' ) . width () + 19 )
}
*/
function agent_wizard_tab_show () {
wizard_tab_showed = wizard_tab_showed + 1 ;
if ( wizard_tab_showed == 1 ) {
$ ( '.subsubmenu' ) . show ( " fast " );
}
}
function agent_wizard_tab_hide () {
wizard_tab_showed = wizard_tab_showed - 1 ;
setTimeout ( function () {
if ( wizard_tab_showed <= 0 ) {
$ ( '.subsubmenu' ) . hide ( " fast " );
}
}, 15000 );
}
/* ]]> */
2013-07-09 09:39:14 +02:00
</ script >