2013-02-14 Sergio Martin <sergio.martin@artica.es>

* pandoradb_data.sql: Fixed the macros of the
	default plugin MySQL

	* include/functions_groups.php
	include/functions_api.php
	include/functions_ui.php
	include/functions_agents.php
	include/functions_modules.php
	include/constants.php
	operation/agentes/estado_ultimopaquete.php
	godmode/db/db_sanity.php
	godmode/agentes/agent_template.php
	godmode/agentes/configurar_agente.php
	godmode/servers/plugin.php: Create a function to disable
	modules fixing the status counts and replace the old way of
	do it in all the console. Fixin a lot of old way of create 
	and delete modules too to use the centralized function and 
	dont break counts. BUG 3604463



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7651 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2013-02-14 12:55:53 +00:00
parent b0823dd5db
commit cd7b81f1a9
13 changed files with 229 additions and 201 deletions

View File

@ -1,3 +1,24 @@
2013-02-14 Sergio Martin <sergio.martin@artica.es>
* pandoradb_data.sql: Fixed the macros of the
default plugin MySQL
* include/functions_groups.php
include/functions_api.php
include/functions_ui.php
include/functions_agents.php
include/functions_modules.php
include/constants.php
operation/agentes/estado_ultimopaquete.php
godmode/db/db_sanity.php
godmode/agentes/agent_template.php
godmode/agentes/configurar_agente.php
godmode/servers/plugin.php: Create a function to disable
modules fixing the status counts and replace the old way of
do it in all the console. Fixin a lot of old way of create
and delete modules too to use the centralized function and
dont break counts. BUG 3604463
2013-02-14 Miguel de Dios <miguel.dedios@artica.es>
* include/constants.php: added constant for module type of

View File

@ -66,7 +66,6 @@ if (isset ($_POST["template_id"])) {
'id_agente' => $id_agente,
'id_tipo_modulo' => $row2["type"],
'descripcion' => __('Created by template ').$name_template. ' . '.$row2["description"],
'nombre' => $row2["name"],
'max' => $row2["max"],
'min' => $row2["min"],
'module_interval' => $row2["module_interval"],
@ -98,47 +97,21 @@ if (isset ($_POST["template_id"])) {
'unknown_instructions' => $row2['unknown_instructions']
);
$name = $row2["name"];
// Check if this module exists in the agent
$module_name_check = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('delete_pending' => 0, 'nombre' => $row2["name"], 'id_agente' => $id_agente));
$module_name_check = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('delete_pending' => 0, 'nombre' => $name, 'id_agente' => $id_agente));
if ($module_name_check !== false) {
$modules_already_added[] = $row2["name"];
$error_count++;
}
else {
$id_agente_modulo = modules_create_agent_module($id_agente, $name, $values);
$id_agente_modulo = db_process_sql_insert('tagente_modulo', $values);
// Set the initial module status
if ($row2["type"] == 21 || $row2["type"] == 22 || $row2["type"] == 23) {
$status = 0;
}
else {
$status = 4;
}
// Create with different estado if proc type or data type
if ($id_agente_modulo !== false) {
$success_count++;
$values = array(
'id_agente_modulo' => $id_agente_modulo,
'datos' => 0,
'timestamp' => '01-01-1970 00:00:00',
'estado' => $status,
'id_agente' => $id_agente,
'utimestamp' => 0);
db_process_sql_insert('tagente_estado', $values);
// Update module status count
if ($status == 4) {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=' . (int)$id_agente);
}
else {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=' . (int)$id_agente);
}
}
else
if ($id_agente_modulo === false) {
$error_count++;
}
}
}
}

View File

