2008-12-23 Ramon Novoa <rnovoa@artica.es>

* pandoradb_data.sql, include/config.php, pandoradb.sql,
          godmode/groups/configure_group.php,
          godmode/groups/group_list.php,
          godmode/agentes/module_manager_editor_network.php,
          godmode/agentes/module_manager_editor_wmi.php,
          godmode/agentes/module_manager_editor_plugin.php,
          godmode/agentes/module_manager_editor_prediction.php,
          godmode/agentes/module_manager_editor_data.php,
          godmode/agentes/configurar_agente.php,
          godmode/agentes/module_manager_editor.php,
          godmode/agentes/agent_manager.php: Added support for a custom ID to
          agents, modules and groups.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1303 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2008-12-23 13:12:03 +00:00
parent 0a501678ee
commit 168182aba4
13 changed files with 123 additions and 44 deletions

View File

@ -1,3 +1,18 @@
2008-12-23 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql, include/config.php, pandoradb.sql,
godmode/groups/configure_group.php,
godmode/groups/group_list.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/agent_manager.php: Added support for a custom ID to
agents, modules and groups.
2008-12-22 Evi Vanoost <vanooste@rcbi.rochester.edu>
* godmode/agentes/agent_template.php: Rewritten to use new functions

View File

@ -131,30 +131,34 @@ $table->data[9][1] = print_select_from_sql ('SELECT id_server, name FROM tserver
enterprise_hook ('inventory_server');
// Custom ID
$table->data[10][0] = '<b>'.__('Custom ID').'</b>';
$table->data[10][1] = print_input_text ('custom_id', $custom_id, '', 16, 255, true);
// Description
$table->data[10][0] = '<b>'.__('Description').'</b>';
$table->data[10][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true);
$table->data[11][0] = '<b>'.__('Description').'</b>';
$table->data[11][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true);
// Learn mode / Normal mode
$table->data[11][0] = '<b>'.__('Module definition').'</b>'.pandora_help("module_definition", true);
$table->data[11][1] = __('Learning mode').' '.print_radio_button_extended ("modo", 1, '', $modo, false, '', 'style="margin-right: 40px;"', true);
$table->data[11][1] .= __('Normal mode').' '.print_radio_button_extended ("modo", 0, '', $modo, false, '', 'style="margin-right: 40px;"', true);
$table->data[12][0] = '<b>'.__('Module definition').'</b>'.pandora_help("module_definition", true);
$table->data[12][1] = __('Learning mode').' '.print_radio_button_extended ("modo", 1, '', $modo, false, '', 'style="margin-right: 40px;"', true);
$table->data[12][1] .= __('Normal mode').' '.print_radio_button_extended ("modo", 0, '', $modo, false, '', 'style="margin-right: 40px;"', true);
// Status (Disabled / Enabled)
$table->data[12][0] = '<b>'.__('Status').'</b>';
$table->data[12][1] = __('Disabled').' '.print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[12][1] .= __('Active').' '.print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[13][0] = '<b>'.__('Status').'</b>';
$table->data[13][1] = __('Disabled').' '.print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
$table->data[13][1] .= __('Active').' '.print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true);
// Remote configuration
$table->data[13][0] = '<b>'.__('Remote configuration').'</b>';
$table->data[14][0] = '<b>'.__('Remote configuration').'</b>';
if (file_exists ($filename['md5'])) {
$table->data[13][1] = date ("F d Y H:i:s.", fileatime ($filename['md5']));
$table->data[14][1] = date ("F d Y H:i:s.", fileatime ($filename['md5']));
// Delete remote configuration
$table->data[13][1] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente=$id_agente"><img src="images/cross.png" /></a>';
$table->data[14][1] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente=$id_agente"><img src="images/cross.png" /></a>';
} else {
$table->data[13][1] = '<i>'.__('Not available').'</i>';
$table->data[14][1] = '<i>'.__('Not available').'</i>';
}
print_table ($table);

View File

