2011-01-27 20:19:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
//Pandora FMS- http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
//Remember the hard-coded values
|
|
|
|
/*
|
|
|
|
-- id_modulo now uses tmodule
|
|
|
|
-- ---------------------------
|
|
|
|
-- 1 - Data server modules (agent related modules)
|
|
|
|
-- 2 - Network server modules
|
|
|
|
-- 4 - Plugin server
|
|
|
|
-- 5 - Predictive server
|
|
|
|
-- 6 - WMI server
|
|
|
|
-- 7 - WEB Server (enteprise)
|
|
|
|
|
|
|
|
In the xml is the tag "module_source"
|
|
|
|
*/
|
|
|
|
|
|
|
|
function resource_registration_extension_main() {
|
|
|
|
global $config;
|
|
|
|
|
2011-02-27 Miguel de Dios <miguel.dedios@artica.es>
* extensions/users_connected.php: fixed the double negation in the
check_acl.
* include/functions_events.php, include/functions_modules.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/functions_config.php, include/ajax/reporting.ajax.php,
include/ajax/visual_console_builder.ajax.php,
include/ajax/alert_list.ajax.php, include/help/es/modu_group_list.php,
include/fgraph.php, include/functions.php, include/functions_db.php,
include/functions_alerts.php, include/functions_reports.php,
extensions/insert_data.php, extensions/system_info.php,
extensions/pandora_logs.php, extensions/agents_modules.php,
extensions/dbmanager.php, extensions/resource_registration.php,
extensions/update_manager/settings.php, extensions/update_manager/main.php,
extensions/plugin_registration.php, operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/incidents/incident_statistics.php, operation/extensions.php,
operation/visual_console/render_view.php,
operation/visual_console/index.php, operation/agentes/status_monitor.php,
operation/agentes/export_csv.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/datos_agente.php, operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/custom_fields.php, operation/agentes/estado_agente.php,
operation/agentes/networkmap.topology.php,
operation/agentes/networkmap.groups.php, operation/agentes/sla_view.php,
operation/agentes/exportdata.php, operation/agentes/gis_view.php,
operation/agentes/estado_monitores.php, operation/agentes/ver_agente.php,
operation/agentes/graphs.php, operation/agentes/agent_fields.php,
operation/agentes/group_view.php, operation/agentes/networkmap.php,
operation/servers/view_server.php, operation/servers/view_server_detail.php,
operation/menu.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php, operation/events/event_statistics.php,
operation/events/export_csv.php, operation/events/sound_events.php,
operation/events/events_validate.php, operation/events/events_list.php,
operation/events/events_marquee.php, operation/events/events.php,
operation/search_reports.php, operation/reporting/reporting_xml.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php, operation/search_maps.php,
mobile/operation/agents/monitor_status.php,
mobile/operation/agents/view_agents.php, mobile/index.php,
general/ui/agents_list.php, godmode/groups/modu_group_list.php,
godmode/groups/configure_group.php, godmode/groups/configure_modu_group.php,
godmode/groups/group_list.php, godmode/admin_access_logs.php,
godmode/extensions.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/agentes/fields_manager.php, godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php, godmode/agentes/configurar_agente.php,
godmode/agentes/configure_field.php, godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php, godmode/servers/recon_script.php,
godmode/servers/plugin.php, godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php, godmode/menu.php,
godmode/alerts/alert_list.list.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_list.builder.php,
godmode/alerts/alert_commands.php, godmode/snmpconsole/snmp_alert.php,
godmode/snmpconsole/snmp_filters.php, godmode/setup/file_manager.php,
godmode/setup/os.list.php, godmode/setup/news.php,
godmode/setup/gis_step_2.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/setup/os.php,
godmode/setup/performance.php, godmode/setup/setup_auth.php,
godmode/setup/gis.php, godmode/setup/os.builder.php,
godmode/setup/setup_visuals.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/users/configure_profile.php,
godmode/gis_maps/configure_gis_map.php, godmode/gis_maps/index.php,
godmode/massive/massive_add_alerts.php,
godmode/massive/massive_copy_modules.php,
godmode/massive/massive_delete_agents.php,
godmode/massive/massive_operations.php,
godmode/massive/massive_edit_agents.php,
godmode/massive/massive_delete_action_alerts.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_delete_alerts.php,
godmode/massive/massive_edit_modules.php,
godmode/massive/massive_add_action_alerts.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_nc_groups_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/module_list.php,
godmode/modules/manage_network_components_form_common.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/reporting_builder.list_items.php,
godmode/reporting/graph_builder.main.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/reporting_builder.preview.php,
godmode/reporting/reporting_builder.main.php,
godmode/reporting/visual_console_builder.data.php,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/graph_builder.php,
godmode/reporting/visual_console_builder.preview.php,
godmode/reporting/graph_builder.graph_editor.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/reporting_builder.item_editor.php,
godmode/reporting/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/graph_builder.preview.php: replaced obsolete "give_acl" to
"check_acl" and erased the "give_acl".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4025 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-02-28 13:02:08 +01:00
|
|
|
if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) {
|
2011-01-27 20:19:00 +01:00
|
|
|
pandora_audit("ACL Violation", "Trying to access Setup Management");
|
|
|
|
require ("general/noaccess.php");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once($config['homedir'] . '/include/functions_network_components.php');
|
|
|
|
require_once($config['homedir'] . '/include/functions_db.php');
|
|
|
|
enterprise_include_once('include/functions_local_components.php');
|
|
|
|
|
|
|
|
print_page_header (__('Resource registration'), "images/extensions.png", false, "", true, "" );
|
|
|
|
|
|
|
|
if (!extension_loaded("libxml")) {
|
|
|
|
print_error_message(_("Error, please install the PHP libXML in the system."));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "<div class=notify>";
|
|
|
|
printf(__("This extension makes registration of resource template more easy. " .
|
|
|
|
"Here you can upload a resource template in Pandora FMS 3.x format (.ptr). " .
|
|
|
|
"Please refer to documentation on how to obtain and use Pandora FMS resources. " .
|
|
|
|
"<br><br>You can get more resurces in our <a href='%s'>Public Resource Library</a>") ,
|
|
|
|
"http://pandorafms.org/index.php?sec=community&sec2=repository&lng=en");
|
|
|
|
echo "</div>";
|
|
|
|
|
|
|
|
echo "<br /><br />";
|
|
|
|
|
|
|
|
// Upload form
|
|
|
|
echo "<form name='submit_plugin' method='post' enctype='multipart/form-data'>";
|
|
|
|
echo '<table class="databox" id="table1" width="50%" border="0" cellpadding="4" cellspacing="4">';
|
|
|
|
echo "<tr><td class='datos'><input type='file' name='resource_upload' />";
|
|
|
|
echo "<td class='datos'><input type='submit' class='sub next' value='".__('Upload')."' />";
|
|
|
|
echo "</form></table>";
|
|
|
|
|
|
|
|
if (!isset ($_FILES['resource_upload']['tmp_name'])) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$xml = simplexml_load_file($_FILES['resource_upload']['tmp_name']);
|
|
|
|
|
|
|
|
//Extract components
|
|
|
|
$components = array();
|
|
|
|
foreach ($xml->xpath('//component') as $componentElement) {
|
|
|
|
$name = safe_input((string)$componentElement->name);
|
|
|
|
$id_os = (int)$componentElement->id_os;
|
|
|
|
$os_version = safe_input((string)$componentElement->os_version);
|
|
|
|
$data = safe_input((string)$componentElement->data);
|
|
|
|
$type = (int)$componentElement->type;
|
|
|
|
$group = (int)$componentElement->group;
|
|
|
|
$description = safe_input((string)$componentElement->description);
|
|
|
|
$module_interval = (int)$componentElement->module_interval;
|
|
|
|
$max = (float)$componentElement->max;
|
|
|
|
$min = (float)$componentElement->min;
|
|
|
|
$tcp_send = safe_input((string)$componentElement->tcp_send);
|
|
|
|
$tcp_rcv_text = safe_input((string)$componentElement->tcp_rcv_text);
|
|
|
|
$tcp_port = (int)$componentElement->tcp_port;
|
|
|
|
$snmp_oid = safe_input((string)$componentElement->snmp_oid);
|
|
|
|
$snmp_community = safe_input((string)$componentElement->snmp_community);
|
|
|
|
$id_module_group = (int)$componentElement->id_module_group;
|
|
|
|
$module_source = (int)$componentElement->module_source;
|
|
|
|
$plugin = (int)$componentElement->plugin;
|
|
|
|
$plugin_username = safe_input((string)$componentElement->plugin_username);
|
|
|
|
$plugin_password = safe_input((string)$componentElement->plugin_password);
|
|
|
|
$plugin_parameters = safe_input((string)$componentElement->plugin_parameters);
|
|
|
|
$max_timeout = (int)$componentElement->max_timeout;
|
|
|
|
$historical_data = (int)$componentElement->historical_data;
|
|
|
|
$min_war = (float)$componentElement->min_war;
|
|
|
|
$max_war = (float)$componentElement->max_war;
|
|
|
|
$min_cri = (float)$componentElement->min_cri;
|
|
|
|
$max_cri = (float)$componentElement->max_cri;
|
|
|
|
$ff_treshold = (int)$componentElement->ff_treshold;
|
|
|
|
$snmp_version = (int)$componentElement->snmp_version;
|
|
|
|
$auth_user = safe_input((string)$componentElement->auth_user);
|
|
|
|
$auth_password = safe_input((string)$componentElement->auth_password);
|
|
|
|
$auth_method = safe_input((string)$componentElement->auth_method);
|
|
|
|
$privacy_method = safe_input((string)$componentElement->privacy_method);
|
|
|
|
$privacy_pass = safe_input((string)$componentElement->privacy_pass);
|
|
|
|
$security_level = safe_input((string)$componentElement->security_level);
|
|
|
|
$wmi_query = safe_input((string)$componentElement->wmi_query);
|
|
|
|
$key_string = safe_input((string)$componentElement->key_string);
|
|
|
|
$field_number = (int)$componentElement->field_number;
|
|
|
|
$namespace = safe_input((string)$componentElement->namespace);
|
|
|
|
$wmi_user = safe_input((string)$componentElement->wmi_user);
|
|
|
|
$wmi_password = safe_input((string)$componentElement->wmi_password);
|
2011-02-09 15:16:27 +01:00
|
|
|
$post_process = safe_input((float)$componentElement->post_process);
|
2011-01-27 20:19:00 +01:00
|
|
|
|
|
|
|
$idComponent = false;
|
|
|
|
switch ((int)$componentElement->module_source) {
|
|
|
|
case 1: //Local component
|
|
|
|
$values = array('description' => $description,
|
|
|
|
'id_network_component_group' => $group,
|
|
|
|
'os_version' => $os_version);
|
|
|
|
$return = enterprise_hook('create_local_component', array($name, $data, $id_os, $values));
|
|
|
|
if ($return !== ENTERPRISE_NOT_HOOK) {
|
|
|
|
$idComponent = $return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: //Network component
|
|
|
|
|
|
|
|
//for modules
|
|
|
|
//15 = remote_snmp, 16 = remote_snmp_inc,
|
|
|
|
//17 = remote_snmp_string, 18 = remote_snmp_proc
|
|
|
|
$custom_string_1 = '';
|
|
|
|
$custom_string_2 = '';
|
|
|
|
$custom_string_3 = '';
|
|
|
|
if ($type >= 15 && $type <= 18) {
|
|
|
|
// New support for snmp v3
|
|
|
|
$tcp_send = $snmp_version;
|
|
|
|
$plugin_user = $auth_user;
|
|
|
|
$plugin_pass = $auth_password;
|
|
|
|
$plugin_parameter = $auth_method;
|
|
|
|
$custom_string_1 = $privacy_method;
|
|
|
|
$custom_string_2 = $privacy_pass;
|
|
|
|
$custom_string_3 = $security_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
$idComponent = create_network_component ($name,
|
|
|
|
$type, $group,
|
|
|
|
array ('description' => $description,
|
|
|
|
'module_interval' => $module_interval,
|
|
|
|
'max' => $max,
|
|
|
|
'min' => $min,
|
|
|
|
'tcp_send' => $tcp_send,
|
|
|
|
'tcp_rcv' => $tcp_rcv_text,
|
|
|
|
'tcp_port' => $tcp_port,
|
|
|
|
'snmp_oid' => $snmp_oid,
|
|
|
|
'snmp_community' => $snmp_community,
|
|
|
|
'id_module_group' => $id_module_group,
|
|
|
|
'id_modulo' => $module_source,
|
|
|
|
'id_plugin' => $plugin,
|
|
|
|
'plugin_user' => $plugin_username,
|
|
|
|
'plugin_pass' => $plugin_password,
|
|
|
|
'plugin_parameter' => $plugin_parameters,
|
|
|
|
'max_timeout' => $max_timeout,
|
|
|
|
'history_data' => $historical_data,
|
|
|
|
'min_warning' => $min_war,
|
|
|
|
'max_warning' => $max_war,
|
|
|
|
'min_critical' => $min_cri,
|
|
|
|
'max_critical' => $max_cri,
|
|
|
|
'min_ff_event' => $ff_treshold,
|
|
|
|
'custom_string_1' => $custom_string_1,
|
|
|
|
'custom_string_2' => $custom_string_2,
|
2011-02-09 15:16:27 +01:00
|
|
|
'custom_string_3' => $custom_string_3,
|
|
|
|
'post_process' => $post_process));
|
2011-01-27 20:19:00 +01:00
|
|
|
if ((bool)$idComponent) {
|
|
|
|
$components[] = $idComponent;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4: //Plugin component
|
|
|
|
$idComponent = create_network_component ($name,
|
|
|
|
$type, $group,
|
|
|
|
array ('description' => $description,
|
|
|
|
'module_interval' => $module_interval,
|
|
|
|
'max' => $max,
|
|
|
|
'min' => $min,
|
|
|
|
'tcp_send' => $tcp_send,
|
|
|
|
'tcp_rcv' => $tcp_rcv_text,
|
|
|
|
'tcp_port' => $tcp_port,
|
|
|
|
'snmp_oid' => $snmp_oid,
|
|
|
|
'snmp_community' => $snmp_community,
|
|
|
|
'id_module_group' => $id_module_group,
|
|
|
|
'id_modulo' => $module_source,
|
|
|
|
'id_plugin' => $plugin,
|
|
|
|
'plugin_user' => $plugin_username,
|
|
|
|
'plugin_pass' => $plugin_password,
|
|
|
|
'plugin_parameter' => $plugin_parameters,
|
|
|
|
'max_timeout' => $max_timeout,
|
|
|
|
'history_data' => $historical_data,
|
|
|
|
'min_warning' => $min_war,
|
|
|
|
'max_warning' => $max_war,
|
|
|
|
'min_critical' => $min_cri,
|
|
|
|
'max_critical' => $max_cri,
|
|
|
|
'min_ff_event' => $ff_treshold,
|
|
|
|
'custom_string_1' => $custom_string_1,
|
|
|
|
'custom_string_2' => $custom_string_2,
|
2011-02-09 15:16:27 +01:00
|
|
|
'custom_string_3' => $custom_string_3,
|
|
|
|
'post_process' => $post_process));
|
2011-01-27 20:19:00 +01:00
|
|
|
if ((bool)$idComponent) {
|
|
|
|
$components[] = $idComponent;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5: //Prediction component
|
|
|
|
break;
|
|
|
|
case 6: //WMI component
|
|
|
|
$idComponent = create_network_component ($name,
|
|
|
|
$type, $group,
|
|
|
|
array ('description' => $description,
|
|
|
|
'module_interval' => $module_interval,
|
|
|
|
'max' => $max,
|
|
|
|
'min' => $min,
|
|
|
|
'tcp_send' => $namespace, //work around
|
|
|
|
'tcp_rcv' => $tcp_rcv_text,
|
|
|
|
'tcp_port' => $field_number, //work around
|
|
|
|
'snmp_oid' => $wmi_query, //work around
|
|
|
|
'snmp_community' => $key_string, //work around
|
|
|
|
'id_module_group' => $id_module_group,
|
|
|
|
'id_modulo' => $module_source,
|
|
|
|
'id_plugin' => $plugin,
|
|
|
|
'plugin_user' => $wmi_user, //work around
|
|
|
|
'plugin_pass' => $wmi_password, //work around
|
|
|
|
'plugin_parameter' => $plugin_parameters,
|
|
|
|
'max_timeout' => $max_timeout,
|
|
|
|
'history_data' => $historical_data,
|
|
|
|
'min_warning' => $min_war,
|
|
|
|
'max_warning' => $max_war,
|
|
|
|
'min_critical' => $min_cri,
|
|
|
|
'max_critical' => $max_cri,
|
|
|
|
'min_ff_event' => $ff_treshold,
|
|
|
|
'custom_string_1' => $custom_string_1,
|
|
|
|
'custom_string_2' => $custom_string_2,
|
2011-02-09 15:16:27 +01:00
|
|
|
'custom_string_3' => $custom_string_3,
|
|
|
|
'post_process' => $post_process));
|
2011-01-27 20:19:00 +01:00
|
|
|
if ((bool)$idComponent) {
|
|
|
|
$components[] = $idComponent;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7: //Web component
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_result_message((bool)$idComponent, sprintf(__("Success create '%s' component."), $name),
|
|
|
|
sprintf(__("Error create '%s' component."), $name));
|
|
|
|
}
|
|
|
|
|
|
|
|
//Extract the template
|
|
|
|
|
|
|
|
$templateElement = $xml->xpath('//template');
|
|
|
|
if (!empty($templateElement)) {
|
|
|
|
$templateElement = $templateElement[0];
|
|
|
|
|
|
|
|
$templateName = (string)$templateElement->name;
|
|
|
|
$templateDescription = (string)$templateElement->description;
|
|
|
|
|
|
|
|
$idTemplate = process_sql_insert('tnetwork_profile', array('name' => $templateName, 'description' => $templateDescription));
|
|
|
|
|
|
|
|
$result = false;
|
|
|
|
if ((bool)$idTemplate) {
|
|
|
|
foreach ($components as $idComponent) {
|
|
|
|
process_sql_insert("tnetwork_profile_component", array('id_nc' => $idComponent, 'id_np' => $idTemplate));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
add_godmode_menu_option (__('Resource registration'), 'PM','gservers','');
|
|
|
|
add_extension_godmode_function('resource_registration_extension_main');
|
|
|
|
?>
|