12/22/06    Nagios 2.x Web Config 1.3

PURPOSE:
The purpose of this project is to provide a web-based front-end for the great Monitoring product called NAGIOS (please see the LEGAL document for trademark info)

STRATEGY:
Use MySQL and PHP to logically lay out the information needed by NAGIOS then use a script to create the text configuration files for NAGIOS.

ASSUMPTIONS:
PHP works with apache installed on the box.  Apache is installed under /usr/local/apache, just create a symbollic link if not.  You must have a basic understanding of Nagios.  You must be using Nagios 2.x.  Register_Globals must be set to on.

***NagiosWeb does NOT allow you to IMPORT old config files !!!!!*******

INSTALLATION:
There are quite a few customization steps required to get the config working, but stick with it it's worth it!!

install web files
1.  create a directory under your htdocs folder named nagiosweb and put all files from the nagiosweb folder into it.  Make sure the wwwrun user has read to all files and write access to your $nagios/etc directory.

add links to the side panel of NAGIOS
2.  edit the /usr/local/nagios/share/side.html page.  Add the following Rows to the Configuration table:


  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot1"></td>
    <td nowrap><a href="/nagiosweb/hostlist.php" target="main" onMouseOver="switchdot('config-dot1',1)" onMouseOut="switchdot('config-dot1',0)" class="NavBarItem">Hosts</a></td>
  </tr>
  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot2"></td>
    <td nowrap><a href="/nagiosweb/hostgrouplist.php" target="main" onMouseOver="switchdot('config-dot2',1)" onMouseOut="switchdot('config-dot2',0)" class="NavBarItem">Host 
      Groups</a></td>
  </tr>
  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot3"></td>
    <td nowrap><a href="/nagiosweb/servicelist.php" target="main" onMouseOver="switchdot('config-dot3',1)" onMouseOut="switchdot('config-dot3',0)" class="NavBarItem">Services</a></td>
  </tr>
  <tr>
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot10"></td>
    <td nowrap><a href="/nagiosweb/servicegrouplist.php" target="main" onMouseOver="switchdot('config-dot10',1)" onMouseOut="switchdot('config-dot10',0)" class="NavBarItem">Service Groups</a></td>
  </tr>
  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot4"></td>
    <td nowrap><a href="/nagiosweb/contactlist.php" target="main" onMouseOver="switchdot('config-dot4',1)" onMouseOut="switchdot('config-dot4',0)" class="NavBarItem">Contacts</a></td>
  </tr>
  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot5"></td>
    <td nowrap><a href="/nagiosweb/contactgrouplist.php" target="main" onMouseOver="switchdot('config-dot5',1)" onMouseOut="switchdot('config-dot5',0)" class="NavBarItem">Contact 
      Groups</a></td>
  </tr>
  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot6"></td>
    <td nowrap><a href="/nagiosweb/timeperiodlist.php" target="main" onMouseOver="switchdot('config-dot6',1)" onMouseOut="switchdot('config-dot6',0)" class="NavBarItem">Time Periods</a></td>
  </tr>
  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot7"></td>
    <td nowrap><a href="/nagiosweb/checkcommandlist.php" target="main" onMouseOver="switchdot('config-dot7',1)" onMouseOut="switchdot('config-dot7',0)" class="NavBarItem">Check Commands</a></td>
  </tr>
  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot8"></td>
    <td nowrap><a href="/nagiosweb/notifylist.php" target="main" onMouseOver="switchdot('config-dot8',1)" onMouseOut="switchdot('config-dot8',0)" class="NavBarItem">Notify Commands</a></td>
  </tr>
  <tr> 
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="config-dot9"></td>
    <td nowrap><a href="/nagiosweb/runscript.php" target="main" onMouseOver="switchdot('config-dot9',1)" onMouseOut="switchdot('config-dot9',0)" class="NavBarItem">Write Config</a></td>
  </tr>



Verify nagios.cfg is using the correct files
3. The nagios.cfg file provides a list of files that are used for configuation.  Make sure the list contains the following:

cfg_file=/usr/local/nagios/etc/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/dependencies.cfg
cfg_file=/usr/local/nagios/etc/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/servicegroups.cfg

Reference the extended host info in the cgi.cfg file
4.  Add the following Line to your cgi.cfg file:

xedtemplate_config_file=/usr/local/nagios/etc/hostextinfo.cfg

Copy the properties icon.
5.  Copy the prop.gif file from the images director and put it in /usr/local/nagios/share/images/logos folder

Setup the mysql database
6.  I have included a structure dump of the mysql database setup, nagiosweb.sql .  Create an empty database called nagiosweb.  Run the included nagiosweb.sql against it to setup the structure and add some sample entries.  By default the database is accessed through localhost using mysql/mysql.  You can change this in dbconfig.php.  You may also need to tweak some of the settings in dbconfig.php.

7.  Make sure the user you are running apache as has write permissions to the nagios/etc directory or you won't be able to write your configs.

8.  ********I'm working on removing this requirement!  Please try with global_variables off then post to forum if you run into problem.  *******    I know it sucks but for now please be sure you enable global_variables or some functionality will be lost.

That should do it.

Now when you goto:  http://nagios.yourdomain.com/nagios/  You should see the new links at the bottom of the left side.

If you are familiar with how the txt files are setup for NAGIOS this interface should be very easy to work with.  

CONFIGURATION STRATEGY - If you're confused on how objects interact this should help

Hosts go into HostGroups
Hosts or HostsGroups can be assigned Services
ContactGroups can be assigned to Services on Hosts or HostGroups
Contacts go into ContactGroups

  
Once you have added hosts, services, and contacts with the new links, click on Write configuration.  Here are 3 buttons.  The first one is Write the Config File, this will write out the txt files for nagios.  The second button is Verify the Config File, this will run '/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg' and display the output.  If you see any errors correct them using the interface then start with the first button again.  Once you have eliminated all the errors click on Restart the Process, then on Confirm.  

LIMITATIONS

One thing you will notice is a service cannot be double-assigned to a host.  If a host and a hostgroup it's assigned to are both assigned the same service you will get errors in the Verify Config File stage.  

HELP !!!!

If you have read through this README and are still confused the first thing I would ask you to do is setup one Host, one Service, and one Timeperiod manually.  This will give you an idea of what this interface is trying to do for you.

NO REALLY HELP ME !!!!

I won't guarantee anything, but you're welcome to drop me an e-mail detailing what problems you're running into and I'll try to help.  jkonkol@users.sourceforge.net



















