2009-03-03 Evi Vanoost <vanooste@rcbi.rochester.edu>

* general/logon_ok.php: Minor edit in language and colors for warning
	
	* include/functions_reporting.php: Changed get_group_stats for better
	queries based on query debugging.
	
	* include/functions_db.php: Change get_server_info for better queries
	based on query debugging. Documentation updates and function updates
	
	* operation/agentes/tactical.php: Removed a row with duplicate info
	
	* operation/reporting/reporting_viewer.php, 
	operation/reporting/reporting_xml.php, include/functions_modules.php,
	godmode/agentes/module_manager_editor.php:
	Function renaming.

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1502 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2009-03-03 22:12:06 +00:00
parent bb35abdf77
commit b92e874d23
9 changed files with 95 additions and 108 deletions

View File

@ -1,3 +1,20 @@
2009-03-03 Evi Vanoost <vanooste@rcbi.rochester.edu>
* general/logon_ok.php: Minor edit in language and colors for warning
* include/functions_reporting.php: Changed get_group_stats for better
queries based on query debugging.
* include/functions_db.php: Change get_server_info for better queries
based on query debugging. Documentation updates and function updates
* operation/agentes/tactical.php: Removed a row with duplicate info
* operation/reporting/reporting_viewer.php,
operation/reporting/reporting_xml.php, include/functions_modules.php,
godmode/agentes/module_manager_editor.php:
Function renaming.
2009-03-03 Esteban Sanchez <estebans@artica.es> 2009-03-03 Esteban Sanchez <estebans@artica.es>
* godmode/alerts/configure_alert_template.php: Add id to separator * godmode/alerts/configure_alert_template.php: Add id to separator

View File

@ -59,7 +59,7 @@ echo '</div>';
// Site stats // Site stats
echo '<div style="width:300px; float:left; padding-left: 30px;" id="rightcolumn">'; echo '<div style="width:300px; float:left; padding-left: 30px;" id="rightcolumn">';
$data = get_group_stats (0); $data = get_group_stats ();
$table->class = "databox"; $table->class = "databox";
$table->cellpadding = 4; $table->cellpadding = 4;
@ -91,27 +91,27 @@ $cells[0][1] = $data["total_agents"];
$cells[0]["color"] = "#000"; $cells[0]["color"] = "#000";
$cells[0]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60"; $cells[0]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60";
$cells[1][0] = __('Total checks'); $cells[1][0] = __('Monitor checks');
$cells[1][1] = $data["total_checks"]; $cells[1][1] = $data["monitor_checks"];
$cells[1]["color"] = "#000"; $cells[1]["color"] = "#000";
$cells[1]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=-1"; $cells[1]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=-1";
$cells[2][0] = __('Modules critical'); $cells[2][0] = __('Monitors critical');
$cells[2][1] = $data["monitor_critical"]; $cells[2][1] = $data["monitor_critical"];
$cells[2]["color"] = "#f00"; $cells[2]["color"] = "#f00";
$cells[2]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=2"; $cells[2]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=2";
$cells[3][0] = __('Modules warning'); $cells[3][0] = __('Monitors warning');
$cells[3][1] = $data["monitor_warning"]; $cells[3][1] = $data["monitor_warning"];
$cells[3]["color"] = "#FFB900"; $cells[3]["color"] = "#FFB900";
$cells[3]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=1"; $cells[3]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=1";
$cells[4][0] = __('Modules normal'); $cells[4][0] = __('Monitors normal');
$cells[4][1] = $data["monitor_ok"]; $cells[4][1] = $data["monitor_ok"];
$cells[4]["color"] = "#00ff00"; $cells[4]["color"] = "#00ff00";
$cells[4]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=0"; $cells[4]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=0";
$cells[5][0] = __('Modules unknown'); $cells[5][0] = __('Monitors unknown');
$cells[5][1] = $data["monitor_unknown"]; $cells[5][1] = $data["monitor_unknown"];
$cells[5]["color"] = "#aaaaaa"; $cells[5]["color"] = "#aaaaaa";
$cells[5]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=3"; $cells[5]["href"] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=3";
@ -176,4 +176,4 @@ foreach ($sessions as $session) {
} }
print_table ($table); print_table ($table);
echo "</div>"; // activity echo "</div>"; // activity
?> ?>

View File

