QueueMetrics > Running QueueMetrics
SOLVED: Generate reports and send them by email
(1/1)
dionv:
--- Quote from: dchabanol on October 27, 2008, 18:35:16 ---Hello,
I need to automatically generate custom report and also general report (via crontab ?), convert them in pdf and send them by email.
I had a look on the forum and also in the documentation but found nothing ...
Any idea ?
Best regards,
Didier Chabanol
http://www.ives.fr
--- End quote ---
Took some digging around, but looks like one way that could work is with the htmldoc package, which is generally available through most linux distributions.
With it, you could do something like:
--- Code: ---wget -O - -p "http://yourserver.com:8080/queuemetrics/qm_rep.do?user=robot&pass=robotpass&queues=q1&period=t1" | htmldoc --webpage --size 11x8.5in -f report.pdf -
--- End code ---
Note the dash (-) after the -O (that's O like Oscar, not 0 like zero), and the ending dash by itself, these are required to work properly. The first one tells wget to send its output to stdout, the final one tells htmldoc to read from stdin.
Since the report pages are kind of wide, I used htmldoc's "size" option to set the output to US letter landscape mode.
You could write the command as two separate steps if you wanted:
--- Code: ---wget -nH -k -K -E -O myreport.html -p "http://yourserver.com:8080/queuemetrics/qm_rep.do?user=robot&pass=robotpass&queues=q1&period=t1"
htmldoc --webpage --size 11x8.5in -f report.pdf report.html
--- End code ---
This one should show most of the images (so if you have a company logo in QM, it will still be there in the report), except the bar graph images. For some reason the robot user's reports do not show the bar graphs for me. (The source code of the rendered page has the bar graph image trying to be called from "/img" instead of "/queuemetrics/img" for some reason.)
To send the report as an attachment from the command line (or from within a script), you may want to install mutt or nail (yes, with an 'n'). In my testing, nail seems to work a little better, but I haven't spent much time on it at this point.
Something like this seems to work well, putting it all together:
--- Code: ---wget -nH -k -K -E -O myreport.html -p "http://myserver.com:8080/queuemetrics/qm_rep.do?user=robot&pass=robotpass&queues=q1&period=t1"
htmldoc --webpage --size 11x8.5in -f myreport.pdf myreport.html
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 user@privatelabelcc.com
--- End code ---
I hope this helps!
DionV
QueueMetrics:
Super cool man! ;-) this will be linked straight from the FAQs.
We'll add a check for the weird /img behaviour.... it will be more likely ../img, meaning "the folder img in the partent directory".
dionv:
--- Quote from: QueueMetrics on April 11, 2009, 09:27:48 ---Super cool man! ;-) this will be linked straight from the FAQs.
We'll add a check for the weird /img behaviour.... it will be more likely ../img, meaning "the folder img in the partent directory".
--- End quote ---
Ah, yes, my typo in creating the message. It was late. I double-checked the source page of the rendered page in my browser:
--- Code: ---<tr class='ST_TR0'>
<td class='stData' style='width: 250;'> John Smith </td>
<td class='stData' style='width: 90;'>1</td>
<td class='stData' style='width: 50;' align='right'> 5.6% </td>
<td class='stData' style='width: 200;'><img src='../img/shade-histo.gif' height='10' width='200.0'></td>
</tr>
--- End code ---
It is, indeed, "../img/"
DionV
QueueMetrics:
You could always create a ../img directory and download the image there :-)
Navigation
[0] Message Index
Go to full version