2009-12-1 Sancho Lerena <slerena@artica.es>
* include/functions_reporting.php: Fixed some innacurate queries, skipping non-init modules, async modules and keepalive modules. * include/functions_servers.php: Improved LAG calculation algorithm, now is VERY precise. Added performance meter for local & remote checks. * include/config_process.php: error_reporting() has better default values now (skipping notices and non-important messages) for pandora_console.log * include/functions_agents.php: Fixing a problem in an alert SQL on function get_agent_alerts_simple(). * include/functions_db.php: get_server_info() moved to functions_servers.php * operation/events/events.php: Fixed a bug with pagination and other bug with user validated events search. * operation/agentes/status_monitor.php: Better management of async modules, non init and unknown modules. Now works as expected. * operation/agentes/estado_monitores.php: Removed blank space between icons to let table row more compact. * operation/agentes/tactical.php: Added performance information. Removed some information (not used) from snmp and recon servers. * general/header.php: Latest changes here don't work as expected. Rewritten and now works fine (enterprise/open logo in header). * godmode/admin_access_logs.php: Fixed pagination bug in tracker. Added table layout with two alternate colors (rowOdd method). * operation/servers/view_server.php, * godmode/servers/modificar_server.php: Added include to functions_servers.php to use the new server functions, moved from functions_db.php. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2151 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
600e19d715
commit
9b1ad4eead
|
@ -1,3 +1,41 @@
|
|||
2009-12-1 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* include/functions_reporting.php: Fixed some innacurate queries, skipping
|
||||
non-init modules, async modules and keepalive modules.
|
||||
|
||||
* include/functions_servers.php: Improved LAG calculation algorithm, now
|
||||
is VERY precise. Added performance meter for local & remote checks.
|
||||
|
||||
* include/config_process.php: error_reporting() has better default values
|
||||
now (skipping notices and non-important messages) for pandora_console.log
|
||||
|
||||
* include/functions_agents.php: Fixing a problem in an alert SQL on function
|
||||
get_agent_alerts_simple().
|
||||
|
||||
* include/functions_db.php: get_server_info() moved to functions_servers.php
|
||||
|
||||
* operation/events/events.php: Fixed a bug with pagination and other bug with
|
||||
user validated events search.
|
||||
|
||||
* operation/agentes/status_monitor.php: Better management of async modules,
|
||||
non init and unknown modules. Now works as expected.
|
||||
|
||||
* operation/agentes/estado_monitores.php: Removed blank space between icons to
|
||||
let table row more compact.
|
||||
|
||||
* operation/agentes/tactical.php: Added performance information. Removed some
|
||||
information (not used) from snmp and recon servers.
|
||||
|
||||
* general/header.php: Latest changes here don't work as expected. Rewritten
|
||||
and now works fine (enterprise/open logo in header).
|
||||
|
||||
* godmode/admin_access_logs.php: Fixed pagination bug in tracker. Added table
|
||||
layout with two alternate colors (rowOdd method).
|
||||
|
||||
* operation/servers/view_server.php,
|
||||
* godmode/servers/modificar_server.php: Added include to functions_servers.php
|
||||
to use the new server functions, moved from functions_db.php.
|
||||
|
||||
2009-12-1 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_alerts.php: fix the select box of correlation alerts,
|
||||
|
|
|
@ -94,7 +94,8 @@ require_once ("include/functions_messages.php");
|
|||
echo "</td>";
|
||||
echo "<td width='20%' rowspan=2>";
|
||||
echo "<a href='index.php?sec=main'>";
|
||||
if (file_exists ($ENTERPRISE_DIR."/load_enterprise.php")){
|
||||
|
||||
if (!defined ('PANDORA_ENTERPRISE')){
|
||||
echo "<img border=0 src='images/pandora_header_logo.png'>";
|
||||
} else {
|
||||
echo "<img border=0 src='images/pandora_header_logo_enterprise.png'>";
|
||||
|
|
|
@ -70,13 +70,13 @@ if ($tipo_log != 'all') {
|
|||
$filter = sprintf (" WHERE accion = '%s'", $tipo_log);
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM tsesion".$filter;
|
||||
$sql = "SELECT COUNT(*) FROM tsesion ".$filter;
|
||||
$count = get_db_sql ($sql);
|
||||
$url = "index.php?sec=godmode&sec2=godmode/admin_access_logs&tipo_log=".$tipo_log;
|
||||
|
||||
|
||||
echo "<tr><td colspan=3>";
|
||||
pagination ($count, $url, $offset);
|
||||
pagination ($count, $url);
|
||||
echo "</td></td></tr></table>";
|
||||
|
||||
$sql = sprintf ("SELECT * FROM tsesion%s ORDER BY fecha DESC LIMIT %d, %d", $filter, $offset, $config["block_size"]);
|
||||
|
@ -88,7 +88,7 @@ if (empty ($result)) {
|
|||
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 4;
|
||||
$table->width = 700;
|
||||
$table->width = 750;
|
||||
$table->class = "databox";
|
||||
$table->size = array ();
|
||||
$table->data = array ();
|
||||
|
@ -105,8 +105,18 @@ $table->size[2] = 130;
|
|||
$table->size[3] = 100;
|
||||
$table->size[4] = 200;
|
||||
|
||||
$rowPair = true;
|
||||
$iterator = 0;
|
||||
|
||||
// Get data
|
||||
foreach ($result as $row) {
|
||||
if ($rowPair)
|
||||
$table->rowclass[$iterator] = 'rowPair';
|
||||
else
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
$data = array ();
|
||||
$data[0] = $row["ID_usuario"];
|
||||
$data[1] = $row["accion"];
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
// Load global vars
|
||||
require("include/config.php");
|
||||
require_once ("include/functions_servers.php");
|
||||
|
||||
check_login();
|
||||
|
||||
|
|
|
@ -22,11 +22,14 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC091127';
|
||||
$build_version = 'PC091201';
|
||||
$pandora_version = 'v3.0RC3-dev';
|
||||
|
||||
/* Help to debug problems. Override global PHP configuration */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// error_reporting(E_ALL);
|
||||
error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
|
||||
|
||||
ini_set("display_errors", 0);
|
||||
ini_set("error_log", $config["homedir"]."/pandora_console.log");
|
||||
|
||||
|
@ -57,6 +60,7 @@ process_config ();
|
|||
require_once ('streams.php');
|
||||
require_once ('gettext.php');
|
||||
|
||||
// Set IP address of user connected to Pandora console and store it in session array
|
||||
global $REMOTE_ADDR;
|
||||
|
||||
$config["remote_addr"] = $_SERVER['REMOTE_ADDR'];
|
||||
|
|
|
@ -113,16 +113,16 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa
|
|||
|
||||
switch ($filter) {
|
||||
case "notfired":
|
||||
$filter = ' AND times_fired = 0 AND disabled = 0';
|
||||
$filter = ' AND times_fired = 0 AND talert_template_modules.disabled = 0';
|
||||
break;
|
||||
case "fired":
|
||||
$filter = ' AND times_fired > 0 AND disabled = 0';
|
||||
$filter = ' AND times_fired > 0 AND talert_template_modules.disabled = 0';
|
||||
break;
|
||||
case "disabled":
|
||||
$filter = ' AND disabled = 1';
|
||||
$filter = ' AND talert_template_modules.disabled = 1';
|
||||
break;
|
||||
case 'all_enabled':
|
||||
$filter = ' AND disabled = 0';
|
||||
$filter = ' AND talert_template_modules.disabled = 0';
|
||||
break;
|
||||
default:
|
||||
$filter = '';
|
||||
|
|
|
@ -2887,188 +2887,6 @@ function delete_agent ($id_agents) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will get all the server information in an array or a specific server
|
||||
*
|
||||
* @param mixed An optional integer or array of integers to select specific servers
|
||||
*
|
||||
* @return mixed False in case the server doesn't exist or an array with info.
|
||||
*/
|
||||
function get_server_info ($id_server = -1) {
|
||||
if (is_array ($id_server)) {
|
||||
$select_id = " WHERE id_server IN (".implode (",", $id_server).")";
|
||||
} elseif ($id_server > 0) {
|
||||
$select_id = " WHERE id_server IN (".(int) $id_server.")";
|
||||
} else {
|
||||
$select_id = "";
|
||||
}
|
||||
|
||||
$modules_info = array ();
|
||||
$modules_total = array ();
|
||||
$result = get_db_all_rows_sql ("SELECT DISTINCT(tagente_estado.running_by), COUNT(*) AS modules, id_modulo
|
||||
FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.delete_pending = 0 GROUP BY running_by");
|
||||
if (empty ($result)) {
|
||||
$result = array ();
|
||||
}
|
||||
|
||||
foreach ($result as $row) {
|
||||
$modules_info[$row["running_by"]] = $row["modules"];
|
||||
if (!isset ($modules_total[$row["id_modulo"]])) {
|
||||
$modules_total[$row["id_modulo"]] = $row["modules"];
|
||||
} else {
|
||||
$modules_total[$row["id_modulo"]] += $row["modules"];
|
||||
}
|
||||
}
|
||||
|
||||
$recon_total = get_db_sql ("SELECT COUNT(*) FROM trecon_task");
|
||||
|
||||
$sql = "SELECT * FROM tserver".$select_id . " ORDER BY server_type";
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
$time = get_system_time ();
|
||||
|
||||
if (empty ($result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$return = array ();
|
||||
foreach ($result as $server) {
|
||||
switch ($server['server_type']) {
|
||||
case 0:
|
||||
$server["img"] = print_image ("images/data.png", true, array ("title" => __('Data server')));
|
||||
$server["type"] = "data";
|
||||
$id_modulo = 1;
|
||||
break;
|
||||
case 1:
|
||||
$server["img"] = print_image ("images/network.png", true, array ("title" => __('Network server')));
|
||||
$server["type"] = "network";
|
||||
$id_modulo = 2;
|
||||
break;
|
||||
case 2:
|
||||
$server["img"] = print_image ("images/snmp.png", true, array ("title" => __('SNMP server')));
|
||||
$server["type"] = "snmp";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 3:
|
||||
$server["img"] = print_image ("images/recon.png", true, array ("title" => __('Recon server')));
|
||||
$server["type"] = "recon";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 4:
|
||||
$server["img"] = print_image ("images/plugin.png", true, array ("title" => __('Plugin server')));
|
||||
$server["type"] = "plugin";
|
||||
$id_modulo = 4;
|
||||
break;
|
||||
case 5:
|
||||
$server["img"] = print_image ("images/chart_bar.png", true, array ("title" => __('Prediction server')));
|
||||
$server["type"] = "prediction";
|
||||
$id_modulo = 5;
|
||||
break;
|
||||
case 6:
|
||||
$server["img"] = print_image ("images/wmi.png", true, array ("title" => __('WMI server')));
|
||||
$server["type"] = "wmi";
|
||||
$id_modulo = 6;
|
||||
break;
|
||||
case 7:
|
||||
$server["img"] = print_image ("images/server_export.png", true, array ("title" => __('Export server')));
|
||||
$server["type"] = "export";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 8:
|
||||
$server["img"] = print_image ("images/page_white_text.png", true, array ("title" => __('Inventory server')));
|
||||
$server["type"] = "inventory";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 9:
|
||||
$server["img"] = print_image ("images/world.png", true, array ("title" => __('Web server')));
|
||||
$server["type"] = "web";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
default:
|
||||
$server["img"] = '';
|
||||
$server["type"] = "unknown";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty ($modules_info[$server["id_server"]])) {
|
||||
$server["modules"] = 0;
|
||||
} else {
|
||||
$server["modules"] = $modules_info[$server["id_server"]];
|
||||
}
|
||||
$server["module_lag"] = 0;
|
||||
$server["lag"] = 0;
|
||||
$server["load"] = 0;
|
||||
|
||||
if (!isset ($modules_total[$id_modulo])) {
|
||||
$server["modules_total"] = 0;
|
||||
} else {
|
||||
$server["modules_total"] = $modules_total[$id_modulo];
|
||||
}
|
||||
|
||||
if ($id_modulo > 0 && $server["modules"] > 0) {
|
||||
//If the server doesn't have modules, it doesn't have lag so nothing to calculate. If it's not a module server, don't go here either
|
||||
$result = get_db_row_sql ("SELECT COUNT(*) AS module_lag, MAX(last_execution_try - current_interval) AS lag FROM tagente_estado
|
||||
WHERE last_execution_try > 0
|
||||
AND current_interval > 0
|
||||
AND running_by = ".$server["id_server"]."
|
||||
AND (UNIX_TIMESTAMP() - last_execution_try - current_interval < current_interval * 2)");
|
||||
|
||||
// Lag over current_interval * 2 is not lag, it's a timed out module
|
||||
// And we can't check current_interval = 0 (data modules) because they come as they want
|
||||
|
||||
if (!empty ($result["lag"])) {
|
||||
$server["lag"] = $time - $result["lag"];
|
||||
}
|
||||
if (!empty ($result["module_lag"])) {
|
||||
$server["module_lag"] = $result["module_lag"];
|
||||
}
|
||||
} else {
|
||||
switch ($server["type"]) {
|
||||
case "recon":
|
||||
$server["name"] = '<a href="index.php?sec=estado_server&sec2=operation/servers/view_server_detail&server_id='.$server["id_server"].'">'.$server["name"].'</a>';
|
||||
|
||||
//Get recon taks info
|
||||
$tasks = get_db_all_rows_sql ("SELECT status, utimestamp FROM trecon_task WHERE id_recon_server = ".$server["id_server"]);
|
||||
if (empty ($tasks)) {
|
||||
$tasks = array ();
|
||||
}
|
||||
//Total jobs running on this recon server
|
||||
$server["modules"] = count ($tasks);
|
||||
|
||||
//Total recon jobs (all servers)
|
||||
$server["modules_total"] = $recon_total;
|
||||
|
||||
//Lag (take average active time of all active tasks)
|
||||
$server["module_lag"] = 0;
|
||||
$lags = array ();
|
||||
foreach ($tasks as $task) {
|
||||
if ($task["status"] > 0 && $task["status"] <= 100) {
|
||||
$lags[] = $time - $task["utimestamp"];
|
||||
//Module lag is actually the number of jobs that is currently running
|
||||
$server["module_lag"]++;
|
||||
}
|
||||
}
|
||||
if (count ($lags) > 0) {
|
||||
$server["lag"] = (int) array_sum ($lags) / count ($lags);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
$server["lag_txt"] = ($server["lag"] == 0 ? '-' : human_time_description_raw ($server["lag"])) . " / ". $server["module_lag"];
|
||||
if ($server["modules_total"] > 0) {
|
||||
$server["load"] = round ($server["modules"] / $server["modules_total"] * 100);
|
||||
}
|
||||
|
||||
//Push the raw data on the return stack
|
||||
$return[$server["id_server"]] = $server;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets the agent group for a given agent module
|
||||
|
|
|
@ -146,13 +146,17 @@ function get_group_stats ($id_group = 0) {
|
|||
if (empty ($alerts))
|
||||
$alerts = array ();
|
||||
|
||||
$disabledQuery = "id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled = 0) AND ";
|
||||
$disabledQuery = "tagente_estado.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled = 0) AND ";
|
||||
|
||||
$data["monitor_checks"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE " . $disabledQuery . $filter);
|
||||
$data["monitor_not_init"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE " . $disabledQuery . $filter."AND utimestamp = 0");
|
||||
$data["monitor_unknown"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE " . $disabledQuery . $filter."AND utimestamp > 0 AND UNIX_TIMESTAMP() - utimestamp >= current_interval * 2");
|
||||
|
||||
$data["monitor_unknown"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado, tagente_modulo WHERE " . $disabledQuery . $filter."AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_tipo_modulo NOT IN (21,23,23, 100) AND utimestamp > 0 AND UNIX_TIMESTAMP() - utimestamp >= current_interval * 2");
|
||||
|
||||
$data["monitor_critical"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE " . $disabledQuery . $filter."AND utimestamp > 0 AND estado = 1 AND UNIX_TIMESTAMP() - utimestamp < current_interval * 2");
|
||||
|
||||
$data["monitor_warning"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE ".$filter."AND utimestamp > 0 AND estado = 2 AND UNIX_TIMESTAMP() - utimestamp < current_interval * 2");
|
||||
|
||||
$data["monitor_ok"] = $data["monitor_checks"] - $data["monitor_not_init"] - $data["monitor_unknown"] - $data["monitor_critical"] - $data["monitor_warning"];
|
||||
|
||||
$data["monitor_alerts"] = 0;
|
||||
|
@ -783,8 +787,10 @@ function get_agent_module_info ($id_agent) {
|
|||
}
|
||||
|
||||
$sql = sprintf ("SELECT * FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND
|
||||
tagente_modulo.disabled = 0 AND tagente_modulo.id_agente = %d", $id_agent);
|
||||
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.utimestamp > 0
|
||||
AND tagente_modulo.id_agente = %d", $id_agent);
|
||||
|
||||
$modules = get_db_all_rows_sql ($sql);
|
||||
|
||||
|
@ -808,7 +814,7 @@ function get_agent_module_info ($id_agent) {
|
|||
$return["last_contact"] = $module["utimestamp"];
|
||||
}
|
||||
|
||||
if ($module["id_tipo_modulo"] < 21 || $module["id_tipo_modulo"] != 100) {
|
||||
if (($module["id_tipo_modulo"] < 21 || $module["id_tipo_modulo"] > 23 ) AND ($module["id_tipo_modulo"] != 100)) {
|
||||
$async = 0;
|
||||
} else {
|
||||
$async = 1;
|
||||
|
@ -876,8 +882,10 @@ function get_agent_module_info_with_filter ($id_agent,$filter = '') {
|
|||
}
|
||||
|
||||
$sql = sprintf ("SELECT * FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND
|
||||
tagente_modulo.disabled = 0 AND tagente_modulo.id_agente = %d", $id_agent);
|
||||
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.utimestamp > 0
|
||||
AND tagente_modulo.id_agente = %d", $id_agent);
|
||||
|
||||
$sql .= $filter;
|
||||
|
||||
|
@ -903,7 +911,7 @@ function get_agent_module_info_with_filter ($id_agent,$filter = '') {
|
|||
$return["last_contact"] = $module["utimestamp"];
|
||||
}
|
||||
|
||||
if ($module["id_tipo_modulo"] < 21 || $module["id_tipo_modulo"] != 100) {
|
||||
if (($module["id_tipo_modulo"] < 21 || $module["id_tipo_modulo"] > 23 ) AND ($module["id_tipo_modulo"] != 100)) {
|
||||
$async = 0;
|
||||
} else {
|
||||
$async = 1;
|
||||
|
|
|
@ -55,4 +55,244 @@ function get_server_names () {
|
|||
return $servers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function will get several metrics from the database to get info about server performance
|
||||
* @return array with several data
|
||||
*/
|
||||
function get_server_performance () {
|
||||
|
||||
global $config;
|
||||
|
||||
$data = array();
|
||||
|
||||
// For remote modules:
|
||||
// Get total modules running
|
||||
|
||||
$data["total_remote_modules"] = get_db_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_modulo != 1 AND disabled = 0 AND utimestamp > 0");
|
||||
|
||||
$data["avg_interval_remote_modules"] = get_db_sql ("SELECT AVG(module_interval) FROM tagente_modulo, tagente_estado where tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND disabled = 0 AND id_modulo != 1 AND module_interval > 0 AND utimestamp > 0");
|
||||
|
||||
$data["remote_modules_rate"] = $data["total_remote_modules"] / $data["avg_interval_remote_modules"];
|
||||
|
||||
// For local modules (ignoring local modules with custom invervals for simplicity).
|
||||
|
||||
$data["total_local_modules"] = get_db_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND id_modulo = 1 AND disabled = 0 AND utimestamp > 0");
|
||||
|
||||
$data["avg_interval_local_modules"] = get_db_sql ("SELECT AVG(tagente.intervalo) FROM tagente WHERE disabled = 0 AND intervalo > 0");
|
||||
|
||||
$data["local_modules_rate"] = $data["total_local_modules"] / $data["avg_interval_local_modules"];
|
||||
|
||||
$data["total_modules"] = $data["total_local_modules"] + $data["total_remote_modules"];
|
||||
|
||||
return ($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This function will get all the server information in an array or a specific server
|
||||
*
|
||||
* @param mixed An optional integer or array of integers to select specific servers
|
||||
*
|
||||
* @return mixed False in case the server doesn't exist or an array with info.
|
||||
*/
|
||||
function get_server_info ($id_server = -1) {
|
||||
if (is_array ($id_server)) {
|
||||
$select_id = " WHERE id_server IN (".implode (",", $id_server).")";
|
||||
} elseif ($id_server > 0) {
|
||||
$select_id = " WHERE id_server IN (".(int) $id_server.")";
|
||||
} else {
|
||||
$select_id = "";
|
||||
}
|
||||
|
||||
$modules_info = array ();
|
||||
$modules_total = array ();
|
||||
$result = get_db_all_rows_sql ("SELECT DISTINCT(tagente_estado.running_by),
|
||||
COUNT(tagente_estado.id_agente_modulo) AS modules, id_modulo
|
||||
FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND utimestamp > 0
|
||||
GROUP BY running_by");
|
||||
if (empty ($result)) {
|
||||
$result = array ();
|
||||
}
|
||||
|
||||
foreach ($result as $row) {
|
||||
$modules_info[$row["running_by"]] = $row["modules"];
|
||||
if (!isset ($modules_total[$row["id_modulo"]])) {
|
||||
$modules_total[$row["id_modulo"]] = $row["modules"];
|
||||
} else {
|
||||
$modules_total[$row["id_modulo"]] += $row["modules"];
|
||||
}
|
||||
}
|
||||
|
||||
$recon_total = get_db_sql ("SELECT COUNT(*) FROM trecon_task");
|
||||
|
||||
$sql = "SELECT * FROM tserver".$select_id . " ORDER BY server_type";
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
$time = get_system_time ();
|
||||
|
||||
if (empty ($result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$return = array ();
|
||||
foreach ($result as $server) {
|
||||
switch ($server['server_type']) {
|
||||
case 0:
|
||||
$server["img"] = print_image ("images/data.png", true, array ("title" => __('Data server')));
|
||||
$server["type"] = "data";
|
||||
$id_modulo = 1;
|
||||
break;
|
||||
case 1:
|
||||
$server["img"] = print_image ("images/network.png", true, array ("title" => __('Network server')));
|
||||
$server["type"] = "network";
|
||||
$id_modulo = 2;
|
||||
break;
|
||||
case 2:
|
||||
$server["img"] = print_image ("images/snmp.png", true, array ("title" => __('SNMP server')));
|
||||
$server["type"] = "snmp";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 3:
|
||||
$server["img"] = print_image ("images/recon.png", true, array ("title" => __('Recon server')));
|
||||
$server["type"] = "recon";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 4:
|
||||
$server["img"] = print_image ("images/plugin.png", true, array ("title" => __('Plugin server')));
|
||||
$server["type"] = "plugin";
|
||||
$id_modulo = 4;
|
||||
break;
|
||||
case 5:
|
||||
$server["img"] = print_image ("images/chart_bar.png", true, array ("title" => __('Prediction server')));
|
||||
$server["type"] = "prediction";
|
||||
$id_modulo = 5;
|
||||
break;
|
||||
case 6:
|
||||
$server["img"] = print_image ("images/wmi.png", true, array ("title" => __('WMI server')));
|
||||
$server["type"] = "wmi";
|
||||
$id_modulo = 6;
|
||||
break;
|
||||
case 7:
|
||||
$server["img"] = print_image ("images/server_export.png", true, array ("title" => __('Export server')));
|
||||
$server["type"] = "export";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 8:
|
||||
$server["img"] = print_image ("images/page_white_text.png", true, array ("title" => __('Inventory server')));
|
||||
$server["type"] = "inventory";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
case 9:
|
||||
$server["img"] = print_image ("images/world.png", true, array ("title" => __('Web server')));
|
||||
$server["type"] = "web";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
default:
|
||||
$server["img"] = '';
|
||||
$server["type"] = "unknown";
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty ($modules_info[$server["id_server"]])) {
|
||||
$server["modules"] = 0;
|
||||
} else {
|
||||
$server["modules"] = $modules_info[$server["id_server"]];
|
||||
}
|
||||
$server["module_lag"] = 0;
|
||||
$server["lag"] = 0;
|
||||
$server["load"] = 0;
|
||||
|
||||
if (!isset ($modules_total[$id_modulo])) {
|
||||
$server["modules_total"] = 0;
|
||||
} else {
|
||||
$server["modules_total"] = $modules_total[$id_modulo];
|
||||
}
|
||||
|
||||
if ($id_modulo > 0 && $server["modules"] > 0) {
|
||||
//If the server doesn't have modules, it doesn't have lag so nothing to calculate.
|
||||
// If it's not a module server, don't go here either
|
||||
|
||||
// Remote servers LAG Calculation:
|
||||
if ($id_modulo != 1){
|
||||
$result = get_db_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo
|
||||
WHERE utimestamp > 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND current_interval > 0
|
||||
AND running_by = ".$server["id_server"]."
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) > current_interval");
|
||||
} else {
|
||||
|
||||
// Local/Dataserver server LAG calculation:
|
||||
$result = get_db_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo
|
||||
WHERE utimestamp > 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_tipo_modulo < 5
|
||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND current_interval > 0
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
|
||||
AND running_by = ".$server["id_server"]."
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)");
|
||||
}
|
||||
|
||||
// Lag over current_interval * 2 is not lag, it's a timed out module
|
||||
// And we can't check current_interval = 0 (data modules) because they come as they want
|
||||
|
||||
if (!empty ($result["lag"])) {
|
||||
$server["lag"] = $result["lag"];
|
||||
}
|
||||
if (!empty ($result["module_lag"])) {
|
||||
$server["module_lag"] = $result["module_lag"];
|
||||
}
|
||||
} else {
|
||||
switch ($server["type"]) {
|
||||
case "recon":
|
||||
$server["name"] = '<a href="index.php?sec=estado_server&sec2=operation/servers/view_server_detail&server_id='.$server["id_server"].'">'.$server["name"].'</a>';
|
||||
|
||||
//Get recon taks info
|
||||
$tasks = get_db_all_rows_sql ("SELECT status, utimestamp FROM trecon_task WHERE id_recon_server = ".$server["id_server"]);
|
||||
if (empty ($tasks)) {
|
||||
$tasks = array ();
|
||||
}
|
||||
//Total jobs running on this recon server
|
||||
$server["modules"] = count ($tasks);
|
||||
|
||||
//Total recon jobs (all servers)
|
||||
$server["modules_total"] = $recon_total;
|
||||
|
||||
//Lag (take average active time of all active tasks)
|
||||
$server["module_lag"] = 0;
|
||||
$lags = array ();
|
||||
foreach ($tasks as $task) {
|
||||
if ($task["status"] > 0 && $task["status"] <= 100) {
|
||||
$lags[] = $time - $task["utimestamp"];
|
||||
//Module lag is actually the number of jobs that is currently running
|
||||
$server["module_lag"]++;
|
||||
}
|
||||
}
|
||||
if (count ($lags) > 0) {
|
||||
$server["lag"] = (int) array_sum ($lags) / count ($lags);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
$server["lag_txt"] = ($server["lag"] == 0 ? '-' : human_time_description_raw ($server["lag"])) . " / ". $server["module_lag"];
|
||||
if ($server["modules_total"] > 0) {
|
||||
$server["load"] = round ($server["modules"] / $server["modules_total"] * 100);
|
||||
}
|
||||
|
||||
//Push the raw data on the return stack
|
||||
$return[$server["id_server"]] = $server;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -89,10 +89,11 @@ foreach ($modules as $module) {
|
|||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = show_server_type ($module['id_modulo']);
|
||||
//$data[1] .= ' <img src="images/'.show_icon_type ($module["id_tipo_modulo"]).'" border="0">';
|
||||
|
||||
if (give_acl ($config['id_user'], $id_grupo, "AW"))
|
||||
$data[1] .= ' <a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&id_agent_module='.$module["id_agente_modulo"].'&edit_module='.$module["id_modulo"].'"><img src="images/config.png"></a>';
|
||||
$data[1] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&id_agent_module='.$module["id_agente_modulo"].'&edit_module='.$module["id_modulo"].'"><img src="images/config.png"></a>';
|
||||
|
||||
$data[2] = substr ($module["nombre"], 0, 25);
|
||||
$data[3] = substr ($module["descripcion"], 0, 35);
|
||||
|
|
|
@ -88,7 +88,6 @@ $sql = " FROM tagente, tagente_modulo, tagente_estado
|
|||
WHERE tagente.id_agente = tagente_modulo.id_agente
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente.disabled = 0
|
||||
AND tagente_modulo.delete_pending = 0
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo";
|
||||
|
||||
// Agent group selector
|
||||
|
@ -117,18 +116,26 @@ if ($ag_freestring != "") {
|
|||
|
||||
// Status selector
|
||||
if ($status == 0) { //Up
|
||||
$sql .= " AND tagente_estado.estado = 0 AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)";
|
||||
$sql .= " AND tagente_estado.estado = 0
|
||||
AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100)))
|
||||
AND utimestamp > 0 ";
|
||||
}
|
||||
elseif ($status == 2) { //Critical
|
||||
$sql .= " AND tagente_estado.estado = 1 AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)";
|
||||
$sql .= " AND tagente_estado.estado = 1
|
||||
AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100)))
|
||||
AND utimestamp > 0 ";
|
||||
}
|
||||
elseif ($status == 1) { //warning
|
||||
$sql .= " AND tagente_estado.estado = 2 AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)";
|
||||
$sql .= " AND tagente_estado.estado = 2
|
||||
AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100)))
|
||||
AND utimestamp > 0 ";
|
||||
}
|
||||
elseif ($status == 4) { //not normal
|
||||
$sql .= " AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2) OR tagente_estado.estado = 2 OR tagente_estado.estado = 1) ";
|
||||
$sql .= " AND (((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2) AND (tagente_modulo.id_tipo_modulo NOT IN(21,22,23,100))) OR tagente_estado.estado = 2 OR tagente_estado.estado = 1) AND utimestamp > 0";
|
||||
|
||||
} elseif ($status == 3) { //Unknown
|
||||
$sql .= " AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo < 21 AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)";
|
||||
$sql .= " AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,100) AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)";
|
||||
|
||||
} elseif ($status == 5) {
|
||||
$sql .= " AND tagente_estado.utimestamp = 0";
|
||||
}
|
||||
|
@ -252,13 +259,16 @@ foreach ($result as $row) {
|
|||
else
|
||||
$interval = $row["agent_interval"];
|
||||
|
||||
if ($seconds >= ($interval * 2)) {
|
||||
$option = array ("html_attr" => 'class="redb"');
|
||||
}
|
||||
else {
|
||||
if ((($row["module_type"] < 21) OR ($row["module_type"] > 23)) AND ($row["module_type"] != 100)){
|
||||
if ($seconds >= ($interval * 2)) {
|
||||
$option = array ("html_attr" => 'class="redb"');
|
||||
}
|
||||
else {
|
||||
$option = array ();
|
||||
}
|
||||
} else {
|
||||
$option = array ();
|
||||
}
|
||||
|
||||
$data[8] = print_timestamp ($row["utimestamp"], true, $option);
|
||||
|
||||
array_push ($table->data, $data);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
// Load global vars
|
||||
require_once ("include/config.php");
|
||||
require_once ("include/functions_events.php");
|
||||
require_once ("include/functions_servers.php");
|
||||
|
||||
check_login ();
|
||||
|
||||
|
@ -129,7 +130,34 @@ $cells[7]["href"] = "index.php?sec=eventos&sec2=operation/events/events&search=&
|
|||
$cells[7]["color"] = "#c00";
|
||||
|
||||
print_cells_temp ($cells);
|
||||
|
||||
|
||||
$server_performance = get_server_performance();
|
||||
echo '<tr><th colspan="2">'.__('Server performance').'</th></tr>';
|
||||
$cells = array ();
|
||||
|
||||
$cells[0][0] = __('Local modules rate');
|
||||
$cells[0][1] = format_numeric($server_performance ["local_modules_rate"]);
|
||||
$cells[0]["color"] = "#000";
|
||||
|
||||
$cells[1][0] = __('Remote modules rate');
|
||||
$cells[1][1] = format_numeric($server_performance ["remote_modules_rate"]);
|
||||
$cells[1]["color"] = "#000";
|
||||
|
||||
$cells[2][0] = __('Local modules');
|
||||
$cells[2][1] = format_numeric($server_performance ["total_local_modules"]);
|
||||
$cells[2]["color"] = "#000";
|
||||
|
||||
$cells[3][0] = __('Remote modules');
|
||||
$cells[3][1] = format_numeric($server_performance ["total_remote_modules"]);
|
||||
$cells[3]["color"] = "#000";
|
||||
|
||||
$cells[4][0] = __('Total running modules');
|
||||
$cells[4][1] = format_numeric($server_performance ["total_modules"]);
|
||||
$cells[4]["color"] = "#000";
|
||||
|
||||
|
||||
print_cells_temp ($cells);
|
||||
|
||||
echo '<tr><th colspan="2">'.__('Summary').'</th></tr>';
|
||||
|
||||
$cells = array ();
|
||||
|
@ -192,10 +220,18 @@ foreach ($serverinfo as $server) {
|
|||
$data[2] = print_status_image (STATUS_SERVER_OK, '', true);
|
||||
}
|
||||
|
||||
$data[3] = print_image ("include/fgraph.php?tipo=progress&percent=".$server["load"]."&height=20&width=80",
|
||||
true, array ("title" => $server["lag_txt"]));
|
||||
|
||||
$data[4] = $server["lag_txt"];
|
||||
if ($server["type"] != "snmp") {
|
||||
$data[3] = print_image ("include/fgraph.php?tipo=progress&percent=".$server["load"]."&height=20&width=80", true, '');
|
||||
|
||||
if ($server["type"] != "recon"){
|
||||
$data[4] = $server["lag_txt"];
|
||||
} else {
|
||||
$data[4] = __("N/A");
|
||||
}
|
||||
} else {
|
||||
$data[3] = "";
|
||||
$data[4] = __("N/A");
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
|
|
@ -99,15 +99,20 @@ $search = preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "%", rawurlde
|
|||
$event_type = get_parameter ("event_type", ''); // 0 all
|
||||
$severity = (int) get_parameter ("severity", -1); // -1 all
|
||||
$status = (int) get_parameter ("status", 0); // -1 all, 0 only red, 1 only green
|
||||
//$id_agent = (int) get_parameter ("id_agent", -1); //-1 all, 0 system
|
||||
//$id_agent = (int) get_parameter ("id_agent", ""); //-1 all, 0 system
|
||||
$text_agent = (string) get_parameter("id_agent", "All");
|
||||
|
||||
switch ($text_agent)
|
||||
{
|
||||
case '-1':
|
||||
$id_agent = -1;
|
||||
break;
|
||||
case 'All':
|
||||
$id_agent = -1;
|
||||
break;
|
||||
case 'Server':
|
||||
$id_agent = 0;
|
||||
break;
|
||||
default:
|
||||
$id_agent = get_agent_id($text_agent);
|
||||
break;
|
||||
|
@ -149,15 +154,18 @@ if ($validate) {
|
|||
if ($ev_group > 1 && in_array ($ev_group, array_keys ($groups))) {
|
||||
//If a group is selected and it's in the groups allowed
|
||||
$sql_post = " AND id_grupo = $ev_group";
|
||||
} elseif (is_user_admin ($config["id_user"])) {
|
||||
//Do nothing if you're admin, you get full access
|
||||
$sql_post = "";
|
||||
$groups[0] = __('System Events');
|
||||
} else {
|
||||
//Otherwise select all groups the user has rights to.
|
||||
$sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")";
|
||||
if (is_user_admin ($config["id_user"])) {
|
||||
//Do nothing if you're admin, you get full access
|
||||
$sql_post = "";
|
||||
$groups[0] = __('System Events');
|
||||
} else {
|
||||
//Otherwise select all groups the user has rights to.
|
||||
$sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($status == 1) {
|
||||
$sql_post .= " AND estado = 1";
|
||||
} elseif ($status == 0) {
|
||||
|
@ -174,8 +182,10 @@ if ($id_agent != -1)
|
|||
$sql_post .= " AND id_agente = ".$id_agent;
|
||||
if ($id_event != -1)
|
||||
$sql_post .= " AND id_evento = ".$id_event;
|
||||
if ($id_user_ack != 0)
|
||||
$sql_post .= " AND id_usuario == '".$id_user_ack."'";
|
||||
|
||||
if ($id_user_ack != "0")
|
||||
$sql_post .= " AND id_usuario = '".$id_user_ack."'";
|
||||
|
||||
|
||||
if ($event_view_hr > 0) {
|
||||
$unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds
|
||||
|
@ -374,6 +384,8 @@ if ($group_rep == 0) {
|
|||
$sql = "SELECT COUNT(DISTINCT(evento)) FROM tevento WHERE 1=1 ".$sql_post;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Count the events with this filter (TODO but not utimestamp).
|
||||
$total_events = (int) get_db_sql ($sql);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
// Load global vars
|
||||
require_once ("include/config.php");
|
||||
require_once ("include/functions_servers.php");
|
||||
|
||||
check_login ();
|
||||
|
||||
|
|
Loading…
Reference in New Issue