sub alert_mail_status { my ($arg_ref) = @_; my $mail_to = ''; # e.g. jbloggs@example.com my $profile = ''; # e.g. NetEng my $subject = sprintf ("Status: %s %s %s %s", $arg_ref->{device}, $arg_ref->{child}, $arg_ref->{descr}, $arg_ref->{state}); my $ipaddr = adb_result (sprintf ("get %s sys SNMP.ipaddr", $arg_ref->{device})); my $contact = adb_result (sprintf ("get %s sys SNMPv2-MIB.sysContact", $arg_ref->{device})); my $location = adb_result (sprintf ("get %s sys SNMPv2-MIB.sysLocation", $arg_ref->{device})); my $time_str = strftime ("%H:%M", localtime ($arg_ref->{tt})); my @body; push @body, join (" ", $time_str, $arg_ref->{device}, $ipaddr, #$contact || "", #$location || "", $arg_ref->{child}, $arg_ref->{descr}, $arg_ref->{attr}, $arg_ref->{alias} || "", $arg_ref->{state} ); # Send to a single email address if ($mail_to ne "") { mail ({ subject => $subject, to => $mail_to, body => \@body }); } # Send to all email addresses in a profile if ($profile ne "") { for my $addr (config_get_emails ($profile)) { mail ({ subject => $subject, to => $addr, body => \@body }); } } }