[smokeping-users] SMTP Alerts on alternate port, smtp auth

Tom Throckmorton throck at gmail.com
Fri Sep 2 22:08:57 CEST 2011


On 9/2/11 3:39 PM, Gregory Sloop wrote:
> That's neat and all, but it's not clear how I'd include any data on
> what the alert is about - what host etc.
> 
> I assume that perhaps the mailtemplate might be helpful, but an
> initial read of the docs isn't particularly enlightening.

Read further - it's covered in the 'to' variable description:

> Either an email address to send alerts to, or the name of a program
> to execute when an alert matches. To call a program, the first
> character of the to value must be a pipe symbol "|". The program will
> the be called whenever an alert matches, using the following 5
> arguments (except if edgetrigger is 'yes'; see below): name-of-alert,
> target, loss-pattern, rtt-pattern, hostname. You can also provide a
> comma separated list of addresses and programs.

So,

1) name-of-alert
2) target
3) loss-pattern
4) rtt-pattern
5) hostname
6) edgetrigger state (raise=1, clear=0)

> I assume you may have done something similar - do you have some
> example code, or can you point me to some?
> 
> I'm reasonably proficient in bash, so it's possible I could cobble
> something together...

It's shockingly simple.  Here's some pseudocode:

-------
alert=$1
target=$2
loss=$3
rtt=$4
hostname=$5
level=$6

output="$alert:$target $rtt / $loss"
echo -e "$hostname\tservice_name\t$level\t$output\n" | /usr/sbin \\
 /send_nsca -H nagioshost -c /etc/nagios/nsca.cfg
-------

> I still think it would be much better to include SMTP alt-port & auth
> etc in the code, along with the required extensions - writing a bash
> script etc is really an ugly hack.
> 
> But if I have to settle for a hack, perhaps it's that or nothing.

Well, something else I didn't point out is that you _can_ specify a
mailhost, which will trigger the use of Net::SMTP, as you were
originally hoping:

> http://oss.oetiker.ch/smokeping/doc/smokeping_config.en.html#I____General______mandatory_section_

> Instead of using sendmail, you can specify the name of an smtp server
> and use perl's Net::SMTP module to send mail (for alerts and DYNAMIC
> client script). Several comma separated mailhosts can be specified.
> SmokePing will try one after the other if one does not answer for 5
> seconds.

...I don't believe that will meet your port/auth needs, which is why I
was suggesting the alternate command method.

-tt

> TT> On 9/2/11 12:55 PM, Gregory Sloop wrote:
>>>
>>> I'd like to use the Net::SMTP module instead of sendmail - (Just
>>> easier, IMO) and I need to use an alternate port. [Like 26]
>>>
>>> Is there some way to configure this? I've searched the lists [and
>>> Google] and was not able to find anything...
> 
> TT> Greg,
> 
> TT> For alerts you can specify any command you want, so instead of / in
> TT> addition to using an email address, you can do something like:
> 
>>> *** Alerts ***
>>> # 'to' can be a comma separated list of email addresses or programs
>>> to = gregs at sloop.net,|/path/to/mail-alerts.sh
> 
> TT> ...where mail-alerts.sh is a script you write or find that does what you
> TT> want.  See the options for the 'to' variable in the Alerts section of
> TT> the docs, here:
> 
>>> http://oss.oetiker.ch/smokeping/doc/smokeping_config.en.html#I____Alerts____
> 
> TT> Cheers,
> 
> TT> -tt
> 



More information about the smokeping-users mailing list