2009-05-27 Esteban Sanchez <estebans@artica.es>

* godmode/agentes/configurar_agente.php: Use pandora functions to
	create and update modules. Some fixes when these operations could
	not be done so the editor appears again. Fixes #2762316

	* godmode/agentes/module_manager_editor.php: Some patches to work
	better with configurar_agente.php

	* include/functions_modules.php: Avoid setting an empty name on
	update_agent_module()



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1711 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2009-05-27 10:31:27 +00:00
parent 6803432b1e
commit 1ca3064760
4 changed files with 67 additions and 62 deletions

View File

@ -1,3 +1,15 @@
2009-05-27 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php: Use pandora functions to
create and update modules. Some fixes when these operations could
not be done so the editor appears again. Fixes #2762316
* godmode/agentes/module_manager_editor.php: Some patches to work
better with configurar_agente.php
* include/functions_modules.php: Avoid setting an empty name on
update_agent_module()
2009-05-27 Esteban Sanchez <estebans@artica.es>
* reporting/fgraph.php: Do not short agent name on

View File

@ -33,9 +33,11 @@ if (! give_acl ($config["id_user"], $group, "AW")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
"Trying to access agent manager");
require ("general/noaccess.php");
exit;
return;
}
require_once ('include/functions_modules.php');
// Get passed variables
$tab = get_parameter ('tab', 'main');
$alerttype = get_parameter ('alerttype');
@ -372,8 +374,8 @@ if ($update_module || $create_module) {
$post_process = (float) get_parameter ('post_process');
$prediction_module = (int) get_parameter ('prediction_module');
$max_timeout = (int) get_parameter ('max_timeout');
$minvalue = (int) get_parameter_post ("min");
$maxvalue = (int) get_parameter ('max');
$min = (int) get_parameter_post ("min");
$max = (int) get_parameter ('max');
$interval = (int) get_parameter ('module_interval', $intervalo);
$id_prediction_module = (int) get_parameter ('id_prediction_module');
$id_plugin = (int) get_parameter ('id_plugin');
@ -405,12 +407,12 @@ if ($update_module || $create_module) {
if ($update_module) {
$id_agent_module = (int) get_parameter ('id_agent_module');
$result = process_sql_update ('tagente_modulo',
$result = update_agent_module ($id_agent_module,
array ('descripcion' => $description,
'id_module_group' => $id_module_group,
'nombre' => $name,
'max' => $maxvalue,
'min' => $minvalue,
'max' => $max,
'min' => $min,
'module_interval' => $interval,
'tcp_port' => $tcp_port,
'tcp_send' => $tcp_send,
@ -434,12 +436,11 @@ if ($update_module) {
'max_warning' => $max_warning,
'min_critical' => $min_critical,
'max_critical' => $max_critical,
'min_ff_event' => $ff_event
),
'id_agente_modulo = '.$id_agent_module);
'min_ff_event' => $ff_event));
if ($result === false) {
echo '<h3 class="error">'.__('There was a problem updating module').'</h3>';
$edit_module = true;
} else {
echo '<h3 class="suc">'.__('Module successfully updated').'</h3>';
$id_agent_module = false;
@ -458,13 +459,11 @@ if ($create_module) {
$id_module = (int) get_parameter ('id_module');
$id_agent_module = process_sql_insert ('tagente_modulo',
array ('id_agente' => $id_agente,
'id_tipo_modulo' => $id_module_type,
'nombre' => $name,
$id_agent_module = create_agent_module ($id_agente, $name,
array ('id_tipo_modulo' => $id_module_type,
'descripcion' => $description,
'max' => $maxvalue,
'min' => $minvalue,
'max' => $max,
'min' => $min,
'snmp_oid' => $snmp_oid,
'snmp_community' => $snmp_community,
'id_module_group' => $id_module_group,
@ -495,19 +494,9 @@ if ($create_module) {
if ($id_agent_module === false) {
echo '<h3 class="error">'.__('There was a problem adding module').'</h3>';
$edit_module = true;
$moduletype = $id_module;
} else {
$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' => $id_agente,
'utimestamp' => 0, 'status_changes' => 0,
'last_status' => 0
));
if ($result !== false) {
echo '<h3 class="suc">'.__('Module added successfully').'</h3>';
} else {
echo '<h3 class="error">'.__('Module added successfully').' - '.__('Status init unsuccessful').'</h3>';
}
echo '<h3 class="suc">'.__('Module added successfully').'</h3>';
$id_agent_module = false;
$edit_module = false;
}

View File

@ -113,42 +113,44 @@ if ($id_agent_module) {
$max_critical = $module['max_critical'];
$ff_event = $module['min_ff_event'];
} else {
$moduletype = (string) get_parameter ('moduletype');
if (!isset ($moduletype)) {
$moduletype = (string) get_parameter ('moduletype');
// Clean up specific network modules fields
$name = '';
$description = '';
$id_module_group = 1;
$id_module_type = 1;
$post_process = '';
$max_timeout = '';
$min = '';
$max = '';
$interval = '';
$prediction_module = '';
$id_plugin = '';
$id_export = '';
$disabled = "0";
$tcp_send = '';
$tcp_rcv = '';
$tcp_port = '';
// Clean up specific network modules fields
$name = '';
$description = '';
$id_module_group = 1;
$id_module_type = 1;
$post_process = '';
$max_timeout = '';
$min = '';
$max = '';
$interval = '';
$prediction_module = '';
$id_plugin = '';
$id_export = '';
$disabled = "0";
$tcp_send = '';
$tcp_rcv = '';
$tcp_port = '';
if ($moduletype == "wmiserver")
$snmp_community = '';
else
$snmp_community = "public";
$snmp_oid = '';
$ip_target = get_agent_address ($id_agente);
$plugin_user = '';
$plugin_pass = '';
$plugin_parameter = '';
$custom_id = '';
$history_data = 1;
$min_warning = 0;
$max_warning = 0;
$min_critical = 0;
$max_critical = 0;
$ff_event = 0;
if ($moduletype == "wmiserver")
$snmp_community = '';
else
$snmp_community = "public";
$snmp_oid = '';
$ip_target = get_agent_address ($id_agente);
$plugin_user = '';
$plugin_pass = '';
$plugin_parameter = '';
$custom_id = '';
$history_data = 1;
$min_warning = 0;
$max_warning = 0;
$min_critical = 0;
$max_critical = 0;
$ff_event = 0;
}
}
switch ($moduletype) {

View File

@ -108,6 +108,8 @@ function delete_agent_module ($id_agent_module) {
function update_agent_module ($id, $values) {
if (! is_array ($values))
return false;
if (! isset ($values['nombre']) && empty ($values['nombre']))
return false;
return (@process_sql_update ('tagente_modulo', $values,
array ('id_agente_modulo' => (int) $id)) !== false);