From 62bf64a668fcf5dd335e9a51641cf44043e543d8 Mon Sep 17 00:00:00 2001 From: ramonn Date: Tue, 25 May 2010 13:16:34 +0000 Subject: [PATCH] 2010-05-25 Ramon Novoa * lib/PandoraFMS/DB.pm: Added functions to get alert data (needed by pandora_manage.pl). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2795 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/DB.pm | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 17fc31a8a9..922bba9345 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2010-05-25 Ramon Novoa + + * lib/PandoraFMS/DB.pm: Added functions to get alert data (needed by + pandora_manage.pl). + 2010-05-25 Ramon Novoa * lib/PandoraFMS/DB.pm: Added functions to get the id of an OS, a diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 3a292e8d14..c602cd4567 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -43,6 +43,8 @@ our @EXPORT = qw( get_server_id get_group_id get_os_id + get_template_id + get_template_module_id is_group_disabled ); @@ -148,6 +150,26 @@ sub get_agent_module_id ($$$) { return defined ($rc) ? $rc : -1; } +########################################################################## +## Return template id given the template name. +########################################################################## +sub get_template_id ($$) { + my ($dbh, $template_name) = @_; + + my $rc = get_db_value ($dbh, "SELECT id FROM talert_templates WHERE name = ?", $template_name); + return defined ($rc) ? $rc : -1; +} + +########################################################################## +## Return the module template id given the module id and the template id. +########################################################################## +sub get_template_module_id ($$$) { + my ($dbh, $module_id, $template_id) = @_; + + my $rc = get_db_value ($dbh, "SELECT id FROM talert_template_modules WHERE id_agent_module = ? AND id_alert_template = ?", $module_id, $template_id); + return defined ($rc) ? $rc : -1; +} + ########################################################################## ## Returns true if the given group is disabled, false otherwise. ##########################################################################