@ -106,6 +106,7 @@ $id_prediction_server = 0;
$id_wmi_server = 0;
$grupo = 0;
$id_os = 0;
$custom_id = "";
// ================================
// Create AGENT
@ -126,6 +127,7 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent
$id_wmi_server = get_parameter_post ("wmi_server", 0);
$id_os = get_parameter_post ("id_os", 0);
$disabled = get_parameter_post ("disabled", 0);
$custom_id = get_parameter_post ("custom_id", "");
// Check if agent exists (BUG WC-50518-2)
if ($nombre_agente == "") {
@ -136,10 +138,10 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent
$agent_created_ok = 0;
} else {
$sql = sprintf ("INSERT INTO tagente
(nombre, direccion, id_grupo, intervalo, comentarios, modo, id_os, disabled, id_network_server, id_plugin_server, id_wmi_server, id_prediction_server, id_parent)
(nombre, direccion, id_grupo, intervalo, comentarios, modo, id_os, disabled, id_network_server, id_plugin_server, id_wmi_server, id_prediction_server, id_parent, custom_id)
VALUES
('%s', '%s', %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d)",
$nombre_agente, $direccion_agente, $grupo, $intervalo, $comentarios, $modo, $id_os, $disabled, $id_network_server, $id_plugin_server, $id_wmi_server, $id_prediction_server, $id_parent);
('%s', '%s', %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, '%s')",
$nombre_agente, $direccion_agente, $grupo, $intervalo, $comentarios, $modo, $id_os, $disabled, $id_network_server, $id_plugin_server, $id_wmi_server, $id_prediction_server, $id_parent, $custom_id);
$id_agente = process_sql ($sql, "insert_id");
enterprise_hook ('update_agent', array ($id_agente));
if ($id_agente !== false) {
@ -148,9 +150,9 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent
// Create special module agent_keepalive
$sql = "INSERT INTO tagente_modulo
(nombre, id_agente, id_tipo_modulo, descripcion, id_modulo)
(nombre, id_agente, id_tipo_modulo, descripcion, id_modulo, custom_id)
VALUES
('agent_keepalive',".$id_agente.",100,'Agent Keepalive monitor',1)";
('agent_keepalive',".$id_agente.",100,'Agent Keepalive monitor',1".$custom_id.")";
$id_agent_module = process_sql ($sql, "insert_id");
if ($id_agent_module !== false) {
@ -509,6 +511,7 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
$id_wmi_server = (int) get_parameter_post ("wmi_server", 0);
$id_prediction_server = (int) get_parameter_post ("prediction_server", 0);
$id_parent = (int) get_parameter_post ("id_parent", 0);
$custom_id = (string) get_parameter_post ("custom_id", "");
//Verify if there is another agent with the same name but different ID
if ($nombre_agente == "") {
@ -532,12 +535,12 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
SET disabled = %d, id_parent = %d, id_os = %d, modo = %d,
nombre = '%s', direccion = '%s', id_grupo = %d,
intervalo = %d, comentarios = '%s', id_network_server = %d,
id_plugin_server = %d, id_wmi_server = %d, id_prediction_server = %d
WHERE id_agente = %d",
id_plugin_server = %d, id_wmi_server = %d, id_prediction_server = %d,
custom_id = '%s' WHERE id_agente = %d",
$disabled, $id_parent, $id_os, $modo, $nombre_agente,
$direccion_agente, $grupo, $intervalo, $comentarios,
$id_network_server, $id_plugin_server, $id_wmi_server,
$id_prediction_server, $id_agente);
$id_prediction_server, $custom_id, $id_agente);
$result = process_sql ($sql);
if ($result === false) {
echo '<h3 class="error">'.__('There was a problem updating agent').'</h3>';
@ -588,6 +591,7 @@ if (isset($_GET["id_agente"])) {
$id_os = $row["id_os"];
$disabled = $row["disabled"];
$id_parent = $row["id_parent"];
$custom_id = $row["custom_id"];
}
// Read data module if editing module
@ -617,6 +621,7 @@ if ((isset ($_GET["update_module"])) && (!isset ($_POST["oid"])) && (!isset ($_P
$modulo_max = "N/A";
if (empty ($modulo_min))
$modulo_min = "N/A";
$custom_id = $row["custom_id"];
}
}
@ -708,6 +713,7 @@ if ((isset ($_POST["update_module"])) || (isset ($_POST["insert_module"]))) {
$form_plugin_pass = (string) get_parameter ("form_plugin_pass","");
$form_plugin_parameter = (string) get_parameter ("form_plugin_parameter","");
$form_id_modulo = (int) get_parameter ("form_id_modulo",0);
$form_custom_id = (string) get_parameter ("form_custom_id","");
}
// MODULE UPDATE
@ -742,10 +748,11 @@ if ((isset ($_POST["update_module"])) && (!isset ($_POST["oid"]))) { // if modif
id_plugin = %d,
post_process = %f,
prediction_module = %d,
max_timeout = %d
max_timeout = %d,
custom_id = '%s'
WHERE id_agente_modulo = %d", $form_description, $form_id_module_group, $form_name, $form_maxvalue, $form_minvalue, $form_interval, $form_tcp_port, $form_tcp_send, $form_tcp_rcv,
$form_snmp_community, $form_snmp_oid, $form_ip_target, $form_flag, $form_id_modulo, $form_disabled, $form_id_export, $form_plugin_user, $form_plugin_pass,
$form_plugin_parameter, $form_id_plugin, $form_post_process, $form_prediction_module, $form_max_timeout, $id_agente_modulo);
$form_plugin_parameter, $form_id_plugin, $form_post_process, $form_prediction_module, $form_max_timeout, $form_custom_id, $id_agente_modulo);
$result = process_sql ($sql);
if ($result === false) {
@ -790,11 +797,11 @@ if (((!isset ($_POST["nc"]) OR ($_POST["nc"] == -1))) && (!isset ($_POST["oid"])
(id_agente, id_tipo_modulo, nombre, descripcion, max, min, snmp_oid, snmp_community,
id_module_group, module_interval, ip_target, tcp_port, tcp_rcv, tcp_send, id_export,
plugin_user, plugin_pass, plugin_parameter, id_plugin, post_process, prediction_module,
max_timeout, disabled, id_modulo)
VALUES (%d,%d,'%s','%s',%d,%d,'%s','%s',%d,%d,'%s',%d,'%s','%s',%d,'%s','%s','%s',%d,%d,%d,%d,%d,%d)",
max_timeout, disabled, id_modulo, custom_id)
VALUES (%d,%d,'%s','%s',%d,%d,'%s','%s',%d,%d,'%s',%d,'%s','%s',%d,'%s','%s','%s',%d,%d,%d,%d,%d,%d,'%s')",
$id_agente, $form_id_tipo_modulo, $form_name, $form_description, $form_maxvalue, $form_minvalue, $form_snmp_oid, $form_snmp_community,
$form_id_module_group, $form_interval, $form_ip_target, $form_tcp_port, $form_tcp_rcv, $form_tcp_send, $form_id_export, $form_plugin_user, $form_plugin_pass,
$form_plugin_parameter, $form_id_plugin, $form_post_process, $form_id_prediction_module, $form_max_timeout, $form_disabled, $form_id_modulo);
$form_plugin_parameter, $form_id_plugin, $form_post_process, $form_id_prediction_module, $form_max_timeout, $form_disabled, $form_id_modulo, $form_custom_id);
$id_agente_modulo = process_sql ($sql, 'insert_id');
if ($id_agente_modulo === false){

View File

@ -94,7 +94,8 @@ if (($form_moduletype == "networkserver" || $form_moduletype == "wmiserver") &&
$form_prediction_module = "";
$form_id_plugin = "";
$form_post_process = "";
$form_custom_id = "";
} elseif (!isset($_POST['oid'])) {
// Clean up specific network modules fields
$form_name = "";
@ -119,6 +120,7 @@ if (($form_moduletype == "networkserver" || $form_moduletype == "wmiserver") &&
$form_plugin_user = "";
$form_plugin_pass = "";
$form_plugin_parameter = "";
$form_custom_id = "";
}
switch ($form_moduletype) {

View File

@ -64,6 +64,7 @@ if ($update_module_id != NULL){
$form_post_process = $row['post_process'];
$form_prediction_module = $row['prediction_module'];
$form_max_timeout = $row['max_timeout'];
$form_custom_id = $row['custom_id'];
if ($tbl_disabled == 1)
$disabled_status = true;
@ -176,6 +177,13 @@ echo '<td valign="top" class="datos">'.__('Description')."</td>";
echo '<td valign="top" class="datos" colspan="3">';
print_textarea ("form_description", 2, 65, $form_description);
echo '</td></tr>';
// Custom ID
echo '<tr>';
echo '<td class="datos2">'.__('Custom ID')."</td>";
echo '<td class="datos2" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
echo '</tr>';
echo '</table>';
//Submit

View File

@ -69,6 +69,7 @@ if ($update_module_id != NULL){
$form_post_process = $row['post_process'];
$form_prediction_module = $row['prediction_module'];
$form_max_timeout = $row['max_timeout'];
$form_custom_id = $row['custom_id'];
if ($tbl_disabled == 1){
$disabled_status = 'checked="ckecked"';
@ -282,6 +283,13 @@ echo '<tr>';
echo '<td valign="top" class="datos">'.__('Description')."</td>";
echo '<td valign="top" class="datos" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
echo '</tr>';
// Custom ID
echo '<tr>';
echo '<td class="datos2">'.__('Custom ID')."</td>";
echo '<td class="datos2" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
echo '</tr>';
echo '</table>';
// Submit

View File

@ -67,6 +67,7 @@ if ($update_module_id != NULL){
$form_post_process = $row['post_process'];
$form_prediction_module = $row['prediction_module'];
$form_max_timeout = $row['max_timeout'];
$form_custom_id = $row['custom_id'];
if ($tbl_disabled == 1){
$disabled_status = 'checked="ckecked"';
@ -208,9 +209,16 @@ echo '</tr>';
// Description
echo '<tr>';
echo '<td valign="top" class="datos">'.__('Description')."</td>";
echo '<td valign="top" class="datos" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
echo '<td valign="top" class="datos2">'.__('Description')."</td>";
echo '<td valign="top" class="datos2" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
echo '</tr>';
// Custom ID
echo '<tr>';
echo '<td class="datos">'.__('Custom ID')."</td>";
echo '<td class="datos" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
echo '</tr>';
echo '</table>';
// Submit

View File

@ -68,6 +68,7 @@ if ($update_module_id != NULL){
$form_post_process = $row['post_process'];
$form_prediction_module = $row['prediction_module'];
$form_max_timeout = $row['max_timeout'];
$form_custom_id = $row['custom_id'];
if ($tbl_disabled == 1){
$disabled_status = 'checked="ckecked"';
@ -167,9 +168,16 @@ echo '</tr>';
// Description
echo '<tr>';
echo '<td valign="top" class="datos">'.__('Description')."</td>";
echo '<td valign="top" class="datos" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
echo '<td valign="top" class="datos2">'.__('Description')."</td>";
echo '<td valign="top" class="datos2" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
echo '</tr>';
// Custom ID
echo '<tr>';
echo '<td class="datos">'.__('Custom ID')."</td>";
echo '<td class="datos" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
echo '</tr>';
echo '</table>';
// Submit

View File

@ -68,7 +68,8 @@ if ($update_module_id != NULL){
$form_post_process = $row['post_process'];
$form_prediction_module = $row['prediction_module'];
$form_max_timeout = $row['max_timeout'];
$form_custom_id = $row['custom_id'];
if ($tbl_disabled == 1){
$disabled_status = 'checked="ckecked"';
} else {
@ -244,6 +245,13 @@ echo '<tr>';
echo '<td valign="top" class="datos">'.__('Description')."</td>";
echo '<td valign="top" class="datos" colspan="3"><textarea name="form_description" cols="65" rows="2">'.$form_description.'</textarea>';
echo '</tr>';
// Custom ID
echo '<tr>';
echo '<td class="datos2">'.__('Custom ID')."</td>";
echo '<td class="datos2" colspan="3"><input type="text" name="form_custom_id" size="20" value="'.$form_custom_id.'"></td>';
echo '</tr>';
echo '</table>';
// Submit

View File

@ -33,6 +33,7 @@ $icon = "";
$name = "";
$id_parent = 0;
$alerts_disabled = 0;
$custom_id = "";
$create_group = (bool) get_parameter ('create_group');
$id_group = (int) get_parameter ('id_group');
@ -44,6 +45,7 @@ if ($id_group) {
$icon = $group["icon"].'.png';
$alerts_disabled = $group["disabled"];
$id_parent = $group["parent"];
$custom_id = $group["custom_id"];
} else {
echo "<h3 class='error'>".__('There was a problem loading group')."</h3>";
echo "</table>";
@ -88,6 +90,9 @@ echo'</span>';
$table->data[3][0] = __('Alerts');
$table->data[3][1] = print_checkbox ('alerts_enabled', 1, ! $alerts_disabled, true);
$table->data[4][0] = __('Custom ID');
$table->data[4][1] = print_input_text ('custom_id', $custom_id, '', 16, 255, true);
echo '<form name="grupo" method="post" action="index.php?sec=gagente&sec2=godmode/groups/group_list">';
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';

View File

@ -54,10 +54,11 @@ if ($create_group) {
$icon = (string) get_parameter ('icon');
$id_parent = (int) get_parameter ('id_parent');
$alerts_disabled = (bool) get_parameter ('alerts_disabled');
$custom_id = (string) get_parameter ('custom_id');
$sql = sprintf ('INSERT INTO tgrupo (nombre, icon, parent, disabled)
VALUES ("%s", "%s", %d, %d)',
$name, substr ($icon, 0, -4), $id_parent, $alerts_disabled);
$sql = sprintf ('INSERT INTO tgrupo (nombre, icon, parent, disabled, custom_id)
VALUES ("%s", "%s", %d, %d, "%s")',
$name, substr ($icon, 0, -4), $id_parent, $alerts_disabled, $custom_id);
$result = mysql_query ($sql);
if ($result) {
echo "<h3 class='suc'>".__('Group successfully created')."</h3>";
@ -72,10 +73,12 @@ if ($update_group) {
$icon = (string) get_parameter ('icon');
$id_parent = (int) get_parameter ('id_parent');
$alerts_enabled = (bool) get_parameter ('alerts_enabled');
$custom_id = (string) get_parameter ('custom_id');
$sql = sprintf ('UPDATE tgrupo SET nombre = "%s",
icon = "%s", disabled = %d, parent = %d
icon = "%s", disabled = %d, parent = %d, custom_id = "%s"
WHERE id_grupo = %d',
$name, substr ($icon, 0, -4), !$alerts_enabled, $id_parent, $id_group);
$name, substr ($icon, 0, -4), !$alerts_enabled, $id_parent, $custom_id, $id_group);
$result = process_sql ($sql);
if ($result !== false) {
echo "<h3 class='suc'>".__('Group successfully updated')."</h3>";

View File

@ -57,6 +57,7 @@ CREATE TABLE IF NOT EXISTS `tagente` (
`id_prediction_server` smallint(4) unsigned default '0',
`id_wmi_server` smallint(4) unsigned default '0',
`id_parent` int(10) unsigned default '0',
`custom_id` varchar(255) default '',
PRIMARY KEY (`id_agente`),
KEY `nombre` (`nombre`),
KEY `direccion` (`direccion`),
@ -156,6 +157,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
`post_process` double(18,13) default NULL,
`prediction_module` bigint(14) default '0',
`max_timeout` int(4) unsigned default '0',
`custom_id` varchar(255) default '',
PRIMARY KEY (`id_agente_modulo`),
KEY `main_idx` (`id_agente_modulo`,`id_agente`),
KEY `tam_agente` (`id_agente`),
@ -315,6 +317,7 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
`icon` varchar(50) default NULL,
`parent` mediumint(4) unsigned NOT NULL default '0',
`disabled` tinyint(3) unsigned NOT NULL default '0',
`custom_id` varchar(255) default '',
PRIMARY KEY (`id_grupo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -89,14 +89,14 @@ UNLOCK TABLES;
LOCK TABLES `tgrupo` WRITE;
INSERT INTO `tgrupo` VALUES
(1,'All','world',0,0),
(2,'Servers','server_database',0,0),
(4,'Firewalls','firewall',0,0),
(8,'Databases','database_gear',0,0),
(9,'Network','transmit',0,0),
(10,'Unknown','world',0,0),
(11,'Workstations','computer',0,0),
(12,'Applications','applications',0,0);
(1,'All','world',0,0,''),
(2,'Servers','server_database',0,0,''),
(4,'Firewalls','firewall',0,0,''),
(8,'Databases','database_gear',0,0,''),
(9,'Network','transmit',0,0,''),
(10,'Unknown','world',0,0,''),
(11,'Workstations','computer',0,0,''),
(12,'Applications','applications',0,0,'');
UNLOCK TABLES;