Tuesday, May 25, 2010

Nagios + PNP graphs PDF reports generator and emailer


We made a small script that we use in our customer’s site to basically pull out the PNP generated graphs through the Nagios Action Items icon. This script will basically download the current report output into PDF and emails them out based on the configuration found on the script header.
  • This script does a simple task of creating PDF files via PNP url and emails it out
  • This script must be executed as root
  • This script may contain sensitive information such as usernames and passwords, so ensure only root has access to it
  • The script works with the extra-option URL only to generate PDF graphs or MRTG, typically /pnp/index.php
  • Make the script executable, i.e. chmod +x pnp_emailer.sh
The solution requires Cleancode’s CLI based email client. All instructions to install and get it up and running is available in the script’s header.
It has basic options currently but you may extend the use of it to just about anything else you wish for it to do.
Eventually, run lines of the scripts as a cron job executed on a timely manner to generate in time reports.
The script is then executed with options at CLI that includes the servername and servicename as defined in the Nagios .CFG files.
Here’s the script. And as usual, your feedback is mucho appreciated.
http://210.5.42.12/downloads/nagios/pnp_emailer.sh
With best,
Sanjay & all Astiostechers!