From 48d9f70c8740619c040bd7db80424709cd629706 Mon Sep 17 00:00:00 2001 From: Digimer Date: Wed, 6 Mar 2019 14:02:18 -0500 Subject: [PATCH] * Started the new Database->get_alert_recipients() method. Signed-off-by: Digimer --- Anvil/Tools/Database.pm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index b5b98201..294fc230 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -20,6 +20,7 @@ my $THIS_FILE = "Database.pm"; # configure_pgsql # connect # disconnect +# get_alert_recipients # get_hosts # get_jobs # get_local_uuid @@ -1250,6 +1251,43 @@ sub disconnect return(0); } +=head2 get_alert_recipients + +This returns a list of users listening to alerts for a given host, along with their alert level. + +Parameters; + +=head3 host_uuid (optional, default Get->host_uuid) + +This is the host we're querying. + +=cut +sub get_alert_recipients +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_alert_recipients()" }}); + + my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : $anvil->Get->host_uuid; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + host_uuid => $host_uuid, + }}); + + my $lowest_level = 0; + my $query = " +SELECT + notification_recipient_uuid, + notification_alert_level +FROM + notifications +WHERE + notification_host_uuid = ".$anvil->Database->quote($job_host_uuid)." +;"; + + return(); +} =head2 get_hosts