2009-05-21 13:00:50 +02: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-05-21 13:00:50 +02: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-05-21 13:00:50 +02: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-06-08 20:26:14 +02:00
|
|
|
|
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-05-21 13:00:50 +02:00
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Include modules functions
|
|
|
|
*/
|
2009-05-21 13:00:50 +02:00
|
|
|
require_once ('include/functions_modules.php');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of network components.
|
|
|
|
*
|
|
|
|
* @param int Module type id of the requested components.
|
|
|
|
* @param mixed Aditional filters to the components. It can be an indexed array
|
|
|
|
* (keys would be the field name and value the expected value, and would be
|
|
|
|
* joined with an AND operator). Examples:
|
|
|
|
<code>
|
|
|
|
$components = get_network_components ($id_module, array ('id_module_group', 10));
|
|
|
|
$components = get_network_components ($id_module, 'id_module_group = 10'));
|
|
|
|
</code>
|
|
|
|
* @param mixed Fields to retrieve on each component.
|
|
|
|
*
|
|
|
|
* @return array A list of network components matching. Empty array is returned
|
|
|
|
* if none matches.
|
|
|
|
*/
|
|
|
|
function get_network_components ($id_module, $filter = false, $fields = false) {
|
|
|
|
if (! is_array ($filter))
|
|
|
|
$filter = array ();
|
|
|
|
if (! empty ($id_module))
|
|
|
|
$filter['id_modulo'] = (int) $id_module;
|
|
|
|
|
|
|
|
$components = get_db_all_rows_filter ('tnetwork_component',
|
|
|
|
$filter, $fields);
|
|
|
|
if ($components === false)
|
|
|
|
return array ();
|
|
|
|
return $components;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of a network components group.
|
|
|
|
*
|
|
|
|
* @param int Network components group id.
|
|
|
|
*
|
|
|
|
* @return string The name of the components group.
|
|
|
|
*/
|
|
|
|
function get_network_component_group_name ($id_network_component_group) {
|
|
|
|
if (empty ($id_network_component_group))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return @get_db_value ('name', 'tnetwork_component_group', 'id_sg', $id_network_component_group);
|
|
|
|
}
|
|
|
|
|
2009-05-25 15:29:48 +02:00
|
|
|
/**
|
|
|
|
* Get a network component group.
|
|
|
|
*
|
|
|
|
* @param int Group id to be fetched.
|
|
|
|
* @param array Extra filter.
|
|
|
|
* @param array Fields to be fetched.
|
|
|
|
*
|
|
|
|
* @return array A network component group matching id and filter.
|
|
|
|
*/
|
|
|
|
function get_network_component_group ($id_network_component_group, $filter = false, $fields = false) {
|
|
|
|
if (empty ($id_network_component_group))
|
|
|
|
return false;
|
|
|
|
if (! is_array ($filter))
|
|
|
|
$filter = array ();
|
|
|
|
$filter['id_sg'] = (int) $id_network_component_group;
|
|
|
|
|
|
|
|
return get_db_row_filter ('tnetwork_component_group', $filter, $fields);
|
|
|
|
}
|
|
|
|
|
2009-05-21 13:00:50 +02:00
|
|
|
/**
|
|
|
|
* Get a list of network component groups.
|
|
|
|
*
|
|
|
|
* The values returned can be passed directly to print_select(). Child groups
|
|
|
|
* are indented, so ordering on print_select() is NOT recommendable.
|
|
|
|
*
|
2009-09-09 14:24:41 +02:00
|
|
|
* @param int id_module_components If provided, groups must have at least one component
|
|
|
|
* of the module provided. Parents will be included in that case even if they don't have
|
2009-05-21 13:00:50 +02:00
|
|
|
* components directly.
|
2009-09-09 14:24:41 +02:00
|
|
|
*
|
|
|
|
* @param bool localComponent expecial comportation for local component.
|
2009-05-21 13:00:50 +02:00
|
|
|
*
|
|
|
|
* @return array An ordered list of component groups with childs indented.
|
|
|
|
*/
|
2009-09-09 14:24:41 +02:00
|
|
|
function get_network_component_groups ($id_module_components = 0, $localComponent = false) {
|
2009-05-21 13:00:50 +02:00
|
|
|
/* Special vars to keep track of indentation level */
|
|
|
|
static $level = 0;
|
|
|
|
static $id_parent = 0;
|
|
|
|
|
|
|
|
$groups = get_db_all_rows_filter ('tnetwork_component_group',
|
|
|
|
array ('parent' => $id_parent),
|
|
|
|
array ('id_sg', 'name'));
|
|
|
|
if ($groups === false)
|
|
|
|
return array ();
|
|
|
|
|
|
|
|
$retval = array ();
|
|
|
|
/* Magic indentation is here */
|
|
|
|
$prefix = str_repeat (' ', $level * 3);
|
|
|
|
foreach ($groups as $group) {
|
|
|
|
$level++;
|
|
|
|
$tmp = $id_parent;
|
|
|
|
$id_parent = (int) $group['id_sg'];
|
2009-09-09 14:24:41 +02:00
|
|
|
$childs = get_network_component_groups ($id_module_components, $localComponent);
|
2009-05-21 13:00:50 +02:00
|
|
|
$id_parent = $tmp;
|
|
|
|
$level--;
|
|
|
|
|
2009-09-09 14:24:41 +02:00
|
|
|
if ($localComponent) {
|
|
|
|
if (! empty ($childs)) {
|
|
|
|
$retval[$group['id_sg']] = $prefix.$group['name'];
|
|
|
|
$retval = $retval + $childs;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$count = get_db_value_filter ('COUNT(*)', 'tlocal_component',
|
|
|
|
array ('id_network_component_group' => (int) $group['id_sg']));
|
|
|
|
|
2009-05-21 13:00:50 +02:00
|
|
|
if ($count > 0)
|
|
|
|
$retval[$group['id_sg']] = $prefix.$group['name'];
|
|
|
|
}
|
|
|
|
}
|
2009-09-09 14:24:41 +02:00
|
|
|
else {
|
|
|
|
|
|
|
|
if (! empty ($childs) || $id_module_components == 0) {
|
|
|
|
$retval[$group['id_sg']] = $prefix.$group['name'];
|
|
|
|
$retval = $retval + $childs;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* If components id module is provided, only groups with components
|
|
|
|
that belongs to this id module are returned */
|
|
|
|
if ($id_module_components) {
|
|
|
|
$count = get_db_value_filter ('COUNT(*)', 'tnetwork_component',
|
|
|
|
array ('id_group' => (int) $group['id_sg'],
|
|
|
|
'id_modulo' => $id_module_components));
|
|
|
|
if ($count > 0)
|
|
|
|
$retval[$group['id_sg']] = $prefix.$group['name'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-05-21 13:00:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a network component.
|
|
|
|
*
|
|
|
|
* @param int Component id to be fetched.
|
|
|
|
* @param array Extra filter.
|
|
|
|
* @param array Fields to be fetched.
|
|
|
|
*
|
|
|
|
* @return array A network component matching id and filter.
|
|
|
|
*/
|
|
|
|
function get_network_component ($id_network_component, $filter = false, $fields = false) {
|
|
|
|
if (empty ($id_network_component))
|
|
|
|
return false;
|
|
|
|
if (! is_array ($filter))
|
|
|
|
$filter = array ();
|
|
|
|
$filter['id_nc'] = (int) $id_network_component;
|
|
|
|
|
|
|
|
return get_db_row_filter ('tnetwork_component', $filter, $fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a network component.
|
|
|
|
*
|
|
|
|
* @param string Component name.
|
|
|
|
* @param string Component type.
|
|
|
|
* @param string Component group id.
|
|
|
|
* @param array Extra values to be set.
|
|
|
|
*
|
|
|
|
* @return int New component id. False on error.
|
|
|
|
*/
|
|
|
|
function create_network_component ($name, $type, $id_group, $values = false) {
|
|
|
|
if (empty ($name))
|
|
|
|
return false;
|
|
|
|
if (empty ($type))
|
|
|
|
return false;
|
|
|
|
if (! is_array ($values))
|
|
|
|
$values = array ();
|
|
|
|
$values['name'] = $name;
|
|
|
|
$values['type'] = (int) $type;
|
|
|
|
$values['id_group'] = (int) $id_group;
|
|
|
|
|
|
|
|
return @process_sql_insert ('tnetwork_component',
|
|
|
|
$values);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates a network component.
|
|
|
|
*
|
|
|
|
* @param int Component id.
|
|
|
|
* @param array Values to be set.
|
|
|
|
*
|
|
|
|
* @return bool True if updated. False on error.
|
|
|
|
*/
|
|
|
|
function update_network_component ($id_network_component, $values = false) {
|
|
|
|
if (empty ($id_network_component))
|
|
|
|
return false;
|
|
|
|
$component = get_network_component ($id_network_component);
|
|
|
|
if (empty ($component))
|
|
|
|
return false;
|
|
|
|
if (! is_array ($values))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return (@process_sql_update ('tnetwork_component',
|
|
|
|
$values,
|
|
|
|
array ('id_nc' => (int) $id_network_component)) !== false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a network component.
|
|
|
|
*
|
|
|
|
* @param int Component id.
|
|
|
|
* @param array Extra filter.
|
|
|
|
*
|
|
|
|
* @return bool True if deleted. False on error.
|
|
|
|
*/
|
|
|
|
function delete_network_component ($id_network_component) {
|
|
|
|
if (empty ($id_network_component))
|
|
|
|
return false;
|
|
|
|
$filter = array ();
|
|
|
|
$filter['id_nc'] = $id_network_component;
|
|
|
|
|
|
|
|
@process_sql_delete ('tnetwork_profile_component', $filter);
|
|
|
|
|
|
|
|
return (@process_sql_delete ('tnetwork_component', $filter) !== false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a module in an agent from a network component.
|
|
|
|
*
|
|
|
|
* @param int Component id to be created.
|
|
|
|
* @param int Agent id to create module in.
|
|
|
|
*
|
|
|
|
* @return array New agent module id if created. False if could not be created
|
|
|
|
*/
|
|
|
|
function create_agent_module_from_network_component ($id_network_component, $id_agent) {
|
|
|
|
if (! user_access_to_agent ($id_agent, 'AW'))
|
|
|
|
return false;
|
|
|
|
$component = get_network_component ($id_network_component,
|
|
|
|
false,
|
|
|
|
array ('name',
|
|
|
|
'description AS descripcion',
|
|
|
|
'type AS id_tipo_modulo',
|
|
|
|
'max',
|
|
|
|
'min',
|
|
|
|
'module_interval',
|
|
|
|
'tcp_port',
|
|
|
|
'tcp_send',
|
|
|
|
'tcp_rcv',
|
|
|
|
'snmp_community',
|
|
|
|
'snmp_oid',
|
|
|
|
'id_module_group',
|
|
|
|
'id_modulo',
|
|
|
|
'plugin_user',
|
|
|
|
'plugin_pass',
|
|
|
|
'plugin_parameter',
|
|
|
|
'max_timeout',
|
|
|
|
'history_data',
|
|
|
|
'min_warning',
|
|
|
|
'max_warning',
|
|
|
|
'min_critical',
|
|
|
|
'max_critical',
|
|
|
|
'min_ff_event'));
|
|
|
|
if (empty ($component))
|
|
|
|
return false;
|
|
|
|
$values = $component;
|
|
|
|
$len = count ($values) / 2;
|
|
|
|
for ($i = 0; $i < $len; $i++)
|
|
|
|
unset ($values[$i]);
|
|
|
|
$name = $values['name'];
|
|
|
|
unset ($values['name']);
|
|
|
|
$values['ip_target'] = get_agent_address ($id_agent);
|
|
|
|
|
|
|
|
return create_agent_module ($id_agent, $name, $values);
|
|
|
|
}
|
2009-09-22 22:52:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of a network component.
|
|
|
|
*
|
|
|
|
* @param int Component id to get.
|
|
|
|
*
|
|
|
|
* @return Component name with the given id. False if not available or readable.
|
|
|
|
*/
|
|
|
|
function get_network_component_name ($id_network_component) {
|
|
|
|
if (empty ($id_network_component))
|
|
|
|
return false;
|
|
|
|
return @get_db_value ('name', 'tnetwork_component', 'id', $id_network_component);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Duplicate local compoment.
|
|
|
|
* @param integer id_local_component Id of localc component for duplicate.
|
|
|
|
*/
|
|
|
|
function duplicate_network_component ($id_local_component) {
|
|
|
|
$network = get_network_component ($id_local_component);
|
|
|
|
|
|
|
|
if ($network === false)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
$name = __('Copy of').' '.$network['name'];
|
|
|
|
|
|
|
|
$networkCopy['description'] = $network['description'];
|
|
|
|
$networkCopy['max'] = $network['max'];
|
|
|
|
$networkCopy['min'] = $network['min'];
|
|
|
|
$networkCopy['module_interval'] = $network['module_interval'];
|
|
|
|
$networkCopy['tcp_port'] = $network['tcp_port'];
|
|
|
|
$networkCopy['tcp_send'] = $network['tcp_send'];
|
|
|
|
$networkCopy['tcp_rcv'] = $network['tcp_rcv'];
|
|
|
|
$networkCopy['snmp_community'] = $network['snmp_community'];
|
|
|
|
$networkCopy['snmp_oid'] = $network['snmp_oid'];
|
|
|
|
$networkCopy['id_module_group'] = $network['id_module_group'];
|
|
|
|
$networkCopy['id_modulo'] = $network['id_modulo'];
|
|
|
|
$networkCopy['id_plugin'] = $network['id_plugin'];
|
|
|
|
$networkCopy['plugin_user'] = $network['plugin_user'];
|
|
|
|
$networkCopy['plugin_pass'] = $network['plugin_pass'];
|
|
|
|
$networkCopy['plugin_parameter'] = $network['plugin_parameter'];
|
|
|
|
$networkCopy['max_timeout'] = $network['max_timeout'];
|
|
|
|
$networkCopy['history_data'] = $network['history_data'];
|
|
|
|
$networkCopy['min_warning'] = $network['min_warning'];
|
|
|
|
$networkCopy['max_warning'] = $network['max_warning'];
|
|
|
|
$networkCopy['min_critical'] = $network['min_critical'];
|
|
|
|
$networkCopy['max_critical'] = $network['max_critical'];
|
|
|
|
$networkCopy['min_ff_event'] = $network['min_ff_event'];
|
|
|
|
|
|
|
|
return create_network_component ($name, $network['type'], $network['id_group'], $networkCopy);
|
|
|
|
}
|
2009-05-21 13:00:50 +02:00
|
|
|
?>
|