/*******************************************************************************

    Author ......... Billy Gunn
    Contact ........ billy@gunn.org
    Program ........ Nagios Plugin for Cacti (NPC)
    Version ........ 0.1.1a
    Purpose ........ A UI replacement for Nagios integrated into Cacti

*******************************************************************************/


----[ Disclamer

    It's the same old story... I take no responsibilty for anything.

----[ Purpose

    As a long time user of Nagios and Cacti I consider both applications crucial to
    understanding the health of my network. The purpose of NPC is to be a complete
    UI replacement to Nagios integrated into Cacti. This will give a single point
    for trending and alert monitoring as well as an improved UI for Nagios.

    The magic of Nagios is its ability to determine the status of a network device
    or service. I feel as though the interface has not cept pace. Cacti on the other
    hand as a fantastic interface. I spend a lot more time in Cacti then I do Nagios
    and decided that I would like to view Nagios status from within Cacti. Additionally
    I wanted to be able to tie Cacti graphs to Nagios hosts and services. With that
    in mind, NPC was born.

----[ Features

    - A central location to monitor trends and alerts.
    - The ability to map Cacti graphs to services or hosts monitored by Nagios.
    - Mapped graphs are shown/hidden dynamically with a mouse click in host or service lists.
    - NPC supports issuing most Nagios commands (only if Nagios and Cacti are on the same host).

----[ Requirements

    - Cacti v0.8.6f or later.
    - Nagios 2.0b4 or later compiled with --enable-event-broker
       * Earlier releases will not work do to changes in the event broker architecture.
    - MySQL 4.1.x
       * You will need the MySQL development RPM's to compile the inserter module.
    - InnoDB support (The NPC tables will be created as InnoDB).
    - Plugin Architecture for Cacti. (http://cactiusers.org/downloads/cacti-plugin-arch.zip)

----[ Installation

    Cacti:
    - Unzip NPC into the plugins directory under your Cacti installation.
       * /cacti/plugins/npc 
    - Edit /cacti/includes/config.php and add: $plugins[] = 'npc';

    - Log into Cacti or load/refresh any page in Cacti to cause setup.php
    to run. This will build the database tables required by the Nagios
    Event Broker module that you will install below.

    - Nagios Event Broker:
    Edit the MySQL options on line 143 of /cacti/plugins/npc/neb/inserter.c. The parameters
    for connecting to the Cacti database have to be hard coded right now. In the future
    the parameters will be able to be passed in from Nagios.

    Next, copy /cacti/plugins/npc/neb/inserter.c and /cacti/plugins/npc/neb/makefile 
    to module/ under your Nagios source directory. cd to the module directory and 
    run make. When make completes you should have a file called inserter.o. This is 
    the module that will be loaded by Nagios. Copy inserter.o to /path/to/nagios/modules. 

    Edit nagios.cfg and set:

	retain_state_information=0
	event_broker_options=-1 and 
    	broker_module=/path/to/nagios/modules/inserter.o

        NOTE: Setting retain_state_information=0 causes all hosts and services to
	      go to a pending state until rechecked by Nagios. Without this setting 
	      the inserter module will never update any data in NPC. Its a minor
	      inconvenience that I will try to fix in the inserter module.

----[ Usage

    Its a simple system that will be easily learned by clicking around. However,
    there are a few configuration options to be aware of:

    - console -> Devices -> <device>
	~ After clicking to edit a device you will see a new field called <Nagios Host Mapping>.
          This drop down menu allows you to map a Nagios host to a cacti host. At the moment all
          that this mapping does is create a dynamic link from the host info page in NPC back to 
          the cacti graphs for that host. I could/will do more in the future.

   - console -> User Management -> <user> -> Realm Permissions
	~ Check the <View NPC> checkbox to give view permissions on a per user basis.

   - console -> Settings -> NPC
	~ Just a few entries here to setup Nagios command execution and refresh rate on Nagios pages.
    
----[ Bugs?
   
    Email me with bugs... I will do my best to fix them.


----[ Future Changes
    
    - Remote command execution across hosts
    - Scheduling down time.
    - Integrating performance graphing
    - Threshold plugin integration
    
    Please email me with any features that would be useful to you.

----[ Changelog

     --- 0.1.1a ---
           Added expand / collapse all to Status Detail

     --- 0.1.0a ---
           Initial release
     
