diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 710901f8ee..ad2919a14e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,18 @@ +2008-12-23 Ramon Novoa + + * 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 * godmode/agentes/agent_template.php: Rewritten to use new functions diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index a16c9937f3..f386ec6b23 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -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] = ''.__('Custom ID').''; +$table->data[10][1] = print_input_text ('custom_id', $custom_id, '', 16, 255, true); + // Description -$table->data[10][0] = ''.__('Description').''; -$table->data[10][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true); +$table->data[11][0] = ''.__('Description').''; +$table->data[11][1] = print_input_text ('comentarios', $comentarios, '', 45, 255, true); // Learn mode / Normal mode -$table->data[11][0] = ''.__('Module definition').''.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] = ''.__('Module definition').''.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] = ''.__('Status').''; -$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] = ''.__('Status').''; +$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] = ''.__('Remote configuration').''; +$table->data[14][0] = ''.__('Remote configuration').''; 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] .= ''; + $table->data[14][1] .= ''; } else { - $table->data[13][1] = ''.__('Not available').''; + $table->data[14][1] = ''.__('Not available').''; } print_table ($table); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 75a7357a7c..ce0abfc25e 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -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 '

'.__('There was a problem updating agent').'

'; @@ -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){ diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 7e351b1b16..37ef332121 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -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) { diff --git a/pandora_console/godmode/agentes/module_manager_editor_data.php b/pandora_console/godmode/agentes/module_manager_editor_data.php index 4a0d54a543..7ef78a1b00 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_data.php +++ b/pandora_console/godmode/agentes/module_manager_editor_data.php @@ -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 ''.__('Description').""; echo ''; print_textarea ("form_description", 2, 65, $form_description); echo ''; + +// Custom ID +echo ''; +echo ''.__('Custom ID').""; +echo ''; +echo ''; + echo ''; //Submit diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index a451d8c4da..930f72d98c 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -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 ''; echo ''.__('Description').""; echo ''; echo ''; + +// Custom ID +echo ''; +echo ''.__('Custom ID').""; +echo ''; +echo ''; + echo ''; // Submit diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index e1e14cb3e7..121ffd9780 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -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 ''; // Description echo ''; -echo ''.__('Description').""; -echo ''; +echo ''.__('Description').""; +echo ''; echo ''; + +// Custom ID +echo ''; +echo ''.__('Custom ID').""; +echo ''; +echo ''; + echo ''; // Submit diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 528dd1be5b..c943e557af 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -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 ''; // Description echo ''; -echo ''.__('Description').""; -echo ''; +echo ''.__('Description').""; +echo ''; echo ''; + +// Custom ID +echo ''; +echo ''.__('Custom ID').""; +echo ''; +echo ''; + echo ''; // Submit diff --git a/pandora_console/godmode/agentes/module_manager_editor_wmi.php b/pandora_console/godmode/agentes/module_manager_editor_wmi.php index b426e43d2b..bb96e73c4a 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_wmi.php +++ b/pandora_console/godmode/agentes/module_manager_editor_wmi.php @@ -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 ''; echo ''.__('Description').""; echo ''; echo ''; + +// Custom ID +echo ''; +echo ''.__('Custom ID').""; +echo ''; +echo ''; + echo ''; // Submit diff --git a/pandora_console/godmode/groups/configure_group.php b/pandora_console/godmode/groups/configure_group.php index 5c28c36b60..034012747b 100644 --- a/pandora_console/godmode/groups/configure_group.php +++ b/pandora_console/godmode/groups/configure_group.php @@ -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 "

".__('There was a problem loading group')."

"; echo ""; @@ -88,6 +90,9 @@ echo''; $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 '
'; print_table ($table); echo '
'; diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 30fd506aa5..ad5cfdebdf 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -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 "

".__('Group successfully created')."

"; @@ -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 "

".__('Group successfully updated')."

"; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8ca5e41dd0..d6d8725f31 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -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; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 7f6cf037cd..b91cb3b72f 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -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;