SMWW - An Addon To Intelligently Show ALL Problems For Nagios

The default Nagios menu allows you to view network outage, host based problems, or service based problems, but only one of these types of problems at a time. The Tactical Overview screen will display the numbers of all three types of problems in a summary format, but not the actual problems within each type. To view the problems, you are still required to click on network outages, hosts or services to see the actual list of problems. To present a list of all problems, I wrote SMWW - Show Me What's Wrong.

SMWW is a user interface screen that uses the standard Nagios modules to query Nagios about any current problems, and then display the 3 problem types on the same screen.

The left hand side of the screen displays the standard Nagios menu bar. The right side of the screen is used to display any problems detected.

At the top of the problem display area, the network problems (if any) are displayed.

Below the network problems, hosts that are down are displayed if they are not located in a network path that is blocked by an outage shown in the network problems section.

Beneath the host problem section, SMWW displays the services that are down, as long as the host they are located on is not listed in the hosts section above, or the host is not located in a network path that is blocked by an outage shown in the network problems section.

The resulting display shows the current problems in a hierarchical manner, assuming that the proper network configuration has been entered into the Nagios configuration files. Even if the network data is missing, the host and services status areas will still continue to display the correct data.

SMWW Code

The code the SMWW is comprised of 2 small files: smww.php and smww.cgi.

The smww.php program follows:


<?php include_once(dirname(__FILE__).'/includes/utils.inc.php'); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- SMWW - Show Me What's Wrong, Ver 1.2 -->
<!-- By John Tysko, tysko@ohio.edu -->
<HTML>
<HEAD>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<title>SMWW</title>
</HEAD>
<frameset cols="180,*" style="border: 0px; framespacing: 0px">
<frame src="side.php" name="side" frameborder="0" style="">
<frame src="<?php echo $cfg["cgi_base_url"];?>/smww.cgi" name="main" frameborder="0" style="">
</frameset>

</HTML>

The smww.cgi program is:



#!/bin/sh

###
### SMWW - Show Me Whats Wrong Ver 1.2
###      by John Tysko, tysko@ohio.edu
###        update 2014/06/05 servicestatustypes changed from 16 to 28
###
###  uses standad nagios interface to display 3 sections -
###      network problems
###      host problems
###      services problems (not on a host that is down)
###

BINDIR=`dirname $0`

REQUEST_METHOD="GET"
export REQUEST_METHOD

$BINDIR/outages.cgi   | sed -e '1,$s/Network Outages/SMWW/'

QUERY_STRING='hostgroup=all&style=hostdetail&hoststatustypes=4&hostprops=42&noheader'
export QUERY_STRING
$BINDIR/status.cgi | grep -v '^Cache-Control:' | grep -v '^Pragma: no-cache' | \
grep -v '^Refresh: '  | grep -v '^Last-Modified' | grep -v '^Expires:' | grep -v '^Content-type:'

QUERY_STRING='host=all&type=detail&servicestatustypes=28&hoststatustypes=3&serviceprops=42&noheader'
export QUERY_STRING
$BINDIR/status.cgi | grep -v '^Cache-Control:' | grep -v '^Pragma: no-cache' | grep -v '^Refresh: ' |  \
 grep -v '^Last-Modified' | grep -v '^Expires:' | grep -v '^Content-type:'

SMWW Installation

The installation of SMWW is trivial. You can cut and paste the code shown above, or right click on the download links here for smww.php and smww.cgi. Place the smww.php that into the nagios/share directory, and the smww.cgi file into the nagios/sbin directory. Remember to make the cgi file executable.

Usage

You can point your browser at http//MY.SERVER/nagios/smww.php to display the screen with frames, but your could also use http//MY.SERVER/nagios/cgi-bin/smww.cgi for browsers that do not use frames.

Integrating SMWW into the Nagios side menu

If you want to use point and click on the left menu bar of Nagios to access SMWW, one logical place to link it in is the "Problems" header line. Currently, this just displays the same information as the host selection, so changing it will not delete any functionality.

Edit the side.php file in nagios/share directory (after making a backup copy, of course) and change the part of the Problems line that looks like:

         /status.cgi?host=all&servicestatustypes=28

to be:
	/smww.cgi

After reloading you current page, you should be able to click on the Problems line in the menu and get the SMWW display.

CHANGES

Changelog
2014/05/22 Ver 1.0 - inital release
2014/06/05 version 1.1 - smww.cgi - servicestatustypes changed from 16 to 28
2014/06/05 version 1.2 - smww.cgi - remove serviceprops=42 option to allow passive problems to show