[smokeping-users] How to send mail alerts

Gregory Sloop gregs at sloop.net
Tue Apr 11 18:27:17 CEST 2017


I'm not entirely sure what you're having a problem with.
I don't want postfix or sendmail installed [or have to configure them] on most smokeping installs.
If I want alerts from smokeping directly [I usually do alerting from Nagios] I use sendemail - it's available as a package on debian/ubuntu, I know for certain. Sendemail will allow you to use SMTP-Auth as well - which is a nice option not available in quite a number of other cases.

At that point, you can call a script for alerts, and pass the environment vars you want and use the script to send the email.

HTH

-Greg


    
    I want to configure the mail alert. Configuration is as follows:

1. pkg install perl5 , install Authen::SASL  Modular
outbound_adsl_j160:/usr/local/lib/perl5@[10:30] #perldoc perllocal 
You have an old groff. Update to version 1.20.1 for good Unicode support.
If you don't upgrade, wide characters may come out oddly.

 at /usr/local/lib/perl5/5.16/Pod/Perldoc.pm line 1346.
You have an old groff. Update to version 1.20.1 for good Unicode support.
If you don't upgrade, wide characters may come out oddly.

 at /usr/local/lib/perl5/5.16/Pod/Perldoc.pm line 1346.
PERLLOCAL(1)          User Contributed Perl Documentation         PERLLOCAL(1)

   ESC[1mWed Apr  5 11:37:57 2017: "Module" Authen::SASLESC[0m
       <B7>   "installed into: /usr/local/lib/perl5/site_perl/5.16"

       <B7>   "LINKTYPE: dynamic"

       <B7>   "VERSION: 2.16"

       <B7>   "EXE_FILES: "

perl v5.16.3                      2017-04-05                      PERLLOCAL(1)


2. Configuration Smokeping.pm 

outbound_adsl_j160:/usr/local/smokeping/lib@[16:32] #more Smokeping.pm 

use Authen::SASL;     #This line increase 

sub sendmail ($$$){
    my $from = shift;
    my $to = shift;
    $to = $1 if $to =~ /<(.*?)>/;
    my $body = shift;
    if ($cfg->{General}{mailhost} and  
        my $smtp = Net::SMTP->new([split /\s*,\s*/, $cfg->{General}{mailhost}],Timeout=>5) ){                 
        $smtp->auth(split(/\s*,\s*/, $cfg->{General}{mailusr}),split(/\s*,\s*/, $cfg->{General}{mailpwd}));     #This line increase 
        $smtp->mail($from);
        $smtp->to(split(/\s*,\s*/, $to));
        $smtp->data();
        $smtp->datasend($body);
        $smtp->dataend();
        $smtp->quit;
    } elsif ($cfg->{General}{sendmail} or -x "/usr/lib/sendmail"){
        open (M, "|-") || exec (($cfg->{General}{sendmail} || "/usr/lib/sendmail"),"-f",$from,$to);
        print M $body;
        close M;
    } else {
        warn "ERROR: not sending mail to $to, as all methodes failed\n";
    }
}

#find  '_vars =>' , increase mailusr mailpwd 
DOC
         _vars =>
         [ qw(owner imgcache imgurl datadir dyndir pagedir piddir sendmail offset
              smokemail cgiurl mailhost mailusr mailpwd snpphost contact display_name
              syslogfacility syslogpriority concurrentprobes changeprocessnames tmail
              changecgiprogramname linkstyle precreateperms ) ],


3. Configuration General Alerts 

outbound_adsl_j160:/usr/local/etc/smokeping/conf.d@[16:37] #more General 
*** General ***

owner    = Peter Random
contact  = some at address.nowhere
#mailhost = my.mail.host
mailhost = smtp.qq.com
mailusr = 514906434 at qq.com
mailpwd = ZDHT#cetc2016

outbound_adsl_j160:/usr/local/etc/smokeping/conf.d@[13:35] #more Alerts 
*** Alerts ***
to = 370767686 at qq.com 
from = 514906434 at qq.com

   
    The above configuration is not normal mail alert.
    

     

370767686
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.oetiker.ch/pipermail/smokeping-users/attachments/20170411/35e9633f/attachment.html>


More information about the smokeping-users mailing list