2013-02-27 Miguel de Dios <miguel.dedios@artica.es>

* godmode/agentes/module_manager_editor_common.php,
	godmode/agentes/modificar_agente.php,
	godmode/agentes/module_manager_editor.php,
	godmode/agentes/agent_manager.php: updated the code to module
	constants.
	
	* include/javascript/pandora_modules.js: fixed the set the
	module_data from to the json.
	
	* include/functions_api.php: cleaned source code style.
	
	* include/constants.php: addded lost constant for the module
	prediction.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7728 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-02-27 09:51:48 +00:00
parent 0dd04ce0ea
commit de78e7da9d
8 changed files with 157 additions and 114 deletions

View File

@ -1,3 +1,19 @@
2013-02-27 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/module_manager_editor_common.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/agent_manager.php: updated the code to module
constants.
* include/javascript/pandora_modules.js: fixed the set the
module_data from to the json.
* include/functions_api.php: cleaned source code style.
* include/constants.php: addded lost constant for the module
prediction.
2013-02-26 Sancho Lerena <slerena@artica.es>
* include/functions_filemanager.php: Fixed tooltips to use new format.

View File

@ -118,8 +118,10 @@ echo '<div style="height: 5px">&nbsp;</div>';
if (!$new_agent) {
// Agent remote configuration editor
$agent_md5 = md5 ($nombre_agente, false);
$filename['md5'] = $config["remote_config"]."/md5/".$agent_md5.".md5";
$filename['conf'] = $config["remote_config"]."/conf/".$agent_md5.".conf";
$filename['md5'] = $config["remote_config"] . "/md5/" .
$agent_md5 . ".md5";
$filename['conf'] = $config["remote_config"] . "/conf/" .
$agent_md5 . ".conf";
}
$disk_conf = (bool) get_parameter ('disk_conf');
@ -170,7 +172,7 @@ if (!$new_agent) {
// Delete link from here
if (!$new_agent) {
$table->data[0][1] .= "&nbsp;&nbsp;<span align='right'><a onClick=\"if (!confirm('" . __('Are you sure?') . "')) return false;\" title='".__("Delete agent")."' href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'><img src='images/cross.png'></a>";
$table->data[0][1] .= "&nbsp;&nbsp;<span align='right'><a onClick=\"if (!confirm('" . __('Are you sure?') . "')) return false;\" title='".__("Delete agent")."' href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'><img src='images/cross.png'></a>";
}
$table->data[1][0] = __('IP Address');
@ -274,7 +276,7 @@ foreach ($listIcons as $index => $value) $arraySelectIcon[$index] = $index;
$path = 'images/gis_map/icons/'; //TODO set better method the path
$table->data[4][0] = __('Agent icon') . ui_print_help_tip(__('Agent icon for GIS Maps.'), true);
if($icon_path == '') {
if ($icon_path == '') {
$display_icons = 'none';
// Hack to show no icon. Use any given image to fix not found image errors
$path_without = "images/spinner.png";
@ -331,7 +333,7 @@ $table->data = array ();
$fields = db_get_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();
if ($fields === false) $fields = array();
foreach ($fields as $field) {
@ -339,7 +341,7 @@ foreach ($fields as $field) {
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if($custom_value === false) {
if ($custom_value === false) {
$custom_value = '';
}
@ -348,7 +350,7 @@ foreach ($fields as $field) {
array_push ($table->data, $data);
}
if(!empty($fields)) {
if (!empty($fields)) {
ui_toggle(html_print_table ($table, true), __('Custom fields'));
}

View File

@ -97,7 +97,7 @@ if ($agent_to_delete) {
}
}
if($enable_agent) {
if ($enable_agent) {
$result = db_process_sql_update('tagente', array('disabled' => 0), array('id_agente' => $enable_agent));
if ($result) {
@ -111,7 +111,7 @@ if($enable_agent) {
__('Successfully enabled'), __('Could not be enabled'));
}
if($disable_agent) {
if ($disable_agent) {
$result = db_process_sql_update('tagente', array('disabled' => 1), array('id_agente' => $disable_agent));
if ($result) {
@ -186,11 +186,15 @@ switch ($sortField) {
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
$order = array('field' => 'nombre COLLATE utf8_general_ci',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
$order = array('field' => 'nombre COLLATE utf8_general_ci',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'DESC');
break;
}
break;
@ -198,11 +202,15 @@ switch ($sortField) {
switch ($sort) {
case 'up':
$selectOsUp = $selected;
$order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
$order = array('field' => 'id_os',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'ASC');
break;
case 'down':
$selectOsDown = $selected;
$order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
$order = array('field' => 'id_os',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'DESC');
break;
}
break;
@ -210,11 +218,15 @@ switch ($sortField) {
switch ($sort) {
case 'up':
$selectGroupUp = $selected;
$order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
$order = array('field' => 'id_grupo',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'ASC');
break;
case 'down':
$selectGroupDown = $selected;
$order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
$order = array('field' => 'id_grupo',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'DESC');
break;
}
break;
@ -230,7 +242,7 @@ switch ($sortField) {
}
$search_sql = '';
if ($search != ""){
if ($search != "") {
$search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%') ";
}
@ -255,7 +267,8 @@ if ($ag_group > 0) {
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s, %s %s LIMIT %d, %d',
ORDER BY %s, %s %s
LIMIT %d, %d',
implode (",", $ag_groups), $search_sql, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]);
break;
case "postgresql":
@ -263,7 +276,8 @@ if ($ag_group > 0) {
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s, %s %s LIMIT %d OFFSET %d',
ORDER BY %s, %s %s
LIMIT %d OFFSET %d',
implode (",", $ag_groups), $search_sql, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset);
break;
case "oracle":
@ -288,13 +302,17 @@ else {
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ('SELECT *
FROM tagente WHERE 1=1 %s
FROM tagente
WHERE 1=1
%s
ORDER BY %s, %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['field2'],
$order['order'], $offset, $config["block_size"]);
break;
case "postgresql":
$sql = sprintf ('SELECT *
FROM tagente WHERE 1=1 %s
FROM tagente
WHERE 1=1
%s
ORDER BY %s, %s %s LIMIT %d OFFSET %d', $search_sql, $order['field'], $order['field2'],
$order['order'], $config["block_size"], $offset);
break;
@ -303,7 +321,9 @@ else {
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$sql = sprintf ('SELECT *
FROM tagente WHERE 1=1 %s
FROM tagente
WHERE 1=1
%s
ORDER BY %s, %s %s', $search_sql, $order['field'], $order['field2'], $order['order']);
$sql = oracle_recode_query ($sql, $set);
break;
@ -331,7 +351,8 @@ else {
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s, %s %s LIMIT %d, %d',
ORDER BY %s, %s %s
LIMIT %d, %d',
implode (',', array_keys ($user_groups)),
$search_sql, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]);
break;
@ -340,7 +361,8 @@ else {
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s, %s %s LIMIT %d OFFSET %d',
ORDER BY %s, %s %s
LIMIT %d OFFSET %d',
implode (',', array_keys ($user_groups)),
$search_sql, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset);
break;
@ -430,7 +452,7 @@ if ($agents !== false) {
echo "&nbsp;";
}
if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
$main_tab = 'main';
}
else {
@ -448,7 +470,7 @@ if ($agents !== false) {
echo "</em>";
}
echo '</span><div class="left actions" style="visibility: hidden; clear: left">';
if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main&
id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>';
@ -509,7 +531,7 @@ if ($agents !== false) {
html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) ."</a>";
}
if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo "&nbsp;&nbsp;<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort'";
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
@ -527,12 +549,13 @@ else {
echo "&nbsp;</td></tr><tr><td>";
}
if(check_acl ($config["id_user"], 0, "AW")) {
if (check_acl ($config["id_user"], 0, "AW")) {
// Create agent button
echo '<a name="bottom">';
echo '<form method="post" action="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente">';
html_print_input_hidden ('new_agent', 1);
html_print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"');
html_print_submit_button (__('Create agent'), 'crt', false,
'class="sub next"');
echo "</form>";
}
@ -554,11 +577,6 @@ $(document).ready (function () {
$(this).css ("min-width", "100px");
});
/* $("#ag_group").hover (
function () {
$(this).css ("width", "auto");
});*/
$("#ag_group").blur (function () {
$(this).css ("width", "100px");
});

View File

@ -328,11 +328,12 @@ $remote_conf = false;
switch ($moduletype) {
case "dataserver":
case 1:
$moduletype = 1;
case MODULE_DATA:
$moduletype = MODULE_DATA;
// Has remote configuration ?
$agent_md5 = md5 (agents_get_name($id_agente), false);
$remote_conf = file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5");
$remote_conf = file_exists ($config["remote_config"] ."/md5/" .
$agent_md5 . ".md5");
/* Categories is an array containing the allowed module types
(generic_data, generic_string, etc) from ttipo_modulo (field categoria) */
@ -349,31 +350,31 @@ switch ($moduletype) {
}
break;
case "networkserver":
case 2:
$moduletype = 2;
case MODULE_NETWORK:
$moduletype = MODULE_NETWORK;
$categories = array (3, 4, 5);
require ('module_manager_editor_common.php');
require ('module_manager_editor_network.php');
break;
case "pluginserver":
case 4:
$moduletype = 4;
case MODULE_PLUGIN:
$moduletype = MODULE_PLUGIN;
$categories = array (0, 1, 2);
require ('module_manager_editor_common.php');
require ('module_manager_editor_plugin.php');
break;
case "predictionserver":
case 5:
$moduletype = 5;
case MODULE_PREDICTION:
$moduletype = MODULE_PREDICTION;
$categories = array (0, 1);
require ('module_manager_editor_common.php');
require ('module_manager_editor_prediction.php');
break;
case "wmiserver":
case 6:
$moduletype = 6;
case MODULE_WMI:
$moduletype = MODULE_WMI;
$categories = array (0, 1, 2);
require ('module_manager_editor_common.php');

View File

@ -157,8 +157,7 @@ if (isset($id_agent_module)) {
$edit = true;
}
}
else
{
else {
//Run into a policy
$edit = true;
}
@ -173,7 +172,7 @@ if (!$edit) {
$type_names = db_get_all_rows_sql($sql);
$type_names_hash = array();
foreach($type_names as $tn) {
foreach ($type_names as $tn) {
$type_names_hash[$tn['id_tipo']] = $tn['nombre'];
}
@ -207,7 +206,7 @@ else {
$type_names = db_get_all_rows_sql($sql);
$type_names_hash = array();
foreach($type_names as $tn) {
foreach ($type_names as $tn) {
$type_names_hash[$tn['id_tipo']] = $tn['nombre'];
}
@ -372,7 +371,8 @@ $table_advanced->data[6][4] = html_print_select_from_sql (
$table_advanced->data[7][0] = __('Quiet');
$table_advanced->data[7][0] .= ui_print_help_tip(__('The module still stores data but the alerts and events will be stop'), true);
$table_advanced->colspan[7][1] = 4;
$table_advanced->data[7][1] = html_print_checkbox('quiet_module', 1, $quiet_module, true);
$table_advanced->data[7][1] = html_print_checkbox('quiet_module', 1,
$quiet_module, true);
$table_advanced->data[8][0] = __('Critical instructions'). ui_print_help_tip(__("Instructions when the status is critical"), true);
$table_advanced->data[8][1] = html_print_textarea ('critical_instructions', 2, 65, $critical_instructions, '', true);
@ -391,10 +391,12 @@ $table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour, $minu
$table_advanced->colspan[11][1] = 4;
$table_advanced->data[12][0] = __('Timeout');
$table_advanced->data[12][1] = html_print_input_text ('max_timeout', $max_timeout, '', 5, 10, true);
$table_advanced->data[12][1] = html_print_input_text ('max_timeout',
$max_timeout, '', 5, 10, true);
$table_advanced->data[12][2] = '';
$table_advanced->data[12][3] = __('Retries');
$table_advanced->data[12][4] = html_print_input_text ('max_retries', $max_retries, '', 5, 10, true);
$table_advanced->data[12][4] = html_print_input_text ('max_retries',
$max_retries, '', 5, 10, true);
if (check_acl ($config['id_user'], 0, "PM")) {
$table_advanced->data[13][0] = __('Category');

View File

@ -228,6 +228,7 @@ define ('MODULE_DATA', 1);
define ('MODULE_NETWORK', 2);
define ('MODULE_SNMP', 2);
define ('MODULE_PLUGIN', 4);
define ('MODULE_PREDICTION', 5);
define ('MODULE_WMI', 6);
define ('MODULE_WEB', 7);

View File

@ -3043,7 +3043,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) {
* @param $thrash3 Don't use
*/
function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) {
if ($id == ""){
if ($id == "") {
returnError('error_update_network_module_policy', __('Error updating network module in policy. Id_policy cannot be left blank.'));
return;
}

View File

@ -108,7 +108,7 @@ function configure_modules_form () {
configuration_data = js_html_entity_decode (data['data']);
$("#text-name").attr ("value", js_html_entity_decode (data["name"]));
$("#textarea_description").attr ("value", js_html_entity_decode (data["description"]));
$("#textarea_configuration_data").attr ("value", configuration_data);
$("#textarea_configuration_data").val(configuration_data);
$("#component_loading").hide ();
$("#id_module_type option[value="+data["type"]+"]").select (1);
$("#text-max").attr ("value", data["max"]);
@ -119,7 +119,10 @@ function configure_modules_form () {
}
else {
period_select_update('module_interval', data["module_interval"]);
} $("#id_module_group option[value="+data["id_module_group"]+"]").select (1);
}
$("#id_module_group option[value="+data["id_module_group"]+"]").select (1);
if (data["history_data"])
$("#checkbox-history_data").check ();
else
@ -137,7 +140,7 @@ function configure_modules_form () {
$("#text-warning_inverse").attr ("value", (data["warning_inverse"] == 0) ? 0 : data["warning_inverse"]);
$("#component_loading").hide ();
$("#id_module_type").change ();
if($("#id_category").is("select")) {
if ($("#id_category").is("select")) {
$("#id_category option[value="+data["id_category"]+"]").select (1);
}
else {
@ -300,7 +303,7 @@ function configure_modules_form () {
$("#text-warning_inverse").attr ("value", (data["warning_inverse"] == 0) ? 0 : data["warning_inverse"]);
$("#component_loading").hide ();
$("#id_module_type").change ();
if($("#id_category").is("select")) {
if ($("#id_category").is("select")) {
$("#id_category option[value="+data["id_category"]+"]").select (1);
}
else {
@ -316,14 +319,14 @@ function configure_modules_form () {
$("select[name='id_tag_available[]']").append($("<option></option>").val($(this).attr('value')).html($(this).text()));
}
});
if($("#id_tag_available option").length > 1) {
if ($("#id_tag_available option").length > 1) {
$("#id_tag_available").find("option[value='']").remove();
}
if($("#id_tag_selected option").length == 0) {
if ($("#id_tag_selected option").length == 0) {
$("select[name='id_tag_selected[]']").append($("<option></option>").val('').html('<i>None</i>'));
}
if(tags != '') {
if (tags != '') {
tags = tags.split(',');
// Fill the selected tags box with select ones
@ -449,7 +452,7 @@ function configure_modules_form () {
});
}
if(typeof $("#prediction_id_agent").pandoraSelectAgentModule == 'function') {
if (typeof $("#prediction_id_agent").pandoraSelectAgentModule == 'function') {
$("#prediction_id_agent").pandoraSelectAgentModule ({
moduleSelect: "select#prediction_module"
});
@ -461,7 +464,7 @@ function configure_modules_form () {
function delete_macro(prefix) {
var next_number = parseInt($('#next_macro').html());
// Is not possible delete first macro
if(next_number == 3) {
if (next_number == 3) {
$('#delete_macro_button').hide();
}
var next_row = parseInt($('#next_row').html());
@ -506,14 +509,14 @@ function new_macro(prefix) {
$row1.insertAfter('#'+prefix+nrow2);
// Change labels
for(i=0;i<=3;i++) {
for(i = 0; i <= 3; i++) {
var label1 = $("#"+prefix+nrow3+"-"+i).html();
var exp_reg = new RegExp('field'+current_number, 'g');
label1 = label1.replace(exp_reg,'field'+next_number);
$("#"+prefix+nrow3+"-"+i).html(label1);
}
for(i=0;i<=1;i++) {
for(i = 0; i <= 1; i++) {
var label2 = $("#"+prefix+nrow4+"-"+i).html();
var exp_reg = new RegExp('field'+current_number, 'g');
label2 = label2.replace(exp_reg,'field'+next_number);
@ -574,7 +577,7 @@ function add_macro_field(macro, row_model_id) {
var fields = $('.macro_field').size();
// If is the first, we insert it after model row
if(fields == 0) {
if (fields == 0) {
$macro_field.insertAfter('#'+ row_model_id +'_field');
}
// If there are more fields, we insert it after the last one
@ -583,7 +586,7 @@ function add_macro_field(macro, row_model_id) {
}
// Change the label
if(macro_help == '') {
if (macro_help == '') {
$('#'+row_id).children().eq(0).html(macro_desc);
}
else {
@ -621,7 +624,7 @@ function load_plugin_macros_fields(row_model_id) {
// Delete all the macro fields
$('.macro_field').remove();
if(data['array'] != null) {
if (data['array'] != null) {
$('#hidden-macros').val(data['base64']);
jQuery.each (data['array'], function (i, macro) {
if(macro['desc'] != '') {