[smokeping-users] Host and title values in Alerts email - diff included

Mitch Sharp mitch at thosesharps.net
Wed Jun 8 05:37:22 CEST 2016


Thanks for making such a great tool Tobi and Niko! Here's a little addition
I whipped up tonight.

I added <##HOST##> and <##TITLE##> keywords to the mail template engine so
that I can have the actual title and host values in my alert emails.

Should anyone else be interested in this, I’ve posted a diff at the link
below, as well as attaching it to this email (not sure if it will make it
through the mailing list filter).
http://files.bluecrow.net/smokeping/smokeping-2.6.11-AdditionalAlertKeywords.diff

I am currently using 2.6.8, but made the diff against the current 2.6.11.
It is working great!!!

My alert email subjects used to look like this:
[SmokeAlert] plossGT10 was raised on CactiIntegration.cacti_218

For a Target config like this:
+ CactiIntegration
++ cacti_218
menu = Customer Name Changed Cable Modem
title = Customer Name Changed Cable Modem
host = 1.1.1.1

Now the alert email subjects look like this:
[SmokeAlert] plossGT10 was raised – Customer Name Changed Cable Modem

The body now includes
Customer Name Changed Cable Modem (1.1.1.1) - Tue Jun  7 22:11:59 2016
Alert "plossGT10" was raised for
https://smokeping.somedomain.com/smokeping/smokeping.cgi?target=CactiIntegration.cacti_218
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.oetiker.ch/pipermail/smokeping-users/attachments/20160607/b3f45d59/attachment.html>
-------------- next part --------------
--- /usr/src/smokeping-2.6.11_original/lib/Smokeping.pm 2014-11-04 16:56:29.000000000 -0600
+++ /usr/src/smokeping-2.6.11/lib/Smokeping.pm  2016-06-07 22:18:54.006617498 -0500
@@ -1815,6 +1815,8 @@
     my $slave = shift;
     my $gotalert;
     my $s = "";
+    my $itemTitle = $tree->{title};
+    my $itemHost = $tree->{host};
     if ($slave) {
         $s = '~'.$slave
     }
@@ -1911,12 +1913,13 @@
                 };
                 if (@to){
                     my $default_mail = <<DOC;
-Subject: [SmokeAlert] <##ALERT##> <##WHAT##> on <##LINE##>
-
-<##STAMP##>
+Subject: [SmokeAlert] <##ALERT##> <##WHAT##> - <##TITLE##>

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

+<##TITLE##> (<##HOST##>)
+<##STAMP##>
+
 Pattern
 -------
 <##PAT##>
@@ -1936,6 +1939,8 @@
                               {
                                           ALERT => $_,
                                           WHAT  => $what,
+                                          HOST => $itemHost,
+                                          TITLE => $itemTitle,
                                           LINE  => $line,
                                           URL   => $urlline,
                                               STAMP => $stamp,
@@ -3380,7 +3385,8 @@
  <##LOSS##>     - loss history
  <##RTT##>      - rtt history
  <##COMMENT##>  - comment
-
+ <##HOST##>     - host
+ <##TITLE##>    - title

 DOC




More information about the smokeping-users mailing list