Nagex – Nagios Intranet Dashboard
Nagex is a Nagios intranet dashboard project driven by event handlers which feeds data to a MySQL database. The PHP script pulls the data for your internal/external company users to view infrastructure status information without giving them access to the CGI interface. This project can be easily integrated inside of your existing intranet using a PHP include or iframe for a custom look and feel since it does not have navigation or links. It utilizes the $HOSTALIAS$ so users do not see internal server names. If you want to display information about every host/service checked by Nagios, simply define the event_handler in your host and service templates instead of individual host and service definitions.
Nagex was my November 2011 project and is a modified version of another project called Nagdash, which was originally developed by John Kenyon. His website is no longer functional and hasn’t responded to my emails. Hope he’s ok. I found the original project on the Nagios Exchange. Feel free to modify Nagex however you want, or leave a comment below ^_^
GNU General Public License – Version 3, 29 June 2007
http://www.gnu.org
The prerequisites are a Linux box running MySQL, PHP, Nagios and a web server like Apache (LAMP). The only downside to Nagex is the fact that it relies on Nagios host and service state changes before it writes values to the mysql database since it does not pull information directly from the cgi’s. In order for data to populate, the event_handler needs to be executed which means hosts/services need to change states into soft or hard.
A quick and easy way is to disconnect the network connection on your nagios box and wait 15 minutes or whatever interval you have your host/service checks configured. If you can’t do this because you’re working in a production environment, then you can pre-populate the database by manually inserting data into the tables. My event handler shell script will update the data if it already exists instead of inserting new entries. Here is a great MySQL reference site: http://www.pantz.org/software/mysql/mysqlcommands.html
Download Nagex
Mirror 0 – Nagios Exchange
Mirror 1 – Sourceforge
Mirror 2 – Direct Link
Untar this project
[sourcecode language=”bash”]tar -xzvf nagex.tar.gz[/sourcecode]
Create a web-accessible directory
[sourcecode language=”bash”]mkdir /var/www/nagex[/sourcecode]
Directory placement
Put nagex.php and images folder in /var/www/nagex
Create the database
[sourcecode language=”bash”]mysql -u root -ppassword
mysql> create database nagex;[/sourcecode]
Create the database user
[sourcecode language=”bash”]mysql> use mysql;
mysql> grant all privileges on nagex.* to nagex@’localhost’ identified by ‘secret’;
mysql> flush privileges;
mysql> exit[/sourcecode]
Import the SQL schema dump
[sourcecode language=”bash”]mysql -u root -ppassword nagex < nagex_structure.sql[/sourcecode]
Copy the event handlers
[sourcecode language=”bash”]mkdir /usr/local/nagios/libexec/eventhandlers
cp ~/nagex/update-nagex /usr/local/nagios/libexec/eventhandlers/
cp ~/nagex/update-nagex-host /usr/local/nagios/libexec/eventhandlers/[/sourcecode]
Set permissions
[sourcecode language=”bash”]chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
chmod 755 /usr/local/nagios/libexec/eventhandlers/*[/sourcecode]
Add commands into commands.cfg
[sourcecode language=”bash”]define command{
command_name update-nagex
command_line /usr/local/nagios/libexec/eventhandlers/update-nagex $HOSTNAME$ "$HOSTALIAS$" "$SERVICEDISPLAYNAME$" $SERVICESTATE$ "$LONGDATETIME$"
}
# ‘update-nagex-host’ host update command deinition
define command{
command_name update-nagex-host
command_line /usr/local/nagios/libexec/eventhandlers/update-nagex-host $HOSTNAME$ "$HOSTALIAS$" $HOSTSTATE$ "$LONGDATETIME$"
}[/sourcecode]
Update service/host definitions with event_handler
[sourcecode language=”bash”]define service{
host_name somehost
check_command check_nrpe!CheckServiceState -a service
service_description Some Service
max_check_attempts 4
event_handler update-nagex
}
define host{
use windows-server
host_name EXCH1
alias Exchange Server
address 100.10.111.222
event_handler update-nagex-host
}[/sourcecode]
Modify nagex.php
Line 18, enter the password you’ve use to create the mysql user.
[sourcecode language=”bash”]$DBpassword = "secret";[/sourcecode]
Test out the web front end
http://yourhost/nagex/nagex.php
Still doesn’t work?
Contact me or leave a comment and I’ll do my best to help you
April 1, 2013 1:37 am @ 01:37
in which file i need to update the (Update service/host definitions with event_handler)
can you make this clear.
April 1, 2013 9:38 am @ 09:38
The file to update depends on what services/hosts you want displayed. For example, if I want to monitor a particular service of a Windows host then I would put the event_handler in windows.cfg like this:
define service{
use generic-service
hostgroup_name clientservers
service_description Client Servers
check_command check_nt!PROCSTATE!-d SHOWALL -l Process.exe
event_handler update-nagex
}
And if I want to display the status of the Host which runs this service, I would add the event_handler in my hosts.cfg:
define host{
use windows-server
host_name NT-XX-01
alias Server 2
address 192.168.1.200
hostgroups windows-servers, clientservers
event_handler update-nagex-host
}
June 20, 2013 4:58 am @ 04:58
Everything done as described here but the browser returns a 500 error. Could you help to identify what I did wrong?
Thanks
June 25, 2013 8:39 am @ 08:39
500 is a generic error. Have you tested with a test.html page? Have you tested php? You could enable debug errors in php.ini to help understand why it is failing.
http://stackoverflow.com/questions/2687730/how-can-i-make-php-display-the-error-instead-of-giving-me-500-internal-server-er