sub alert_mail_syslog { my ($arg_ref) = @_; my $mail_to = ''; # e.g. jbloggs@example.com my $profile = ''; # e.g. NetEng # Parameters from alert my $tt = $arg_ref->{tt}; my $device = $arg_ref->{device}; my $ipaddr = $arg_ref->{ipaddr}; my $priority = $arg_ref->{priority}; my $facility = $arg_ref->{facility}; my $msg = $arg_ref->{msg}; my $time_str = strftime ("%H:%M", localtime ($arg_ref->{tt})); # Device parameters from database my $contact = adb_result (sprintf ("get %s sys SNMPv2-MIB.sysContact", $device)); my $location = adb_result (sprintf ("get %s sys SNMPv2-MIB.sysLocation", $device)); my $subject = sprintf ("Syslog: %s %s %s", $priority, $device, $ipaddr); my @body; push @body, join (" ", $time_str, $device, $ipaddr, #$contact || "", #$location || "", $msg ); # 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 }); } } }