@ -75,7 +75,7 @@ require_once ("include/functions_exportserver.php");
// Using network component to fill some fields // Using network component to fill some fields
if ($id_agent_module) { if ($id_agent_module) {
$module = get_agent_module ($id_agent_module); $module = get_agentmodule ($id_agent_module);
$moduletype = $module['id_modulo']; $moduletype = $module['id_modulo'];
$name = $module['nombre']; $name = $module['nombre'];
$description = $module['descripcion']; $description = $module['descripcion'];

View File

@ -313,15 +313,14 @@ function get_group_agents ($id_group = 0, $disabled = false, $case = "lower") {
} }
/** /**
* Get a singlemodule in an agent. * Get a single module information.
* *
* @param mixed Agent id to get modules. It can also be an array of agent id's. * @param int agentmodule id to get.
* *
* @return array An array with all modules in the agent. * @return array An array with module information
* If multiple rows are selected, they will be in an array
*/ */
function get_agent_module ($id_agent_module) { function get_agentmodule ($id_agentmodule) {
return get_db_row ('tagente_modulo', 'id_agente_modulo', (int) $id_agent_module); return get_db_row ('tagente_modulo', 'id_agente_modulo', (int) $id_agentmodule);
} }
/** /**
@ -337,7 +336,7 @@ function get_agent_module ($id_agent_module) {
* the WHERE keyword). Example: * the WHERE keyword). Example:
<code> <code>
Both are similars: Both are similars:
$modules = get_agent_modules ($id_agent, false, array ('disabled', 0)); $modules = get_agent_modules ($id_agent, false, array ('disabled' => 0));
$modules = get_agent_modules ($id_agent, false, 'disabled = 0'); $modules = get_agent_modules ($id_agent, false, 'disabled = 0');
Both are similars: Both are similars:
@ -2599,6 +2598,7 @@ function get_server_info ($id_server = -1) {
$sql = "SELECT * FROM tserver".$select_id; $sql = "SELECT * FROM tserver".$select_id;
$result = get_db_all_rows_sql ($sql); $result = get_db_all_rows_sql ($sql);
$time = get_system_time ();
if (empty ($result)) { if (empty ($result)) {
return false; return false;
@ -2624,36 +2624,44 @@ function get_server_info ($id_server = -1) {
$server["type"] = "unknown"; $server["type"] = "unknown";
} }
$server["modules"] = get_db_sql ("SELECT COUNT(*) FROM tagente_estado, tagente_modulo $modules = array ();
$result = get_db_all_rows_sql ("SELECT tagente_estado.id_agente_modulo, tagente_modulo.nombre FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente_modulo.disabled = 0
AND tagente_modulo.delete_pending = 0
AND tagente_estado.running_by = ".$server["id_server"]); AND tagente_estado.running_by = ".$server["id_server"]);
if ($result === false) {
$result = array ();
}
foreach ($result as $module_info) {
$modules[$module_info["id_agente_modulo"]] = $module_info["nombre"];
}
$server["modules"] = count ($modules);
$server["module_info"] = $modules; //We have it, so we might as well pass it just in case somebody might find out a use for it.
$server["module_lag"] = 0;
$server["lag"] = 0;
if ($server["modules"] > 0) {
//If the server doesn't have modules, it doesn't have lag
$server["module_lag"] = get_db_sql ("SELECT COUNT(*) FROM tagente_estado, tagente_modulo, tagente $result = get_db_row_sql ("SELECT COUNT(*) AS module_lag, MAX(last_execution_try - current_interval) AS lag FROM tagente_estado
WHERE tagente_estado.last_execution_try > 0 WHERE last_execution_try > 0
AND tagente_estado.running_by = ".$server["id_server"]." AND current_interval > 0
AND tagente_modulo.id_agente = tagente.id_agente AND running_by = ".$server["id_server"]."
AND tagente.disabled = 0 AND id_agente_modulo IN (".implode (",", array_keys ($modules)).")
AND tagente_modulo.disabled = 0 AND (UNIX_TIMESTAMP() - last_execution_try - current_interval < current_interval * 2)");
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
// Lag over 1200 seconds is not lag, is module without contacting data in several time.or with a // Lag over current_interval * 2 is not lag, it's a timed out module
// 1200 sec is 20 min // And we can't check current_interval = 0 (data modules) because they come as they want
$server["lag"] = get_db_sql ("SELECT MAX(tagente_estado.last_execution_try - tagente_estado.current_interval)
FROM tagente_estado, tagente_modulo, tagente
WHERE tagente_estado.last_execution_try > 0
AND tagente_estado.running_by = ".$server["id_server"]."
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
if (empty ($server["lag"])) { if (!empty ($result["lag"])) {
$server["lag"] = 0; $server["lag"] = $time - $result["lag"];
} else { }
$server["lag"] = get_system_time () - $server["lag"]; if (!empty ($result["module_lag"])) {
$server["module_lag"] = $result["module_lag"];
}
} }
//Push the raw data on the return stack //Push the raw data on the return stack

View File

@ -29,7 +29,7 @@
* False on error. * False on error.
*/ */
function copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent) { function copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent) {
$module = get_agent_module ($id_agent_module); $module = get_agentmodule ($id_agent_module);
if ($module === false) if ($module === false)
return false; return false;

View File

@ -79,13 +79,13 @@ function get_agentmodule_sla ($id_agentmodule, $period = 0, $min_value = 1, $max
} }
/** /**
* Get general stats info on a group * Get general statistical info on a group
* *
* @param int Group Id to get info. * @param int Group Id to get info from
* *
* @return array * @return array Group statistics
*/ */
function get_group_stats ($id_group) { function get_group_stats ($id_group = 0) {
$data = array (); $data = array ();
$data["monitor_checks"] = 0; $data["monitor_checks"] = 0;
$data["monitor_not_init"] = 0; $data["monitor_not_init"] = 0;
@ -110,64 +110,31 @@ function get_group_stats ($id_group) {
$groups = array_keys (get_user_groups ()); $groups = array_keys (get_user_groups ());
if ($id_group > 0 && in_array ($id_group, $groups)) { if ($id_group > 0 && in_array ($id_group, $groups)) {
//If a group is selected, and we have permissions to it then we don't need to look for them //If a singular group is selected, and we have permissions to it then we don't need to get all
$groups = array (); $groups = array ((int) $id_group);
$groups[0] = $id_group; } elseif ($id_group > 0) {
return $data; //We don't have selected any valid groups (select 0 for all groups your user can get to)
} }
//Select all modules in group
$agents = get_group_agents ($groups);
$modules = array ();
$module_ids = array ();
$agents = array_keys (get_group_agents ($groups));
if (empty ($agents)) { if (empty ($agents)) {
//No agents in this group, means no data //No agents in this group, means no data
return $data; return $data;
} }
$sql = sprintf ("SELECT tagente_estado.id_agente_modulo,
tagente_modulo.id_tipo_modulo,
estado, datos,
current_interval,
utimestamp
FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.id_agente IN (%s)", implode (",", array_keys ($agents)));
$result = get_db_all_rows_sql ($sql);
if ($result === false) {
//No data for any agents, means everything is 0 anyway.
return $data;
}
foreach ($result as $row) {
$last_update = $cur_time - $row["utimestamp"];
$data["monitor_checks"]++; $filter = 'id_agente IN ('.implode (",", $agents).') ';
//Check whether it's down, not init, unknown or OK $data["monitor_checks"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE ".$filter);
if ($last_update == $cur_time) { $data["monitor_not_init"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE ".$filter."AND utimestamp = 0");
//The utimestamp is 0 and has never been updated $data["monitor_unknown"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE ".$filter."AND UNIX_TIMESTAMP() - utimestamp >= current_interval * 2");
$data["monitor_not_init"]++; $data["monitor_critical"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE ".$filter."AND estado = 1");
} elseif ($last_update >= ($row["current_interval"] * 2)) { $data["monitor_warning"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE ".$filter."AND estado = 2");
//The utimestamp is greater than 2x the interval (it has timed out) $data["monitor_ok"] = $data["monitor_checks"] - $data["monitor_not_init"] - $data["monitor_unknown"] - $data["monitor_critical"] - $data["monitor_warning"];
$data["monitor_unknown"]++;
} elseif ($row["estado"] == 1){
$data["monitor_critical"]++;
} elseif ($row["estado"] == 2){
$data["monitor_warning"]++;
}
else {
$data["monitor_ok"]++;
}
} //End foreach module
//Moved it out of the loop otherwise for each module there would be a SQL query
$sql = sprintf ("SELECT times_fired FROM talert_template_modules WHERE id_agent_module IN (%s)", implode (",", array_keys ($agents))); $sql = sprintf ("SELECT times_fired FROM talert_template_modules WHERE id_agent_module IN (%s)", implode (",", array_keys ($agents)));
$result = get_db_all_rows_sql ($sql); $result = get_db_all_rows_sql ($sql);
if ($result === false) { if (empty ($result)) {
$result = array (); //It's possible there are no alerts so we don't return $result = array (); //It's possible there are no alerts so we don't return
} }
@ -182,7 +149,7 @@ function get_group_stats ($id_group) {
$data["total_agents"] = count ($agents); $data["total_agents"] = count ($agents);
$data["total_checks"] = $data["monitor_checks"]; $data["total_checks"] = $data["monitor_checks"];
$data["total_ok"] = $data["monitor_ok"]; $data["total_ok"] = $data["monitor_ok"];
// Todo, count SNMP Alerts and Inventory alerts here //TODO: count SNMP Alerts and Inventory alerts here
$data["total_alerts"] = $data["monitor_alerts"] + $data["monitor_alerts_fired"]; $data["total_alerts"] = $data["monitor_alerts"] + $data["monitor_alerts_fired"];
$data["total_alerts_fired"] = $data["monitor_alerts_fired"]; $data["total_alerts_fired"] = $data["monitor_alerts_fired"];
$data["total_alerts_fire_count"] = $data["monitor_alerts_fire_count"]; $data["total_alerts_fire_count"] = $data["monitor_alerts_fire_count"];
@ -225,7 +192,7 @@ function get_group_stats ($id_group) {
$data["alert_level"] = 100; $data["alert_level"] = 100;
} }
$data["server_sanity"] = 100 - $data["module_sanity"]; $data["server_sanity"] = format_numeric (100 - $data["module_sanity"], 1);
return $data; return $data;
} }
@ -483,9 +450,9 @@ function get_monitors_down_reporting_table ($monitors_down) {
* @param int Group to get the report * @param int Group to get the report
* @param bool Flag to return or echo the report (by default). * @param bool Flag to return or echo the report (by default).
* *
* @return string * @return HTML string with group report
*/ */
function general_group_reporting ($id_group, $return = false) { function print_group_reporting ($id_group, $return = false) {
$agents = get_group_agents ($id_group, false, "none"); $agents = get_group_agents ($id_group, false, "none");
$output = '<strong>'.__('Agents in group').': '.count ($agents).'</strong><br />'; $output = '<strong>'.__('Agents in group').': '.count ($agents).'</strong><br />';

View File

@ -49,7 +49,7 @@ function print_cells_temp ($cells) {
echo "<h2>".__('Pandora Agents')." &gt; ".__('Tactical view')."</h2>"; echo "<h2>".__('Pandora Agents')." &gt; ".__('Tactical view')."</h2>";
$data = get_group_stats (0); $data = get_group_stats ();
echo '<div style="width:265px; float:left; padding-right: 40px;" id="leftcolumn">'; echo '<div style="width:265px; float:left; padding-right: 40px;" id="leftcolumn">';
// Monitor checks // Monitor checks
@ -103,7 +103,7 @@ $cells[1]["color"] = "#000";
$cells[2][0] = __('Monitors warning'); $cells[2][0] = __('Monitors warning');
$cells[2][1] = $data["monitor_warning"]; $cells[2][1] = $data["monitor_warning"];
$cells[2]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; //Down $cells[2]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; //Down
$cells[2]["color"] = "#f00"; $cells[2]["color"] = "#FFB900";
$cells[3][0] = __('Monitors critical'); $cells[3][0] = __('Monitors critical');
$cells[3][1] = $data["monitor_critical"]; $cells[3][1] = $data["monitor_critical"];
@ -140,15 +140,10 @@ $cells[0][1] = $data["total_agents"];
$cells[0]["color"] = "#000"; $cells[0]["color"] = "#000";
$cells[0]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; $cells[0]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60";
$cells[1][0] = __('Total Checks'); $cells[1][0] = __('Uninitialized modules');
$cells[1][1] = $data["total_checks"]; $cells[1][1] = $data["server_sanity"] . "%";
$cells[1]["color"] = "#000"; $cells[1]["color"] = "#000";
$cells[1]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; $cells[1]["href"] = "index.php?sec=estado_server&sec2=operation/servers/view_server&refr=60";
$cells[2][0] = __('Uninitialized modules');
$cells[2][1] = $data["server_sanity"] . "%";
$cells[2]["color"] = "#000";
$cells[2]["href"] = "index.php?sec=estado_server&sec2=operation/servers/view_server&refr=60";
print_cells_temp ($cells); print_cells_temp ($cells);

View File

@ -443,7 +443,7 @@ foreach ($contents as $content) {
$data = array (); $data = array ();
$table->colspan[1][0] = 2; $table->colspan[1][0] = 2;
$data[0] = general_group_reporting ($report['id_group'], true); $data[0] = print_group_reporting ($report['id_group'], true);
array_push ($table->data, $data); array_push ($table->data, $data);
break; break;

View File

@ -261,7 +261,7 @@ foreach ($contents as $content) {
case 'general_group_report': case 'general_group_report':
$data["title"] = __('Group'); $data["title"] = __('Group');
$data["objdata"] = "<![CDATA["; $data["objdata"] = "<![CDATA[";
$data["objdata"] .= general_group_reporting ($report['id_group'], true); $data["objdata"] .= print_group_reporting ($report['id_group'], true);
$data["objdata"] .= "]]>"; $data["objdata"] .= "]]>";
break; break;
case 12: case 12: