This script will send you a PDF of your SmokePing report (sample of the PDF)

  1. save the script below and chmod +x
  2. on your smokeping host, install wkhtmltopdf, xvfbrunexec, and pdfcropexec. these will grab your smokeping output from the web, save to PDF, and will crop the left hand menu bar so all you see is a clean report

usage smokesend [RRD_NAME] recipient_emails bcc_recipient_emails

get your RRD from the name of your smokeping report

you can send to multiple emails by adding a comma. the first group of emails is TO:, the second is BCC: in case you want to send the report to NOC

the script works best crontab’d

get in touch if you’d like help implementing

DAG Tech also offers SmokePing as a configured service

——————————————————————-

#!/bin/bash
# DAG Tech www.dagtech.com SmokeSend for SmokePing 20150903 Daniel Ghazi

# prints command line usage if no options passed to script
if [ -z “$1” ] || [ -z “$2″ ]; then
echo usage: smokesend [RRD_NAME] recipient_emails bcc_recipient_emails
echo ex: smokesend ICMPLatency.EVOLSC01.hqfw1-ifsec user@evosc01.com,user2@evosc01.com noc@dagtech.com
else

# DEFINE THESE
SENDERNAME=”YOUR NAME”
LOG=/var/log/smokesend.log
SMOKEPINGCGI=http://yoursmokepinghost.com/cgi-bin/smokeping.cgi
WKHTMLPDFEXEC=/usr/local/bin/wkhtmltopdf
XVFBRUNEXEC=/usr/bin/xvfb-run
PDFCROPEXEC=/usr/bin/pdfcrop
# TODO need to set mutt -e switch to set REALNAME and FROM on the fly
#EMAILREALNAME=Real Name
#EMAILFROM=smokeping@yourdomain.com

# sets $FILE to RRD name underscore datestamp
FILE=$1_$(date +%Y%m%d%s)

echo SmokeSend by DAG Tech www.dagtech.com
echo Generating SmokePing round robin database report $FILE

# uses xvfb to run wkhtmlpdf headless (without XFree86 GUI) and URL into temp PDF file
# TODO increase resolution of PDF
echo Running wkhtmltopdf to write RRD web content to PDF
$XVFBRUNEXEC -a -s “-screen 0 800x600x24” $WKHTMLPDFEXEC “$SMOKEPINGCGI”?target=$1 /tmp/$FILE.pdf

# pdfcrop utility to remove left menu bar which contains all monitored clients
echo cropping 100 pixel left menu bar from PDF
$PDFCROPEXEC /tmp/$FILE.pdf –margins ‘-100 0 0 0’ /tmp/”$SENDERNAME”-SmokePing-$FILE.pdf

# remove tmp PDF
echo removing temp files
rm -f /tmp/$FILE.pdf

# uses mutt email client to send PDF to recipients TO and BCC if declared
if [ -z “$3” ]; then
echo sending “$SENDERNAME”-SmokePing-$FILE.pdf TO $2
mutt -s “$SENDERNAME SmokePing report for $FILE” $2 -a /tmp/”$SENDERNAME”-SmokePing-$FILE.pdf < /dev/null
else
echo sending “$SENDERNAME”-SmokePing-$FILE.pdf TO $2
echo sending “$SENDERNAME”-SmokePing-$FILE.pdf BCC $3
mutt -s “$SENDERNAME SmokePing report for $FILE” $2 -b $3 -a /tmp/”$SENDERNAME”-SmokePing-$FILE.pdf < /dev/null
fi

# writes entry into log file
if [ -z “$3” ]; then
echo $(date +%Y%m%d%s) SmokeSend sent “$SENDERNAME”-SmokePing-$FILE.pdf TO $2 >> $LOG
else
echo $(date +%Y%m%d%s) SmokeSend sent “$SENDERNAME”-SmokePing-$FILE.pdf TO $2 BCC $3 >> $LOG
fi

#TODO clean reports

echo SmokeSend done!
fi

1067352697
REQUEST SERVICE