Printing and mailing out a report automatically

2013-03-20
Since QueueMetrics 13.04, it is possible to have QueueMetrics generate a report in PDF or XLS format, and download it or sent it automatically to a group of recipients by e-mail. The following notes only apply to earlier versions of QueueMetrics.

It is possible to print a full report to PDF automatically and have it emailed periodically with no human intervention.
In order to run the following script, you need to install the following packages on your server:
yum install htmldoc
yum install nail

(you need to enable the DAG repository to have nail).

The script is as follows:
#! /bin/bash

QM_SERVER=http://127.0.0.1:8080
QM_WEBAPP=DAILY
QM_QUEUE=q1
QM_PERIOD=d90
QM_USER=robot
QM_PASS=robot
EMAIL=mu@email

# cleanup images
rm -rf $QM_WEBAPP/
rm -rf img/

# download images
wget -nH -k -K -p "$QM_SERVER/$QM_WEBAPP/qm_rep.do?user=$QM_USER&pass=$QM_ASS&queues=none&period=t1"

mv $QM_WEBAPP/img/ .

wget -o img/shade-histo.gif "$QM_SERVER/$QM_WEBAPP/img/shade-histo.gif"

# download report
wget -nH -k -K -p -l 1 -O report.html "$QM_SERVER/$QM_WEBAPP/qm_rep.do?user=$QM_USER&pass=$QM_PASS&queues=$QM_QUEUE&period=$QM_PERIOD"

# convert to PDF
htmldoc --webpage --size 11x8.5in -f myreport.pdf myreport.html

# mail out
echo "Your daily report is attached as a PDF" | env MAILRC=/dev/null from=qm-server@example.com smtp=mail.example.com nail -n -s "Daily Report" -a myreport.pdf $EMAIL

This can be run automatically. For valid queue and time period parameters, see the chapter "Automating statistics download: the ROBOT profile" in the QM user manual.

In order to run the script, make sure that the ROBOT user is enabled in your QueueMetrics installation (it is disabled by default).