From 94335b1e8c75664ef8c6e1af38a9f0d21042bb96 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Thu, 21 Jun 2012 13:19:49 +0000 Subject: [PATCH] 2012-06-21 Ramon Novoa * lib/PandoraFMS/Core.pm: merged from 4.0 branch. Added inventory server statistics. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6659 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/Core.pm | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index ac54628156..cfe42d7367 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2012-06-21 Ramon Novoa + + * lib/PandoraFMS/Core.pm: merged from 4.0 branch. Added inventory server + statistics. + 2012-06-21 Juan Manuel Ramon * ChangeLog: Forgot to update ChangeLog in my last commit. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 5d7ab2dfa7..5c621b3091 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2329,9 +2329,29 @@ sub pandora_server_statistics ($$) { # For each server, update stats: Simple. foreach my $server (@servers) { - + + # Inventory server + if ($server->{"server_type"} == 8) { + # Get modules exported by this server + $server->{"modules"} = get_db_value ($dbh, "SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente AND tagente.server_name = ?", $server->{"name"}); + + # Get total exported modules + $server->{"modules_total"} = get_db_value ($dbh, "SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente"); + + # Calculate lag + $lag_row = get_db_single_row ($dbh, "SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory.interval) AS lag + FROM tagente, tagent_module_inventory + WHERE utimestamp > 0 + AND tagent_module_inventory.id_agente = tagente.id_agente + AND tagent_module_inventory.interval > 0 + AND tagente.server_name = ? + AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.interval * 10) + AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.interval", $server->{"name"}); + $server->{"module_lag"} = $lag_row->{"module_lag"}; + $server->{"lag"} = $lag_row->{"lag"}; + } # Export server - if ($server->{"server_type"} == 7) { + elsif ($server->{"server_type"} == 7) { # Get modules exported by this server $server->{"modules"} = get_db_value ($dbh, "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"});