2011-12-07 Sergio Martin <sergio.martin@artica.es>

* include/functions_modules.php
	godmode/agentes/module_manager_editor_common.php
	godmode/agentes/module_manager.php: Added status column in 
	godmode view of modules and added delete button in 
	edition module view

	* operation/agentes/estado_monitores.php: Fixed missed
	extra query to not show modules of foreign policies



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5239 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-12-07 14:19:05 +00:00
parent 6eff29a159
commit ce862be0ec
5 changed files with 104 additions and 79 deletions

View File

@ -1,3 +1,14 @@
2011-12-07 Sergio Martin <sergio.martin@artica.es>
* include/functions_modules.php
godmode/agentes/module_manager_editor_common.php
godmode/agentes/module_manager.php: Added status column in
godmode view of modules and added delete button in
edition module view
* operation/agentes/estado_monitores.php: Fixed missed
extra query to not show modules of foreign policies
2011-12-07 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2011-12-07 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* operation/agentes/estado_agente.php: Added filter by summarized * operation/agentes/estado_agente.php: Added filter by summarized

View File

@ -342,20 +342,21 @@ $table->head[4] = __('Interval') . ' ' .
'<a href="' . $url . '&sort_field=interval&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp)) . '</a>' . '<a href="' . $url . '&sort_field=interval&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp)) . '</a>' .
'<a href="' . $url . '&sort_field=interval&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown)) . '</a>'; '<a href="' . $url . '&sort_field=interval&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown)) . '</a>';
$table->head[5] = __('Description'); $table->head[5] = __('Description');
$table->head[6] = __('Warn'); $table->head[6] = __('Status');
$table->head[7] = __('Warn');
$table->head[7] = __('Action'); $table->head[8] = __('Action');
$table->rowstyle = array(); $table->rowstyle = array();
$table->style = array (); $table->style = array ();
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'font-weight: bold';
$table->size = array (); $table->size = array ();
$table->size[2] = '55px'; $table->size[2] = '55px';
$table->size[7] = '100px'; $table->size[8] = '100px';
$table->align = array (); $table->align = array ();
$table->align[2] = 'center'; $table->align[2] = 'center';
$table->align[7] = 'left'; $table->align[8] = 'left';
$table->data = array (); $table->data = array ();
$agent_interval = agents_get_interval ($id_agente); $agent_interval = agents_get_interval ($id_agente);
@ -477,30 +478,36 @@ foreach ($modules as $module) {
$data[5] = ui_print_truncate_text($module['descripcion'], 50, false); $data[5] = ui_print_truncate_text($module['descripcion'], 50, false);
$module_status = db_get_row('tagente_estado', 'id_agente_modulo', $module['id_agente_modulo']);
modules_get_status($module['id_agente_modulo'], $module_status['estado'], $module_status['datos'], $status, $title);
$data[6] = ui_print_status_image($status, $title, true);
// MAX / MIN values // MAX / MIN values
$data[6] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]); $data[7] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]);
// Delete module // Delete module
$data[7] = html_print_checkbox('id_delete[]', $module['id_agente_modulo'], false, true); $data[8] = html_print_checkbox('id_delete[]', $module['id_agente_modulo'], false, true);
$data[7] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo'].'" $data[8] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo'].'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[7] .= html_print_image ('images/cross.png', true, $data[8] .= html_print_image ('images/cross.png', true,
array ('title' => __('Delete'))); array ('title' => __('Delete')));
$data[7] .= '</a> '; $data[8] .= '</a> ';
$data[7] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&duplicate_module='.$module['id_agente_modulo'].'" $data[8] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&duplicate_module='.$module['id_agente_modulo'].'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[7] .= html_print_image ('images/copy.png', true, $data[8] .= html_print_image ('images/copy.png', true,
array ('title' => __('Duplicate'))); array ('title' => __('Duplicate')));
$data[7] .= '</a> '; $data[8] .= '</a> ';
// Make a data normalization // Make a data normalization
if (isset($numericModules[$type])) { if (isset($numericModules[$type])) {
if ($numericModules[$type] === true) { if ($numericModules[$type] === true) {
$data[7] .= '&nbsp;<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; $data[8] .= '&nbsp;<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[7] .= html_print_image ('images/chart_curve.png', true, $data[8] .= html_print_image ('images/chart_curve.png', true,
array ('title' => __('Normalize'))); array ('title' => __('Normalize')));
$data[7] .= '</a>'; $data[8] .= '</a>';
} }
} }

View File

@ -124,6 +124,15 @@ $table_simple->style[2] = 'font-weight: bold; vertical-align: top';
$table_simple->data[0][0] = __('Name'); $table_simple->data[0][0] = __('Name');
$table_simple->data[0][1] = html_print_input_text ('name', io_safe_output($name), '', 50, 100, true, $disabledBecauseInPolicy); $table_simple->data[0][1] = html_print_input_text ('name', io_safe_output($name), '', 50, 100, true, $disabledBecauseInPolicy);
if (isset($id_agent_module) && isset($id_agente)) {
$table_simple->data[0][1] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$id_agent_module.'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$table_simple->data[0][1] .= html_print_image ('images/cross.png', true,
array ('title' => __('Delete module')));
$table_simple->data[0][1] .= '</a> ';
}
$table_simple->data[0][2] = __('Disabled'); $table_simple->data[0][2] = __('Disabled');
$table_simple->data[0][3] = html_print_checkbox ("disabled", 1, $disabled, true); $table_simple->data[0][3] = html_print_checkbox ("disabled", 1, $disabled, true);

View File

@ -995,29 +995,6 @@ function modules_get_agentmodule_last_status($id_agentmodule = 0) {
return $status_row['last_status']; return $status_row['last_status'];
} }
/**
* Get the worst status of all modules of the agents of a group.
*
* @param int Id module to check.
*
* @return int Worst status of a module for all of its agents.
* The value -1 is returned in case the agent has exceed its interval. <-- DISABLED
*/
function modules_get_status ($id_module = 0) {
$time = get_system_time ();
$status = db_get_sql ("SELECT estado
FROM tagente_estado, tagente_modulo
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.id_agente_modulo = ".$id_module);
// TODO: Check any alert for that agent who has recept alerts fired
return $status;
}
/** /**
* Get the current value of an agent module. * Get the current value of an agent module.
* *
@ -1188,4 +1165,54 @@ function modules_get_modulegroup_name ($modulegroup_id) {
return (string) db_get_value ('name', 'tmodule_group', 'id_mg', (int) $modulegroup_id); return (string) db_get_value ('name', 'tmodule_group', 'id_mg', (int) $modulegroup_id);
} }
/**
* Gets a module status an modify the status and title reference variables
*
* @param mixed The module data (Necessary $module['datos'] and $module['estado']
* @param int status reference variable
* @param string title reference variable
*
*/
function modules_get_status($id_agent_module, $db_status, $data, &$status, &$title) {
$status = STATUS_MODULE_WARNING;
$title = "";
if ($db_status == 1) {
$status = STATUS_MODULE_CRITICAL;
$title = __('CRITICAL');
}
elseif ($db_status == 2) {
$status = STATUS_MODULE_WARNING;
$title = __('WARNING');
}
elseif ($db_status == 0) {
$status = STATUS_MODULE_OK;
$title = __('NORMAL');
}
elseif ($db_status == 3) {
$last_status = modules_get_agentmodule_last_status($id_agent_module);
switch($last_status) {
case 0:
$status = STATUS_MODULE_OK;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL');
break;
case 1:
$status = STATUS_MODULE_CRITICAL;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL');
break;
case 2:
$status = STATUS_MODULE_WARNING;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('WARNING');
break;
}
}
if (is_numeric($data)) {
$title .= ": " . format_for_graph($data);
}
else {
$title .= ": " . substr(io_safe_output($data),0,42);
}
}
?> ?>

View File

@ -152,6 +152,15 @@ switch ($config["dbtype"]) {
break; break;
} }
// Get the enterprise acl sql condition
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente));
if($extra_sql == ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}else if ($extra_sql != '') {
$extra_sql = "(($extra_sql) OR id_policy_module = 0) AND";
}
// Get all module from agent // Get all module from agent
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
@ -172,8 +181,8 @@ switch ($config["dbtype"]) {
SELECT * FROM tagente_estado, (SELECT * FROM tagente_modulo WHERE id_agente = %d AND disabled = 0 AND delete_pending = 0) tagente_modulo SELECT * FROM tagente_estado, (SELECT * FROM tagente_modulo WHERE id_agente = %d AND disabled = 0 AND delete_pending = 0) tagente_modulo
LEFT JOIN tmodule_group ON tagente_modulo.id_module_group = tmodule_group.id_mg LEFT JOIN tmodule_group ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_estado.utimestamp != 0 AND %s tagente_estado.utimestamp != 0
ORDER BY tagente_modulo.id_module_group , %s %s", $id_agente, $order['field'], $order['order']); ORDER BY tagente_modulo.id_module_group , %s %s", $id_agente, $extra_sql, $order['field'], $order['order']);
break; break;
// If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table() // If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table()
case "oracle": case "oracle":
@ -330,46 +339,8 @@ foreach ($modules as $module) {
html_print_image("images/tag_red.png", true, array("id" => 'tag-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> '; html_print_image("images/tag_red.png", true, array("id" => 'tag-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> ';
} }
$data[4] = ui_print_string_substr ($module["descripcion"], 40, true, 9); $data[4] = ui_print_string_substr ($module["descripcion"], 40, true, 9);
$status = STATUS_MODULE_WARNING;
$title = "";
if ($module["estado"] == 1) {
$status = STATUS_MODULE_CRITICAL;
$title = __('CRITICAL');
}
elseif ($module["estado"] == 2) {
$status = STATUS_MODULE_WARNING;
$title = __('WARNING');
}
elseif ($module["estado"] == 0) {
$status = STATUS_MODULE_OK;
$title = __('NORMAL');
}
elseif ($module["estado"] == 3) {
$last_status = modules_get_agentmodule_last_status($module['id_agente_modulo']);
switch($last_status) {
case 0:
$status = STATUS_MODULE_OK;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL');
break;
case 1:
$status = STATUS_MODULE_CRITICAL;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL');
break;
case 2:
$status = STATUS_MODULE_WARNING;
$title = __('UNKNOWN')." - ".__('Last status')." ".__('WARNING');
break;
}
}
if (is_numeric($module["datos"])) { modules_get_status($module['id_agente_modulo'], $module['estado'], $module['datos'], $status, $title);
$title .= ": " . format_for_graph($module["datos"]);
}
else {
$title .= ": " . substr(io_safe_output($module["datos"]),0,42);
}
$data[5] = ui_print_status_image($status, $title, true); $data[5] = ui_print_status_image($status, $title, true);