diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 54c1b63a2c..17fc31a8a9 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2010-05-25 Ramon Novoa + + * lib/PandoraFMS/DB.pm: Added functions to get the id of an OS, a + module and a group (needed by pandora_manage.pl). + + * lib/PandoraFMS/Core.pm: Removed tagente_estado.status from the + keep_alive_nd query. + 2010-05-24 Sergio Martin * util/plugin/snmp_process.pl: Changed the diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 48f224fc8a..38129117f2 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1205,8 +1205,7 @@ sub pandora_module_keep_alive_nd { AND tagente.disabled = 0 AND tagente_modulo.id_tipo_modulo = 100 AND tagente_modulo.disabled = 0 - AND tagente_estado.datos = 1 - AND tagente_estado.estado = 0 + AND tagente_estado.datos = 1 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND ( tagente_estado.utimestamp + (tagente.intervalo * 2) < UNIX_TIMESTAMP())'); diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index eef1817444..3a292e8d14 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -41,6 +41,8 @@ our @EXPORT = qw( get_module_id get_nc_profile_name get_server_id + get_group_id + get_os_id is_group_disabled ); @@ -96,6 +98,26 @@ sub get_server_id ($$$) { return defined ($rc) ? $rc : -1; } +########################################################################## +## Return group ID given the group name. +########################################################################## +sub get_group_id ($$) { + my ($dbh, $group_name) = @_; + + my $rc = get_db_value ($dbh, "SELECT id_grupo FROM tgrupo WHERE nombre = ?", $group_name); + return defined ($rc) ? $rc : -1; +} + +########################################################################## +## Return OS ID given the OS name. +########################################################################## +sub get_os_id ($$) { + my ($dbh, $os_name) = @_; + + my $rc = get_db_value ($dbh, "SELECT id_os FROM tconfig_os WHERE name = ?", $os_name); + return defined ($rc) ? $rc : -1; +} + ########################################################################## ## SUB dame_agente_nombre (id_agente) ## Return agent name, given "id_agente" @@ -116,6 +138,16 @@ sub get_module_name ($$) { return get_db_value ($dbh, "SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = ?", $module_id); } +########################################################################## +## Return module id given the module name and agent id. +########################################################################## +sub get_agent_module_id ($$$) { + my ($dbh, $module_name, $agent_id) = @_; + + my $rc = get_db_value ($dbh, "SELECT id_agente_modulo FROM tagente_modulo WHERE nombre = ? AND id_agente = ?", $module_name, $agent_id); + return defined ($rc) ? $rc : -1; +} + ########################################################################## ## Returns true if the given group is disabled, false otherwise. ##########################################################################