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
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:
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 -
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:
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
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:
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
I hope this helps!
DionV