skip to Main Content

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


# DAG Tech 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 [email protected],[email protected] [email protected]

# TODO need to set mutt -e switch to set REALNAME and FROM on the fly
#[email protected]

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

echo SmokeSend by DAG Tech
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
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

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

#TODO clean reports

echo SmokeSend done!

Back To Top