sandialabs/scot

Email alert script alertbot.pl broken

ahoying opened this issue · 2 comments

In Docker, alertbot.pl doesn't work.

In troubleshooting I found several issues. First, Sys::RunAlone is missing from the required perl modules.

Once that is installed, lib/Scot/Bot/ForkAlerts.pm references Scot::Util::Phantom which does not exist, commenting that line out fixed that issue.

Then I got this error:

$ ./alertbot.pl
Attribute (env) is required at constructor Scot::Util::Imap::new (defined at ../lib/Scot/Util/Imap.pm line 426) line 40.
Scot::Util::Imap::new('Scot::Util::Imap', 'config', 'HASH(0x934f4c0)', 'log', 'Log::Log4perl::Logger=HASH(0xf0e8a8)', 'email_acct', undef, 'mongo', 'Scot::Util::Mongo=HASH(0x931d4b0)') called at ../lib/Scot/Env.pm line 334
Scot::Env::_build_imap('Scot::Env=HASH(0xf0ea10)') called at reader Scot::Env::imap (defined at ../lib/Scot/Env.pm line 319) line 7
Scot::Env::imap('Scot::Env=HASH(0xf0ea10)') called at ../lib/Scot/Bot/ForkAlerts.pm line 54
Scot::Bot::ForkAlerts::_get_imap('Scot::Bot::ForkAlerts=HASH(0x9343638)') called at reader Scot::Bot::ForkAlerts::imap (defined at ../lib/Scot/Bot/ForkAlerts.pm line 44) line 7
Scot::Bot::ForkAlerts::imap('Scot::Bot::ForkAlerts=HASH(0x9343638)') called at ../lib/Scot/Bot/ForkAlerts.pm line 61
Scot::Bot::ForkAlerts::run('Scot::Bot::ForkAlerts=HASH(0x9343638)', 'HASH(0x8521bd0)') called at ./alertbot.pl line 173

To fix that I updated Env.pm and changed the Scot::Util::Imap->new call to this:

my $imap    = Scot::Util::Imap->new(
    config      => $config->{$mode},
    log         => $self->log,
    email_acct  => $account,
    mongo       => $mongo,
    env         => $self,
);

After that the script started working fine and I can now get new alerts via email.

Thanks for finding those issues. I will fix asap.

Much thanks @ahoying . In the future feel free to create a pull request. Then we can merge in your fixes with a single click on our end. All of your fixes have been sound and well executed.