Nagios Dashboard - PHP


#1

Hello,

We implemented Nagios and found that trying to display their web interface and some other interfaces on a projector screen was not working. I am not a dedicated programmer but i decided to code my own web interface. It is coded in PHP. It requires that PHP5 be installed on your Nagios box. The PHP script is quite flexible and can be edited easily.

The web interface is being used on our live Nagios box, version 3.0.3. Put script in /var/www and point your web browser to your
nagiosbox/nagios.php

It will display hosts/services in a table with different colors etc indicating whether the host/service is up, down, warning, critical.

This might help someone somewhere somehow. Script attached.


#2

Do you have some screenshots for us? 8)


#3

Screens attached. Screens are from live environment without hosts column and services column.The data for the table is pulled straight from status.dat.




#4

Anyone tried the above yet?


#5

This looks good! . I have started using it with bit more customization and gave a Netcool look.
Is it possible to alter this script to get status of a particular hostgroup? Did someone try that ?


#6

We changed the script a bit and uploaded it to our blog:

dingleberry.me/2009/11/nagios-op … dashboard/

Thanks for giving us the base to work on:)


#7

Great script! We are currently using it on our production Nagios servers.

We did have one small problem though. After a few days we ended up with about 70G of error logs resulting from two lines of the code.

/var/log/apache/error.log:

[Mon Mar 28 14:27:27 2011] [error] [client xxx.xxx.xxx.xxx] PHP Notice:
Undefined offset: 0 in /var/www/dashboard/nagios_get.php on line 208,
referer: nagios.lcsee.wvu.edu/dashboard/
[Mon Mar 28 14:27:27 2011] [error] [client xxx.xxx.xxx.xxx] PHP Notice:
Undefined offset: 0 in /var/www/dashboard/nagios_get.php on line 224,
referer: nagios.lcsee.wvu.edu/dashboard/

We are actually using the modified version from dingleberry.me (Thanks to them as well) so the line numbers don’t match up but the offending lines are:

if ($servicearray$servicecount] != “”) { //if the host has a service being checked
and
if ($servicearray$servicecount] == “”) { //if the host has no service being checked

The problem is we have a few entities which don’t have services (used as parents) so $servicearray[0] isn’t a valid array index at the point of those evaluations.
To remedy the problem I added an ‘else’ to an earlier evaluation which determines if there are any services. If there are no services then it sets $servicearray[0]="".
The code follows.

Original:

if ($servicepos !== false) {
$servicecount++;
$servicearray$servicecount] = substr($line, strpos($line, ‘=’) + 1, strlen($line));
$check = 1;
}

Modified:

if ($servicepos !== false) {
$servicecount++;
$servicearray$servicecount] = substr($line, strpos($line, ‘=’) + 1, strlen($line));
$check = 1;
} else {
$servicearray[0] = “”;
}

Fairly simple fix but I hope this can help someone in the future.

Thanks again for the great script!


#8

I would be completely lost without threads like this, thank you guys for working on this nice script and plucking away and the errors, you guys are giving me some good guidelines to work within. I was getting a bit worried that I might have to run a pst repair tool or something to that effect, but all seems well on the home front. I officially give this thread an A+.


#9

Hi there,

I am wondering if anyone can help me on this.

I am using the PHP Dashboard but I have a couple of problems that have come up :

  1. It does not show up Passive Checks
  2. Service checks of the same name on two different devices do not show up both. Only one shows.

Could anyone be able to help me on this ?

Thanks