Skip to content

Run MTR automatically when SmokePing triggers an alert

License

Notifications You must be signed in to change notification settings

Ne00n/smokeping-mtr-alert

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smokeping-mtr-alert

Modified for gotify

When SmokePing detects an alert condition it can be configured to run a script instead of sending an e-mail.

This script, when launched from SmokePing, runs an MTR traceroute in report mode and e-mails the output to the designated address. This can be useful in providing some clues as to the source of packet loss.

Installation

This script requires that MTR and curl are installed and available on the path of the user running SmokePing.

smokeping-mtr-alert should be placed in a directory that is readable by the SmokePing user (such as /usr/local/bin), and marked as executable. As SmokePing does not permit arguments to be passed to alert scripts you may wish to use a wrapper script to override configuration (such as the destination e-mail address or system name). An example wrapper script is provided in smokeping-mtr-alert-wrapper.

SmokePing may then be configured in its "pipe" mode to run the script when an alert is triggered. The "from" address can be anything as it is not passed to the script.

*** Alerts ***
to = |/usr/local/bin/smokeping-mtr-alert
from = smokeping@example.com

+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times  in a row

Configured alerts may then be attached to targets.

++ AlertDemo

menu = Demonstration
title = Demonstration host for alerts
host = 192.0.2.1
alerts = someless

More information about the alerting syntax is available in the SmokePing documentation.

Example e-mail

From: smokeping-mtr-alert@monitoring.example.com
To: root@example.com
Subject: monitoring SmokePing alert: Test.AlertDemo
Date: Thu,  2 Jun 2016 13:27:22 +1200 (NZST)

Packet loss report from monitoring for Test.AlertDemo at Thu Jun  2 13:27:22 2016.

mtr -n --report 192.0.2.1

Start: Thu Jun  2 13:27:12 2016
HOST: monitoring                  Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 203.0.113.0                0.0%    10    0.7   6.3   0.4  55.9  17.4
  2.|-- 198.51.100.0               0.0%    10   21.9  24.3  15.7  43.1   9.2
  3.|-- ???                       100.0    10    0.0   0.0   0.0   0.0   0.0

Alert triggered: someloss
Target: Test.AlertDemo
Target hostname: 192.0.2.1
Loss pattern: 100%
RTT: U

Usage

The positional arguments to the script will usually be provided by SmokePing itself.

usage: smokeping-mtr-alert [-h] [--url URL] [--name NAME]
                           alert target loss_pattern rtt hostname

Run from SmokePing as a "pipe" alert target. Sends an MTR for the target to
the designated e-mail address. Michael Fincham
<michael.fincham@catalyst.net.nz>.

positional arguments:
  alert          name of the alert, supplied by smokeping
  target         target being monitored, supplied by smokeping
  loss_pattern   loss pattern that has triggered, supplied by smokeping
  rtt            current RTT for target, supplied by smokeping
  hostname       hostname of target, supplied by smokeping

optional arguments:
  -h, --help     show this help message and exit
  --url URL      gotify url to call
  --name NAME    name of smokeping installation, defaults to hostname where
                 the script runs

Limitations

  • No support for the edgetrigger option in SmokePing.
  • SmokePing will not run a script with custom parameters, necessitating the use of a wrapper script if defaults need to be overridden.

About

Run MTR automatically when SmokePing triggers an alert

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.1%
  • Shell 3.9%