Dashboard applets for MRTG and Nagios

Steve Shipway, University of Auckland, 2010

s.shipway@auckland.ac.nz : steve@steveshipway.org
http://www.steveshipway.org/forum

Installation
------------

First, obtain the latest copy of Slickboard from www.maani.us/slickboard
If you feel virtuous, register it to obtain a registration key to use later.
A registration key will enable the external links to work (not essential).

Install the slickboard.swf , AC_RunActiveContent.js and dashboard.js into 
your web server root on your MRTG/Nagios server. If you want ot put them 
anywhere else, youll need to modify the code a little).

If you want to run this on a different server to your MRTG or Nagios 
installation, then you need to install the .cgi files onto the remote server,
and then use a reverse proxy module in Apache to make them appear to be
local (this is because of XSS protection in web browsers).  See later for
details.

Install the .cgi files into your cgi-bin and make sure they can run (if you 
have authentication system they need to be disabled for these scripts).

If you want to have some more security, rename the scripts to have a -public
suffix, IE rename xxxx.cgi to xxxx-public.cgi.  This will restrict the Nagios
hostgroup and MRTG cfg files that the script will hand over data for.

If you are using -public, modify the definitions at the start of the script(s)
to specify the public hostgroup (Nagios) or public CFG filename pattern (MRTG).

If you are using a license key, optionally set it in the script.

Make sure that the Nagios EXTINFO URL and/or the MRTG Routers2 URL are correct.
You can also set any othe roptions you care to.

Adding an applet to your web page
---------------------------------

Gauges and bar graphs are usually 200x250, graphs are 600x250.  Nagios can be 
any size but we recommend either 600x250 or 400x250.  As a result, you can fit 
a 5x3 grid into 1000x750 which fits nicely on a page.

If you use a differrent size for gauges and bar graphs it will try to scale 
down to fit, up to a point.  If you dont specify a Target, then ALL the targets
will render (though they may not all fit in).  You can also pass a cols param
to the underlying CGI which forces the number of columns of subgauges... but 
this is getting a bit advanced, and requires using the 'applet' function.

Add this to the top of your web page:

<script language="javascript">AC_FL_RunContent = 0;</script>
<script language="javascript"> DetectFlashVer = 0; </script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
<script src="dashboard.js" language="javascript"></script>

You can optionally use this to set some additional variables.  The mrtgcgi
and nagioscgi variables define where to find the gaugexml3.cgi, nagiosxml.cgi
etc scripts, and should be relative URLs, not absolute as you can trigger
XSS security procections.

<script language="JavaScript" type="text/javascript"><!--
licensekey='put your licensekey in here';
mrtgcgi='/cgi-bin/'; // set relative path to avoid XSS problems
nagioscgi='/nagios/cgi-bin/';
// --></script>

Now, where you want to add a gauge, use this (replace targetname and the MRTG 
cfg filename):

<script language="JavaScript" type="text/javascript"><!--
gauge('MRTG cfg filename','targetname');
// --></script>

To add a small bar graph, use:

<script language="JavaScript" type="text/javascript"><!--
bars('MRTG cfg filename','targetname');
// --></script>

Where you want to add a graph, you use this:

<script language="JavaScript" type="text/javascript"><!--
graph('MRTG cfg filename','targetname');
// --></script>

Where you want a Nagios status window, use this (replace 'hostname').  The
600 and 250 are the width and height of the applet:

<script language="JavaScript" type="text/javascript"><!--
nagioshost('hostname',600,250);
// --></script>

or this (replace 'hostgroupname'):

<script language="JavaScript" type="text/javascript"><!--
nagioshostgroup('hostgroupname',600,250);
// --></script>

There is even a generic interface if you've written your own XML CGI, or if
you want to pass non-standard parameters to the gaugexml3 or graphxml3 CGIs:

<script language="JavaScript" type="text/javascript"><!--
applet('/cgi-bin/myscript.cgi',200,250);
// --></script>

Using Reverse Proxy
-------------------

If your Nagios is on a separate server, you need to set up a reverse proxy
to send local requests there.  Under Apache, you can do this using something
like this, which makes /nagios/ a virtual redirect to our Nagios server.  You
may need to set nagioscgi appropriately:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /nagios/>
ProxyPass        https://nagios.auckland.ac.nz/
ProxyPassReverse https://nagios.auckland.ac.nz/
</Location>

