Smokeping mailtemplate format

Submitted by stompro on Wed, 11/07/2007 - 10:28am.

I have had a problem with the alerts that smokeping­ sends out for the last year or so.  Ever since work purchase new cell phones that had less space to show text messages, every alert that smokeping has been sending has been split into 2 messages, which is really annoying when the main internet connection at work goes down, and 64 (128) notices get queued up to be delivered.

This morning that happened again when 702 did some network maintenance, so I found some time to fix it.  The nice thing is that the latest version of smokeping has a configuration option to set the alert email template to something other than the default.  The format that the template needs to be in isn't very clear though.  While I was looking for a clue as to how the template had to be formated I found that I could have just edited the Smokeping.pm file and changed the template there, and had this fixed a year ago.

There is no­w a mailtemplate variable that can be set in the alerts section of the config file.  This should be the path to a file that contains the template data.  I had no luck adding the template data inline. 
mailtemplate = /etc/smokeping/mailtemplateThe first 2 lines of the template need to look like this
Subject: [Smokeping] blah blah

Body of template

There has to be a space after the subject line.  The error messages that smokeping gives you are pretty lame.  "ERROR: /etc/smokeping/config, line 101: mailtemplate '/etc/smokeping/mailtemplate' should start with mail header lines"  It should say that the mailtemplate must start with a subject header line, and then a blank line.

If you look at Smokeping.pm
while (<$tmpl>){
$subj =1 if /^Subject: /;
next if /^\S+: /;
last if /^$/;
return "mailtemplate '$_[0]' should start with mail header lines";

Those are the checks that the file must pass.  Also in Smokeping.pm is the built in template which gives a clue to the format.

my $default_mail = <<DOC;
Subject: [SmokeAlert] <##ALERT##> <##WHAT##> on <##LINE##>

<##STAMP##>

Alert "<##ALERT##>" <##WHAT##> for <##URL##>

Pattern
-------
<##PAT##>

Data (old --> now)
------------------
<##LOSS##>
<##RTT##>

Comment
-------
<##COMMENT##>

DOC­

I hope this information is useful to others that need to change the alert email format.

Submitted by Anonymous on Thu, 10/02/2008 - 6:50am.

Extremely useful, thank you.
Google is a wonderful thing :)