2009-02-16 13:18:42 +01:00
|
|
|
<?php
|
|
|
|
|
2009-06-08 20:26:14 +02:00
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
|
|
|
// Please see http://pandorafms.org for full contribution list
|
2009-02-16 13:18:42 +01:00
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
2009-06-08 20:26:14 +02:00
|
|
|
// modify it under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation; version 2
|
|
|
|
|
2009-02-16 13:18:42 +01:00
|
|
|
// 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.
|
|
|
|
|
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php,
include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/FusionCharts/FusionCharts_Gen.php,
include/FusionCharts/FusionCharts.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/help/en/help_plugin_parameters.php,
include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php,
include/help/en/help_postprocess.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_date_format.php, include/help/en/help_recontask.php,
include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php,
include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php,
include/help/en/help_agent_status.php,
include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php,
include/help/en/help_time_stamp-comparation.php,
include/help/en/help_eventview.php, include/help/en/help_timesource.php,
include/help/en/help_alert_validation.php,
include/help/en/help_map_builder.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_module_type.php,
include/help/en/help_planned_downtime.php,
include/help/en/help_serverlag.php, include/help/en/help_alerts.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_module_definition.php,
include/help/en/help_plugin_definition.php,
include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php
include/help/en/help_manageconfig.php,
include/help/es/help_alert_validation.php,
include/help/es/help_plugin_parameters.php,
include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php,
include/help/es/help_map_builder.php, include/help/es/help_postprocess.php,
include/help/es/help_date_format.php,
include/help/es/help_alert_recovery.php,
include/help/es/help_prediction_source_module.php,
include/help/es/help_module_type.php,
include/help/es/help_planned_downtime.php,
include/help/es/help_alert-matches.php, include/help/es/help_recontask.php,
include/help/es/help_alerts.php, include/help/es/help_serverlag.php,
include/help/es/help_snmpwalk.php,
include/help/es/help_module_definition.php,
include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php,
include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php,
include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php,
include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php,
include/help/es/help_wminamespace.php,
include/help/es/help_network_component.php,
include/help/es/help_time_stamp-comparation.php,
include/help/es/help_manageconfig.php, include/help/es/help_timesource.php,
include/config_process.php, include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change comments blocks for delete the
warnings to construct phpDoc Files, give a struct and order in the
phpDoc files.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-25 19:39:28 +02:00
|
|
|
/**
|
|
|
|
* @package Include
|
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/ldap.php,
include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/config_process.php,
include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change or add the subpackage in phpdoc
comment blocks for to organize more the result phpdoc files. Start to
document undocument functions.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1882 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-26 17:37:47 +02:00
|
|
|
* @subpackage Modules
|
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php,
include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/FusionCharts/FusionCharts_Gen.php,
include/FusionCharts/FusionCharts.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/help/en/help_plugin_parameters.php,
include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php,
include/help/en/help_postprocess.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_date_format.php, include/help/en/help_recontask.php,
include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php,
include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php,
include/help/en/help_agent_status.php,
include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php,
include/help/en/help_time_stamp-comparation.php,
include/help/en/help_eventview.php, include/help/en/help_timesource.php,
include/help/en/help_alert_validation.php,
include/help/en/help_map_builder.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_module_type.php,
include/help/en/help_planned_downtime.php,
include/help/en/help_serverlag.php, include/help/en/help_alerts.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_module_definition.php,
include/help/en/help_plugin_definition.php,
include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php
include/help/en/help_manageconfig.php,
include/help/es/help_alert_validation.php,
include/help/es/help_plugin_parameters.php,
include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php,
include/help/es/help_map_builder.php, include/help/es/help_postprocess.php,
include/help/es/help_date_format.php,
include/help/es/help_alert_recovery.php,
include/help/es/help_prediction_source_module.php,
include/help/es/help_module_type.php,
include/help/es/help_planned_downtime.php,
include/help/es/help_alert-matches.php, include/help/es/help_recontask.php,
include/help/es/help_alerts.php, include/help/es/help_serverlag.php,
include/help/es/help_snmpwalk.php,
include/help/es/help_module_definition.php,
include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php,
include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php,
include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php,
include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php,
include/help/es/help_wminamespace.php,
include/help/es/help_network_component.php,
include/help/es/help_time_stamp-comparation.php,
include/help/es/help_manageconfig.php, include/help/es/help_timesource.php,
include/config_process.php, include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change comments blocks for delete the
warnings to construct phpDoc Files, give a struct and order in the
phpDoc files.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-25 19:39:28 +02:00
|
|
|
*/
|
|
|
|
|
2009-02-16 13:18:42 +01:00
|
|
|
/**
|
|
|
|
* Copy a module defined in an agent to other agent.
|
|
|
|
*
|
|
|
|
* This function avoid duplicated by comparing module names.
|
|
|
|
*
|
|
|
|
* @param int Source agent module id.
|
|
|
|
* @param int Detiny agent id.
|
|
|
|
*
|
|
|
|
* @return New agent module id on success. Existing module id if it already exists.
|
|
|
|
* False on error.
|
|
|
|
*/
|
|
|
|
function copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent) {
|
2009-03-03 23:12:06 +01:00
|
|
|
$module = get_agentmodule ($id_agent_module);
|
2009-02-16 13:18:42 +01:00
|
|
|
if ($module === false)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
$modules = get_agent_modules ($id_destiny_agent, false,
|
2009-07-16 15:42:51 +02:00
|
|
|
array ('nombre' => $module['nombre'], 'disabled' => false));
|
2009-03-17 16:15:55 +01:00
|
|
|
|
2009-02-16 13:18:42 +01:00
|
|
|
if (! empty ($modules))
|
|
|
|
return array_pop (array_keys ($modules));
|
2009-07-16 15:42:51 +02:00
|
|
|
|
|
|
|
$modulesDisabled = get_agent_modules ($id_destiny_agent, false,
|
|
|
|
array ('nombre' => $module['nombre'], 'disabled' => true));
|
|
|
|
|
|
|
|
if (!empty($modulesDisabled)) {
|
|
|
|
//the foreach have only one loop but extract the array index, and it's id_agente_modulo
|
|
|
|
foreach ($modulesDisabled as $id => $garbage) {
|
|
|
|
$id_module = $id;
|
|
|
|
process_sql_update('tagente_modulo', array('disabled' => false, 'delete_pending' => false),
|
|
|
|
array('id_agente_modulo' => $id_module, 'disabled' => true));
|
|
|
|
}
|
|
|
|
|
|
|
|
$values = array ();
|
|
|
|
$values['id_agente_modulo'] = $id_module;
|
|
|
|
|
|
|
|
/* PHP copy arrays on assignment */
|
|
|
|
$new_module = $module;
|
|
|
|
|
|
|
|
/* Rewrite different values */
|
|
|
|
$new_module['id_agente'] = $id_destiny_agent;
|
|
|
|
$new_module['ip_target'] = get_agent_address ($id_destiny_agent);
|
|
|
|
|
|
|
|
/* Unset numeric indexes or SQL would fail */
|
|
|
|
$len = count ($new_module) / 2;
|
|
|
|
for ($i = 0; $i < $len; $i++)
|
|
|
|
unset ($new_module[$i]);
|
|
|
|
/* Unset original agent module id */
|
|
|
|
unset ($new_module['id_agente_modulo']);
|
|
|
|
|
|
|
|
$id_new_module = $id_module;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* PHP copy arrays on assignment */
|
|
|
|
$new_module = $module;
|
|
|
|
|
|
|
|
/* Rewrite different values */
|
|
|
|
$new_module['id_agente'] = $id_destiny_agent;
|
|
|
|
$new_module['ip_target'] = get_agent_address ($id_destiny_agent);
|
|
|
|
|
|
|
|
/* Unset numeric indexes or SQL would fail */
|
|
|
|
$len = count ($new_module) / 2;
|
|
|
|
for ($i = 0; $i < $len; $i++)
|
|
|
|
unset ($new_module[$i]);
|
|
|
|
/* Unset original agent module id */
|
|
|
|
unset ($new_module['id_agente_modulo']);
|
|
|
|
|
|
|
|
$id_new_module = process_sql_insert ('tagente_modulo', $new_module);
|
|
|
|
if ($id_new_module === false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values = array ();
|
|
|
|
$values['id_agente_modulo'] = $id_new_module;
|
2009-02-16 13:18:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$values['id_agente'] = $id_destiny_agent;
|
|
|
|
|
2009-07-16 15:42:51 +02:00
|
|
|
if (! in_array ($new_module['id_tipo_modulo'], array (2, 6, 9, 18, 21, 100))) //TODO delete magic numbers
|
2009-02-16 13:18:42 +01:00
|
|
|
/* Not proc modules uses a special estado (status) value */
|
|
|
|
$values['estado'] = 100;
|
|
|
|
|
|
|
|
$result = process_sql_insert ('tagente_estado', $values);
|
|
|
|
if ($result === false)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return $id_new_module;
|
|
|
|
}
|
|
|
|
|
2009-03-17 16:15:55 +01:00
|
|
|
/**
|
|
|
|
* Deletes a module from an agent.
|
|
|
|
*
|
|
|
|
* @param mixed Agent module id to be deleted. Accepts an array with ids.
|
|
|
|
*
|
|
|
|
* @return True if the module was deleted. False if not.
|
|
|
|
*/
|
2009-05-13 Esteban Sánchez <estebans@artica.es>
* images/clean.png, images/fullscreen.png, images/local_component.png,
images/log-out.png, images/normalscreen.png,
images/server_export.png: Added to repository. New tango icons.
* images/application_osx_terminal.png, images/arrow_refresh.png,
images/asterisk_yellow.png, images/attach.png,
images/drive_network.png, images/drive_user.png,
images/page_white_acrobat.png, images/rainbow.png,
images/telephone.png: Deleted from repository. Unused images.
* images/add.png, images/application_double.png,
images/application_edit.png, images/application.png,
images/book_edit.png, images/calendar_view_day.png,
images/camera.png, images/email_open.png, images/email.png,
images/god3.png, images/group.png, images/heart.png,
images/house.png, images/lupa.png, images/monitor.png,
images/mouse.png, images/package.png, images/page_white_magnify.png,
images/page_white.png, images/page_white_text.png,
images/paste_plain.png, images/pdf.png,
images/refresh.png, images/reporting.png, images/rosette.png,
images/script.png, images/server_database.png, images/server.png,
images/world.png, images/zoom.png: Updated to use tango icons.
* general/ui/agents_list.php: Added pagination.
* general/header.php: Logout icon replaced.
* include/styles/pandora.css: Some styles for tabs.
* include/functions_db.php: Changed export server icon.
* operation/events/events.php, operation/snmpconsole/snmp_view.php,
operation/visual_console/render_view.php,
operation/agentes/networkmap.php: Changed fullscreen icons.
* godmode/agentes/configurar_agente.php,
include/functions_modules.php,
include/functions_agents.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1686 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-05-13 14:29:37 +02:00
|
|
|
function delete_agent_module ($id_agent_module) {
|
|
|
|
$where = array ('id_agent_module' => $id_agent_module);
|
2009-03-17 16:15:55 +01:00
|
|
|
|
2010-09-22 10:21:08 +02:00
|
|
|
enterprise_hook('deleteLocalModuleInConf', array(get_agentmodule_agent($id_agent_module), get_agentmodule_name($id_agent_module)));
|
2010-09-13 09:38:56 +02:00
|
|
|
|
2009-03-17 16:15:55 +01:00
|
|
|
process_sql_delete ('talert_template_modules', $where);
|
|
|
|
process_sql_delete ('tgraph_source', $where);
|
|
|
|
process_sql_delete ('treport_content', $where);
|
2009-05-13 Esteban Sánchez <estebans@artica.es>
* images/clean.png, images/fullscreen.png, images/local_component.png,
images/log-out.png, images/normalscreen.png,
images/server_export.png: Added to repository. New tango icons.
* images/application_osx_terminal.png, images/arrow_refresh.png,
images/asterisk_yellow.png, images/attach.png,
images/drive_network.png, images/drive_user.png,
images/page_white_acrobat.png, images/rainbow.png,
images/telephone.png: Deleted from repository. Unused images.
* images/add.png, images/application_double.png,
images/application_edit.png, images/application.png,
images/book_edit.png, images/calendar_view_day.png,
images/camera.png, images/email_open.png, images/email.png,
images/god3.png, images/group.png, images/heart.png,
images/house.png, images/lupa.png, images/monitor.png,
images/mouse.png, images/package.png, images/page_white_magnify.png,
images/page_white.png, images/page_white_text.png,
images/paste_plain.png, images/pdf.png,
images/refresh.png, images/reporting.png, images/rosette.png,
images/script.png, images/server_database.png, images/server.png,
images/world.png, images/zoom.png: Updated to use tango icons.
* general/ui/agents_list.php: Added pagination.
* general/header.php: Logout icon replaced.
* include/styles/pandora.css: Some styles for tabs.
* include/functions_db.php: Changed export server icon.
* operation/events/events.php, operation/snmpconsole/snmp_view.php,
operation/visual_console/render_view.php,
operation/agentes/networkmap.php: Changed fullscreen icons.
* godmode/agentes/configurar_agente.php,
include/functions_modules.php,
include/functions_agents.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1686 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-05-13 14:29:37 +02:00
|
|
|
process_sql_delete ('tevento', array ('id_agentmodule' => $id_agent_module));
|
|
|
|
$where = array ('id_agente_modulo' => $id_agent_module);
|
2009-03-17 16:15:55 +01:00
|
|
|
process_sql_delete ('tlayout_data', $where);
|
|
|
|
process_sql_delete ('tagente_estado', $where);
|
|
|
|
process_sql_update ('tagente_modulo',
|
2009-11-25 10:44:58 +01:00
|
|
|
array ('nombre' => 'delete_pending', 'delete_pending' => 1, 'disabled' => 1),
|
2009-03-17 16:15:55 +01:00
|
|
|
$where);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-03-18 16:42:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates a module from an agent.
|
|
|
|
*
|
|
|
|
* @param mixed Agent module id to be deleted. Accepts an array with ids.
|
|
|
|
* @param array Values to update.
|
|
|
|
*
|
|
|
|
* @return True if the module was updated. False if not.
|
|
|
|
*/
|
2009-09-18 17:14:44 +02:00
|
|
|
function update_agent_module ($id, $values, $onlyNoDeletePending = false) {
|
2009-05-29 12:32:26 +02:00
|
|
|
if (! is_array ($values) || empty ($values))
|
2009-03-18 16:42:15 +01:00
|
|
|
return false;
|
2009-05-29 12:32:26 +02:00
|
|
|
if (isset ($values['nombre']) && empty ($values['nombre']))
|
2009-05-27 12:31:27 +02:00
|
|
|
return false;
|
2009-03-18 16:42:15 +01:00
|
|
|
|
2009-09-18 17:14:44 +02:00
|
|
|
if ($onlyNoDeletePending) {
|
|
|
|
return (@process_sql_update ('tagente_modulo', $values,
|
|
|
|
array ('id_agente_modulo' => (int) $id, 'delete_pending' => 0)) !== false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return (@process_sql_update ('tagente_modulo', $values,
|
|
|
|
array ('id_agente_modulo' => (int) $id)) !== false);
|
|
|
|
}
|
2009-05-04 Esteban Sánchez <estebans@artica.es>
* include/functions_agents.php: Added create_agent(),
* include/functions_db.php: Renamed dame_agente_id() to get_agent_id ().
Added process_sql_begin(), process_sql_rollback() and process_sql_commit()
and use MySQL functions directly because the Pandora cache was avoiding
more than one execution.
* include/functions_incidents.php, include/functions_messages.php,
godmode/agentes/massive_delete_agents.php,
godmode/agentes/massive_delete_alerts.php,
godmode/agentes/massive_delete_modules.php,
godmode/agentes/massive_edit_modules.php,
godmode/db/db_purge.php,
include/functions_events.php: Use new transaction functions.
* include/functions_modules.php: Sanitize some values. Added
create_agent_module_from_network_component(), create_agent_module()
and get_network_component().
* godmode/agentes/configurar_agente.php: Use get_agent_id() and transaction
functions.
* reporting/fgraph.php, operation/reporting/reporting_viewer.php: Use
get_agent_id().
* godmode/setup/file_manager.php: Removed unnecesary variable.
* operation/agentes/ver_agente.php: Replaced exit with return on ajax
operation.
* include/config_process.php: Updated build number.
* include/functions_network_profiles.php: Fixed documentation.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1672 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-05-04 12:10:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a module in an agent.
|
|
|
|
*
|
|
|
|
* @param int Agent id.
|
|
|
|
* @param int Module name id.
|
|
|
|
* @param array Extra values for the module.
|
2009-12-07 19:00:00 +01:00
|
|
|
* @param bool Disable the ACL checking, for default false.
|
2009-05-04 Esteban Sánchez <estebans@artica.es>
* include/functions_agents.php: Added create_agent(),
* include/functions_db.php: Renamed dame_agente_id() to get_agent_id ().
Added process_sql_begin(), process_sql_rollback() and process_sql_commit()
and use MySQL functions directly because the Pandora cache was avoiding
more than one execution.
* include/functions_incidents.php, include/functions_messages.php,
godmode/agentes/massive_delete_agents.php,
godmode/agentes/massive_delete_alerts.php,
godmode/agentes/massive_delete_modules.php,
godmode/agentes/massive_edit_modules.php,
godmode/db/db_purge.php,
include/functions_events.php: Use new transaction functions.
* include/functions_modules.php: Sanitize some values. Added
create_agent_module_from_network_component(), create_agent_module()
and get_network_component().
* godmode/agentes/configurar_agente.php: Use get_agent_id() and transaction
functions.
* reporting/fgraph.php, operation/reporting/reporting_viewer.php: Use
get_agent_id().
* godmode/setup/file_manager.php: Removed unnecesary variable.
* operation/agentes/ver_agente.php: Replaced exit with return on ajax
operation.
* include/config_process.php: Updated build number.
* include/functions_network_profiles.php: Fixed documentation.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1672 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-05-04 12:10:19 +02:00
|
|
|
*
|
|
|
|
* @return New module id if the module was created. False if not.
|
|
|
|
*/
|
2009-12-07 19:00:00 +01:00
|
|
|
function create_agent_module ($id_agent, $name, $values = false, $disableACL = false) {
|
|
|
|
|
|
|
|
if (!$disableACL) {
|
|
|
|
if (empty ($id_agent) || ! user_access_to_agent ($id_agent, 'AW'))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-05-04 Esteban Sánchez <estebans@artica.es>
* include/functions_agents.php: Added create_agent(),
* include/functions_db.php: Renamed dame_agente_id() to get_agent_id ().
Added process_sql_begin(), process_sql_rollback() and process_sql_commit()
and use MySQL functions directly because the Pandora cache was avoiding
more than one execution.
* include/functions_incidents.php, include/functions_messages.php,
godmode/agentes/massive_delete_agents.php,
godmode/agentes/massive_delete_alerts.php,
godmode/agentes/massive_delete_modules.php,
godmode/agentes/massive_edit_modules.php,
godmode/db/db_purge.php,
include/functions_events.php: Use new transaction functions.
* include/functions_modules.php: Sanitize some values. Added
create_agent_module_from_network_component(), create_agent_module()
and get_network_component().
* godmode/agentes/configurar_agente.php: Use get_agent_id() and transaction
functions.
* reporting/fgraph.php, operation/reporting/reporting_viewer.php: Use
get_agent_id().
* godmode/setup/file_manager.php: Removed unnecesary variable.
* operation/agentes/ver_agente.php: Replaced exit with return on ajax
operation.
* include/config_process.php: Updated build number.
* include/functions_network_profiles.php: Fixed documentation.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1672 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-05-04 12:10:19 +02:00
|
|
|
if (empty ($name))
|
|
|
|
return false;
|
|
|
|
if (! is_array ($values))
|
|
|
|
$values = array ();
|
|
|
|
$values['nombre'] = $name;
|
|
|
|
$values['id_agente'] = (int) $id_agent;
|
|
|
|
|
|
|
|
$id_agent_module = process_sql_insert ('tagente_modulo', $values);
|
|
|
|
|
|
|
|
if ($id_agent_module === false)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
$result = process_sql_insert ('tagente_estado',
|
|
|
|
array ('id_agente_modulo' => $id_agent_module,
|
|
|
|
'datos' => 0,
|
|
|
|
'timestamp' => '0000-00-00 00:00:00',
|
|
|
|
'estado' => 0,
|
|
|
|
'id_agente' => (int) $id_agent,
|
|
|
|
'utimestamp' => 0,
|
|
|
|
'status_changes' => 0,
|
|
|
|
'last_status' => 0
|
|
|
|
));
|
|
|
|
|
|
|
|
if ($result === false) {
|
|
|
|
process_sql_delete ('tagente_modulo',
|
|
|
|
array ('id_agente_modulo' => $id_agent_module));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $id_agent_module;
|
2009-03-18 16:42:15 +01:00
|
|
|
}
|
2009-05-19 13:32:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets all the agents that have a module with a name given.
|
|
|
|
*
|
|
|
|
* @param string Module name.
|
|
|
|
* @param int Group id of the agents. False will be any group.
|
|
|
|
* @param array Extra filter.
|
|
|
|
* @param mixed Fields to be returned. All agents field by default
|
|
|
|
*
|
|
|
|
* @return array All the agents which have a module with the name given.
|
|
|
|
*/
|
|
|
|
function get_agents_with_module_name ($module_name, $id_group, $filter = false, $fields = 'tagente.*') {
|
|
|
|
if (empty ($module_name))
|
|
|
|
return false;
|
|
|
|
if (! is_array ($filter))
|
|
|
|
$filter = array ();
|
|
|
|
$filter[] = 'tagente_modulo.id_agente = tagente.id_agente';
|
|
|
|
$filter['`tagente_modulo`.nombre'] = $module_name;
|
|
|
|
$filter['`tagente`.id_agente'] = array_keys (get_group_agents ($id_group, false, "none"));
|
|
|
|
|
|
|
|
return get_db_all_rows_filter ('tagente, tagente_modulo',
|
|
|
|
$filter, $fields);
|
|
|
|
}
|
2010-09-17 Miguel de Dios <miguel.dedios@artica.es>
* include/fgraph.php: added function "grafico_modulo_sparse_mobile" for
to paint a mobile graph.
* include/functions_db.php: erased deprecate function "dame_grupo_icono".
* include/functions_module.php: moved the functions "format_delete",
"format_time", "format_data", "format_verbatim", "format_timestamp",
"format_delete", "format_delete_string", "format_delete_log4x" from the
file "operation/agentes/datos_agente.php" for to use in other source code
places.
* operation/agentes/datos_agente.php: extracted the functions
"format_delete", "format_time", "format_data", "format_verbatim",
"format_timestamp", "format_delete", "format_delete_string",
"format_delete_log4x" to "include/functions_module.php" for to use in other
source code.
* operation/agentes/tactical.php: cleaned source code style.
* operation/agentes/group_view.php: cleaned source code style.
* mobile/operation/agents/view_agents.php: added class "viewGraph" to show
graph and data of any module.
* mobile/operation/agents/tactical.php: added first version of page to show
tactical mobile page.
* mobile/operation/agents/view_alerts.php: added first version of page to
show alerts mobile page.
* mobile/operation/agents/group_view.php: added first version of page to
show group view mobile page.
* mobile/operation/servers/view_servers.php: added first version of page to
show servers mobile page.
* mobile/include/style/main.css: added many new styles.
* mobile/include/functions_web.php: added links into menu for new pages.
* mobile/include/system.class.php: fixed scope of method "getConfig".
* mobile/index.php: added hooks for new pages.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3250 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-09-17 12:56:17 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// This are functions to format the data
|
|
|
|
//
|
|
|
|
|
|
|
|
function format_time($ts)
|
|
|
|
{
|
|
|
|
return print_timestamp ($ts, true, array("prominent" => "comparation"));
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_data($data)
|
|
|
|
{
|
|
|
|
if (is_numeric ($data)) {
|
|
|
|
$data = format_numeric($data, 2);
|
|
|
|
} else {
|
|
|
|
$data = safe_input ($data);
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_verbatim($data){
|
|
|
|
// We need to replace \n by <br> to create a "similar" output to
|
|
|
|
// information recolected in logs.
|
|
|
|
$data2 = preg_replace ("/\\n/", "<br>", $data);
|
|
|
|
return "<span style='font-size:10px;'>" . $data2 . "</span>";
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_timestamp($ts)
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
// This returns data with absolute user-defined timestamp format
|
|
|
|
// and numeric by data managed with 2 decimals, and not using Graph format
|
|
|
|
// (replacing 1000 by K and 1000000 by G, like version 2.x
|
|
|
|
return date ($config["date_format"], $ts);
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_delete($id)
|
|
|
|
{
|
|
|
|
global $period, $module_id, $config, $group;
|
|
|
|
|
|
|
|
$txt = "";
|
|
|
|
|
|
|
|
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
|
|
|
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
|
|
|
}
|
|
|
|
return $txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_delete_string($id)
|
|
|
|
{
|
|
|
|
global $period, $module_id, $config, $group;
|
|
|
|
|
|
|
|
$txt = "";
|
|
|
|
|
|
|
|
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
|
|
|
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete_string='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
|
|
|
}
|
|
|
|
return $txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_delete_log4x($id)
|
|
|
|
{
|
|
|
|
global $period, $module_id, $config, $group;
|
|
|
|
|
|
|
|
$txt = "";
|
|
|
|
|
|
|
|
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
|
|
|
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete_log4x='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
|
|
|
}
|
|
|
|
return $txt;
|
|
|
|
}
|
2009-02-16 13:18:42 +01:00
|
|
|
?>
|