diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 049e97c19b..1a07c46254 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-06-12 Ramon Novoa + + * include/functions_servers.php, + godmode/servers/modificar_server.php: Merged from 4.0 branch. Added + real-time export server stats. + 2012-06-12 Miguel de Dios * extras/pandoradb_migrate_v3.2_to_v4.0.sql: added the lost diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index bde9f5d158..209c5c0f20 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -145,10 +145,13 @@ else { $data[4] = 'N/A'; $data[5] = 'N/A'; break; + case "export": + $data[3] = progress_bar($server["load"], 60, 20, $server["lag_txt"], 0); + $data[4] = $server["modules"] . " ".__('of')." ". $server["modules_total"]; + $data[5] = 'N/A'; + break; default: - // Load - $data[3] = - progress_bar($server["load"], 60, 20, $server["lag_txt"], 0); + $data[3] = progress_bar($server["load"], 60, 20, $server["lag_txt"], 0); $data[4] = $server["modules"] . " ".__('of')." ". $server["modules_total"]; $data[5] = ''.$server["lag_txt"].''; break; diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index a4bb0bc310..eeab45c386 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -256,8 +256,51 @@ function servers_get_info ($id_server = -1) { $server["module_lag"] = 0; $server["lag"] = 0; + // Export server + if ($server["server_type"] == 7) { + + # Get modules exported by this server + $server["modules"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tserver_export WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export = tserver_export.id AND tserver_export.id_export_server = " . $server["id_server"]); + + # Get total exported modules + $server["modules_total"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export != 0"); + + $server["lag"] = 0; + $server["module_lag"] = 0; - if ($server["server_type"] != 3) { + } + // Recon server + else if ($server["server_type"] == 3) { + + $server["name"] = ''.$server["name"].''; + + //Total jobs running on this recon server + $server["modules"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE id_recon_server = ".$server["id_server"]); + + //Total recon jobs (all servers) + $server["modules_total"] = db_get_sql ("SELECT COUNT(status) FROM trecon_task"); + + //Lag (take average active time of all active tasks) + $server["module_lag"] = 0; + + switch ($config["dbtype"]) { + case "mysql": + $server["lag"] = db_get_sql ("SELECT UNIX_TIMESTAMP() - utimestamp from trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); + + $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); + break; + case "postgresql": + $server["lag"] = db_get_sql ("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); + + $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); + break; + case "oracle": + $server["lag"] = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); + + $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); + break; + } + } else { // --------------------------------------------------------------- // Data, Plugin, WMI, Network and Others @@ -360,44 +403,8 @@ function servers_get_info ($id_server = -1) { if (!empty ($result["module_lag"])) { $server["module_lag"] = $result["module_lag"]; - } - - // --------------------------------------------------------------- - // Recon server only - // --------------------------------------------------------------- - - } - elseif ($server["server_type"] == 3) { - - $server["name"] = ''.$server["name"].''; - - //Total jobs running on this recon server - $server["modules"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE id_recon_server = ".$server["id_server"]); - - //Total recon jobs (all servers) - $server["modules_total"] = db_get_sql ("SELECT COUNT(status) FROM trecon_task"); - - //Lag (take average active time of all active tasks) - $server["module_lag"] = 0; - - switch ($config["dbtype"]) { - case "mysql": - $server["lag"] = db_get_sql ("SELECT UNIX_TIMESTAMP() - utimestamp from trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; - case "postgresql": - $server["lag"] = db_get_sql ("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; - case "oracle": - $server["lag"] = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; } - } // recon + } } // Take data for realtime mode if (isset($server["module_lag"]))