@ -1234,9 +1234,9 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
// MODULE ENABLE/DISABLE
// =====================
if($enable_module) {
$result = db_process_sql_update('tagente_modulo', array('disabled' => 0), array('id_agente_modulo' => $enable_module));
$result = modules_change_disabled($enable_module, 0);
if ($result) {
if ($result === NOERR) {
db_pandora_audit("Module management", 'Enable ' . $enable_module);
}
else {
@ -1248,9 +1248,9 @@ if($enable_module) {
}
if($disable_module) {
$result = db_process_sql_update('tagente_modulo', array('disabled' => 1), array('id_agente_modulo' => $disable_module));
$result = modules_change_disabled($disable_module, 1);
if ($result) {
if ($result === NOERR) {
db_pandora_audit("Module management", 'Disable ' . $disable_module);
}
else {

View File

@ -93,9 +93,14 @@ elseif ($sanity == 2) {
modules_delete_agent_module($row['id_agente_modulo']);
}
echo "Deleting bad module (id 0)<br>";
db_process_sql_delete('tagente_modulo', array('id_modulo' => 0));
$bad_modules = db_get_all_rows_filter('tagente_modulo', array('id_modulo' => 0));
foreach($bad_modules as $bm) {
modules_delete_agent_module ($bm['id_agente_modulo']);
}
}
echo "<br>";

View File

@ -416,7 +416,12 @@ else {
echo "<h3 class='suc'>".__('Plugin deleted successfully')."</h3>";
}
if ($plugin_id != 0) {
$result = db_process_sql_delete('tagente_modulo', array('id_plugin' => $plugin_id));
// Delete all the modules with this plugin
$plugin_modules = db_get_all_rows_filter('tagente_modulo', array('id_plugin' => $plugin_id));
foreach($plugin_modules as $pm) {
modules_delete_agent_module ($pm['id_agente_modulo']);
}
}
}
@ -454,7 +459,7 @@ else {
echo $row["execute"];
echo "</td><td class=$tdcolor>";
echo "<a href='index.php?sec=$sec&sec2=godmode/servers/plugin&view=".$row["id"]."&tab=plugins&pure=" . $config['pure'] . "'>" . html_print_image('images/config.png', true, array("title" => __("Edit"))) . "</a>&nbsp;&nbsp;";
echo "<a href='index.php?sec=$sec&sec2=godmode/servers/plugin&kill_plugin=".$row["id"]."&tab=plugins&pure=" . $config['pure'] . "'>" . html_print_image("images/cross.png", true, array("border" => '0')) . "</a>";
echo "<a href='index.php?sec=$sec&sec2=godmode/servers/plugin&kill_plugin=".$row["id"]."&tab=plugins&pure=" . $config['pure'] . "' onclick='javascript: if (!confirm(\"" . __('All the modules that are using this plugin will be deleted') . '. ' . __('Are you sure?') . "\")) return false;'>" . html_print_image("images/cross.png", true, array("border" => '0')) . "</a>";
echo "</td></tr>";
}
echo "</table>";

View File

@ -131,7 +131,8 @@ define('GENERIC_SIZE_TEXT', 25);
/* Agent module status */
define('AGENT_MODULE_STATUS_CRITICAL_BAD', 1);
define('AGENT_MODULE_STATUS_CRITICAL_ALERT', 4);
define('AGENT_MODULE_STATUS_CRITICAL_ALERT', 100);
define('AGENT_MODULE_STATUS_NO_DATA', 4);
define('AGENT_MODULE_STATUS_NORMAL', 0);
define('AGENT_MODULE_STATUS_WARNING', 2);
define('AGENT_MODULE_STATUS_UNKNOW', 3);

View File

@ -95,37 +95,19 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
agents_add_address ($id_agent, $ip_address);
// Create special module agent_keepalive
$id_agent_module = db_process_sql_insert ('tagente_modulo',
array ('nombre' => 'agent_keepalive',
'id_agente' => $id_agent,
'id_tipo_modulo' => 100,
$values_modules = array ('id_tipo_modulo' => 100,
'descripcion' => __('Agent keepalive monitor'),
'id_modulo' => 1,
'min_warning' => 0,
'max_warning' => 1));
'max_warning' => 1);
$id_agent_module = modules_create_agent_module($id_agent, 'agent_keepalive', $values_modules);
if ($id_agent_module === false) {
db_process_sql_rollback ();
return false;
}
$result = db_process_sql_insert ('tagente_estado',
array ('id_agente_modulo' => $id_agent_module,
'datos' => '',
'timestamp' => 0,
'estado' => 0,
'id_agente' => $id_agent,
'last_try' => 0,
'utimestamp' => 0,
'current_interval' => 0,
'running_by' => 0,
'last_execution_try' => 0));
if ($result === false) {
db_process_sql_rollback ();
return false;
}
db_process_sql_commit ();
db_pandora_audit ("Agent management", "New agent '$name' created");

View File

@ -4301,7 +4301,7 @@ function api_set_delete_module($id, $id2, $other, $trash1) {
}
if (!$simulate) {
$return = db_process_sql_delete('tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$return = modules_delete_agent_module($idAgentModule);
}
else {
$return = true;
@ -4452,7 +4452,7 @@ function api_set_new_module($id, $id2, $other, $trash1) {
$values['id_modulo'] = 2;
$return = db_process_sql_insert('tagente_modulo', $values);
$return = modules_create_agent_module($values['id_agente'], $values['nombre'], $values);
$data['type'] = 'string';
if ($return === false) {
@ -5291,8 +5291,15 @@ function api_set_new_note_incident($id, $id2, $other, $thrash2) {
function api_set_disable_module ($agent_name, $module_name, $thrast3, $thrash4) {
$id_agent = agents_get_agent_id($agent_name);
$id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name));
db_process_sql("UPDATE tagente_modulo SET disabled = 1 WHERE id_agente_modulo = $id_agent_module");
returnData('string', array('type' => 'string', 'data' => __('Correct module disable')));
$result = modules_change_disabled($id_agent_module, 1);
if($result === NOERR) {
returnData('string', array('type' => 'string', 'data' => __('Correct module disable')));
}
else {
returnData('string', array('type' => 'string', 'data' => __('Error disabling module')));
}
}
@ -5308,8 +5315,15 @@ function api_set_disable_module ($agent_name, $module_name, $thrast3, $thrash4)
function api_set_enable_module ($agent_name, $module_name, $thrast3, $thrash4) {
$id_agent = agents_get_agent_id($agent_name);
$id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name));
db_process_sql("UPDATE tagente_modulo SET disabled = 0 WHERE id_agente_modulo = $id_agent_module");
returnData('string', array('type' => 'string', 'data' => __('Correct module enable')));
$result = modules_change_disabled($id_agent_module, 1);
if($result === NOERR) {
returnData('string', array('type' => 'string', 'data' => __('Correct module enable')));
}
else {
returnData('string', array('type' => 'string', 'data' => __('Error enabling module')));
}
}

View File

@ -960,7 +960,7 @@ function groups_monitor_not_init ($group_array) {
$group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE id_grupo IN $group_clause");
return db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
}
// Get monitor OK, except disabled and non-init
@ -980,7 +980,7 @@ function groups_monitor_ok ($group_array) {
$group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE id_grupo IN $group_clause");
return db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
}
// Get monitor CRITICAL, except disabled and non-init
@ -1000,7 +1000,7 @@ function groups_monitor_critical ($group_array) {
$group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE id_grupo IN $group_clause");
return db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
}
// Get monitor WARNING, except disabled and non-init
@ -1020,7 +1020,7 @@ function groups_monitor_warning ($group_array) {
$group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE id_grupo IN $group_clause");
return db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
}
// Get monitor UNKNOWN, except disabled and non-init
@ -1040,7 +1040,7 @@ function groups_monitor_unknown ($group_array) {
$group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE id_grupo IN $group_clause");
return db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
}
// Get alerts defined for a given group, except disabled

View File

@ -48,49 +48,21 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
$modules = agents_get_modules ($id_destiny_agent, false,
array ('nombre' => $module['nombre'], 'disabled' => false));
// These are the modules that exists in the target
// The module already exist in the target
if (! empty ($modules))
return array_pop (array_keys ($modules));
$modulesDisabled = agents_get_modules ($id_destiny_agent, false,
array ('nombre' => $module['nombre'], 'disabled' => true));
// If the module exist but disabled, we enable it
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;
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
db_process_sql_update('tagente_modulo', array('disabled' => false, 'delete_pending' => false),
array('id_agente_modulo' => $id_module, 'disabled' => true));
break;
case "oracle":
db_process_sql_update('tagente_modulo', array('disabled' => false, 'delete_pending' => false),
array('id_agente_modulo' => $id_module, 'disabled' => true), 'AND', false);
break;
}
modules_change_disabled($id_module, 0);
}
$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'] = agents_get_address ($id_destiny_agent);
$new_module['policy_linked'] = 0;
$new_module['id_policy_module'] = 0;
/* 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 {
@ -98,7 +70,6 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
$new_module = $module;
/* Rewrite different values */
$new_module['id_agente'] = $id_destiny_agent;
$new_module['ip_target'] = agents_get_address ($id_destiny_agent);
$new_module['policy_linked'] = 0;
$new_module['id_policy_module'] = 0;
@ -107,86 +78,62 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
$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']);
unset ($new_module['id_agente']);
$id_new_module = modules_create_agent_module($id_destiny_agent, $new_module['nombre'], $new_module);
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$id_new_module = db_process_sql_insert ('tagente_modulo',
$new_module);
break;
case "oracle":
$id_new_module = db_process_sql_insert ('tagente_modulo',
$new_module, false);
break;
}
if ($id_new_module === false) {
return false;
}
$values = array ();
$values['id_agente_modulo'] = $id_new_module;
}
$values['id_agente'] = $id_destiny_agent;
// If the module is synthetic we duplicate the operations too
if($module['id_modulo'] == 5) {
$synth_ops = db_get_all_rows_field_filter('tmodule_synth','id_agent_module_target',$module['id_agente_modulo']);
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$result = db_process_sql_insert ('tagente_estado', $values);
break;
case "oracle":
$result = db_process_sql_insert ('tagente_estado', $values, false);
break;
if($synth_ops === false) {
$synth_ops = array();
}
foreach($synth_ops as $synth_op) {
unset($synth_op['id']);
$synth_op['id_agent_module_target'] = $id_new_module;
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
db_process_sql_insert ('tmodule_synth',
$synth_op);
break;
case "oracle":
db_process_sql_insert ('tmodule_synth',
$synth_op, false);
break;
}
}
}
if ($result !== false) {
// If the module is synthetic we duplicate the operations too
if($module['id_modulo'] == 5) {
$synth_ops = db_get_all_rows_field_filter('tmodule_synth','id_agent_module_target',$module['id_agente_modulo']);
// Copy module tags
$source_tags = tags_get_module_tags($id_agent_module);
if($synth_ops === false) {
$synth_ops = array();
}
if ($source_tags == false)
$source_tags = array();
foreach($synth_ops as $synth_op) {
unset($synth_op['id']);
$synth_op['id_agent_module_target'] = $id_new_module;
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
db_process_sql_insert ('tmodule_synth',
$synth_op);
break;
case "oracle":
db_process_sql_insert ('tmodule_synth',
$synth_op, false);
break;
}
}
}
tags_insert_module_tag($id_new_module, $source_tags);
// Copy module tags
$source_tags = tags_get_module_tags($id_agent_module);
//Added the config data if necesary
enterprise_include_once('include/functions_config_agents.php');
if ($source_tags == false)
$source_tags = array();
$id_agente = modules_get_agentmodule_agent($id_agent_module);
tags_insert_module_tag($id_new_module, $source_tags);
$agent_md5 = md5 (agents_get_name($id_agente), false);
$remote_conf = file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5");
//Added the config data if necesary
enterprise_include_once('include/functions_config_agents.php');
$id_agente = modules_get_agentmodule_agent($id_agent_module);
$agent_md5 = md5 (agents_get_name($id_agente), false);
$remote_conf = file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5");
if ($remote_conf) {
$result = enterprise_hook('config_agents_copy_agent_module_to_agent',
array($id_agent_module, $id_new_module));
}
if ($remote_conf) {
$result = enterprise_hook('config_agents_copy_agent_module_to_agent',
array($id_agent_module, $id_new_module));
}
if ($result === false)
@ -195,6 +142,75 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
return $id_new_module;
}
/**
* Enable/Disable a module
*
* @param mixed Agent module id to be disabled. Accepts an array with ids.
* @param integer new value for the field disabled. 0 to enable, 1 to disable
*
* @return True if the module was disabled. False if not.
*/
function modules_change_disabled($id_agent_module, $new_value = 1) {
$id_agent_module = (array) $id_agent_module;
// Define the operation dependes if is disable or enable
if($new_value == 1) {
$operation = '- 1';
}
else {
$operation = '+ 1';
}
foreach($id_agent_module as $id_module) {
// If the module is already disabled/enabled abort
$current_disabled = db_get_value('disabled', 'tagente_modulo', 'id_agente_modulo', $id_module);
if($current_disabled == $new_value) {
continue;
}
$status = modules_get_agentmodule_status($id_module);
$agent_id = modules_get_agentmodule_agent($id_module);
// Define the field to update depends the status
switch($status) {
case AGENT_MODULE_STATUS_NO_DATA:
$modification = 'notinit_count = notinit_count ' . $operation . ',';
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
$modification = 'critical_count = critical_count ' . $operation . ',';
break;
case AGENT_MODULE_STATUS_WARNING:
$modification = 'warning_count = warning_count ' . $operation . ',';
break;
case AGENT_MODULE_STATUS_NORMAL:
$modification = 'normal_count = normal_count ' . $operation . ',';
break;
case AGENT_MODULE_STATUS_UNKNOW:
$modification = 'unknown_count = unknown_count ' . $operation . ',';
break;
default:
$modification = '';
break;
}
// Increase total count of the agent
$result = db_process_sql('UPDATE tagente SET ' . $modification . ' total_count = total_count ' . $operation . ' WHERE id_agente = ' . $agent_id);
if(!$result) {
return ERR_GENERIC;
}
}
$result = db_process_sql_update('tagente_modulo', array('disabled' => $new_value), array('id_agente_modulo' => $id_agent_module));
if($result) {
return NOERR;
}
else {
return ERR_GENERIC;
}
}
/**
* Deletes a module from an agent.
*
@ -225,20 +241,22 @@ function modules_delete_agent_module ($id_agent_module) {
$where);
db_process_sql_delete('ttag_module', $where);
// Update module status count
if ($module['estado'] == 0) {
db_process_sql ('UPDATE tagente SET normal_count=normal_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 1) {
db_process_sql ('UPDATE tagente SET critical_count=critical_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 2) {
db_process_sql ('UPDATE tagente SET warning_count=warning_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 3) {
db_process_sql ('UPDATE tagente SET unknown_count=unknown_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 4) {
db_process_sql ('UPDATE tagente SET notinit_count=notinit_count-1 WHERE id_agente=' . $module['id_agente']);
}
db_process_sql ('UPDATE tagente SET total_count=total_count-1 WHERE id_agente=' . $module['id_agente']);
// Update module status count only if the module is not disabled
if($module['disabled'] == 0) {
if ($module['estado'] == 0) {
db_process_sql ('UPDATE tagente SET normal_count=normal_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 1) {
db_process_sql ('UPDATE tagente SET critical_count=critical_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 2) {
db_process_sql ('UPDATE tagente SET warning_count=warning_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 3) {
db_process_sql ('UPDATE tagente SET unknown_count=unknown_count-1 WHERE id_agente=' . $module['id_agente']);
} else if ($module['estado'] == 4) {
db_process_sql ('UPDATE tagente SET notinit_count=notinit_count-1 WHERE id_agente=' . $module['id_agente']);
}
db_process_sql ('UPDATE tagente SET total_count=total_count-1 WHERE id_agente=' . $module['id_agente']);
}
return true;
}
@ -285,9 +303,18 @@ function modules_update_agent_module ($id, $values, $onlyNoDeletePending = false
$where['delete_pending'] = 0;
}
// Disable action requires a special function
if(isset($values['disabled'])) {
$result_disable = modules_change_disabled($id, $values['disabled']);
unset($values['disabled']);
}
else {
$result_disable = true;
}
$result = @db_process_sql_update ('tagente_modulo', $values, $where);
if($result === false) {
if($result === false || $result_disable === ERR_GENERIC) {
return ERR_DB;
}
else {
@ -402,14 +429,15 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl
return ERR_DB;
}
// Update module status count
if ($status == 0) {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=' . (int)$id_agent);
} else {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=' . (int)$id_agent);
// Update module status count if the module is not created disabled
if(!isset ($values['disabled']) || $values['disabled'] == 0) {
if ($status == 0) {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=' . (int)$id_agent);
} else {
db_process_sql ('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=' . (int)$id_agent);
}
}
return $id_agent_module;
}

View File

@ -1786,7 +1786,7 @@ function ui_toggle($code, $name, $title = '', $hidde_default = true, $return = f
// Link to toggle
$output = '';
$output .= '<a href="#" id="tgl_ctrl_'.$uniqid.'"><b>'.$name.'</b>&nbsp;'.html_print_image ($original, true, array ("title" => $title, "id" => "image_".$uniqid)).'</a>';
$output .= '<a href="javascript:" id="tgl_ctrl_'.$uniqid.'"><b>'.$name.'</b>&nbsp;'.html_print_image ($original, true, array ("title" => $title, "id" => "image_".$uniqid)).'</a>';
$output .= '<br /><br />';
// Code into a div

View File

@ -562,4 +562,3 @@ function toggle_full_value(id) {
$("#value_module_text_" + id).html(value_title);
}
</script>
?>

View File

@ -1008,7 +1008,7 @@ INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `p
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (4,'SMTP&#x20;Check','This&#x20;plugin&#x20;is&#x20;used&#x20;to&#x20;send&#x20;a&#x20;mail&#x20;to&#x20;a&#x20;SMTP&#x20;server&#x20;and&#x20;check&#x20;if&#x20;works.&#x20;&#x0d;&#x0a;&#x0d;&#x0a;Parameters&#x20;in&#x20;the&#x20;plugin:&#x0d;&#x0a;&#x0d;&#x0a;IP&#x20;Address&#x20;-&#x20;SMTP&#x20;Server&#x20;IP&#x20;address&#x0d;&#x0a;User&#x20;-&#x20;AUTH&#x20;login&#x20;&#x20;&#x0d;&#x0a;Pass&#x20;-&#x20;AUTH&#x20;password&#x0d;&#x0a;Port&#x20;-&#x20;SMTP&#x20;port&#x20;&#40;optional&#41;&#x0d;&#x0a;&#x0d;&#x0a;Optional&#x20;parameters:&#x0d;&#x0a;&#x0d;&#x0a;-d&#x20;Destination&#x20;email&#x0d;&#x0a;-f&#x20;Email&#x20;of&#x20;the&#x20;sender&#x0d;&#x0a;-a&#x20;Authentication&#x20;system.&#x20;Could&#x20;be&#x20;LOGIN,&#x20;PLAIN,&#x20;CRAM-MD5&#x20;or&#x20;DIGEST-MD',10,'/usr/share/pandora_server/util/plugin/SMTP_check.pl',0,'{"1":{"macro":"_field1_","desc":"Target&#x20;IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Port","help":"","value":""},"3":{"macro":"_field3_","desc":"Username","help":"","value":""},"4":{"macro":"_field4_","desc":"Password","help":"","value":""},"5":{"macro":"_field5_","desc":"Optional&#x20;parameters","help":"","value":""}}','-h&#x20;_field1_&#x20;-o&#x20;_field2_&#x20;-u&#x20;_field3_&#x20;-p&#x20;_field4_&#x20;_field5_');
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (6,'MySQL&#x20;Plugin','',15,'/usr/share/pandora_server/util/plugin/mysql_plugin.sh',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"IP&#x20;address\",\"help\":\"IP&#x20;address\",\"value\":\"-s\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"Username&#x20;to&#x20;access&#x20;to&#x20;database\",\"value\":\"-u\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"Password&#x20;to&#x20;access&#x20;to&#x20;database\",\"value\":\"-p\"}}', '');
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (6,'MySQL&#x20;Plugin','',15,'/usr/share/pandora_server/util/plugin/mysql_plugin.sh',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"IP&#x20;address\",\"help\":\"IP&#x20;address\",\"value\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"Username&#x20;to&#x20;access&#x20;to&#x20;database\",\"value\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"Password&#x20;to&#x20;access&#x20;to&#x20;database\",\"value\":\"\"}}', '-s&#x20;_field1_&#x20;-u&#x20;_field2_&#x20;-p&#x20;_field3_');
INSERT INTO `tagent_custom_fields` VALUES (1,'Serial&#x20;Number',0),(2,'Department',0),(3,'Additional&#x20;ID',0);