NPC Quick Start Guide
Table of Contents
The purpose of this guide is to outline the minimum steps necessary to get NPC installed and running.
Below are the minimum requirements:
- PHP 5.1
- PDO and JSON support are required
- Latest NPC Release
- NDOUtils 1.4b7
- Nagios 3.x
- Cacti 0.8.7b
- Cacti Plugin Architecture v2.0
NPC has been tested with the above application versions. PHP 5.2 is required do to the use of PDO and JSON. PHP 5.1 with PDO and JSON modules installed "may" work but will not be supported.
The default memory limit for PHP probably will not be enough to run NPC. Edit /etc/php.ini and update the memory_limit option. Set it to at least 32M.
memory_limit = 32M
Note on RHES/CentOS PHP 5.1.x: I have successfully tested NPC on PHP 5.1.6. This required that the json module be installed (JSON is included in PHP 5.2). I could not find a pre-built php-json module for RHES/CentOS with PHP 5.1.x. I found a source rpm here. I rebuilt the rpm for php 5.1.6 with the following command. Prior to rebuilding I had to install a few extra components with yum. In my case I had to do a:
'yum install php-devel autoconf automake libtool'.
Then rebuild the source RPM with the following command:
rpmbuild --rebuild php-json-4.3.2_1.2.1-1.aurore.src.rpm
You must have Cacti installed with the plugin architecture version 2.0 or higher before installing NPC.
Grab the latest version of NPC from the downloads section and do the following steps:
- Untar/zip npc into <path_to_cacti>/plugins/
- login to cacti as an admin.
- Install the plugin in Cacti
- Go to Console -> Plugin Management -> Uninstalled
- Click the Install link under the npc section
- Next, click the Installed tab
- To enable NPC click the Enable link under the npc section
- You can find the NPC plugin options under the Cacti Settings section
Note: If you do not see the Plugin Management link then go to user management and enable it.
Note: Users that had a version of npc less than 2.0.0a-151 can remove the following line from <path_to_cacti>/include/global.php
$plugins = 'npc';
Without NDO2DB feeding Nagios data into NPC the dashboard (and other screens) will be empty and should look like this.
Next, there are a few NPC settings to add/update. click the Console tab -> Settings (under Configuration heading) -> NPC tab.
- Remote Commands
- Check the checkbox to enable remote commands. At the moment this is system wide so all users that can access NPC will be able to execute commands.
- Nagios Command File Path
- Add the path to the nagios command file. It will be something like /usr/local/nagios/var/rw/nagios.cmd
- Nagios URL
- The URL to the Nagios web interface is used to get access to the status map and reporting CGI's. You can also access the Nagios UI by clicking the "Nagios" link in the left hand "Navigation" pane in NPC.
- Set the date and time format to your liking.
Refer to the Nagios documentation for installation. Some parts of NPC like reporting and the status map use the Nagios interface by wrapping the Nagios CGI's in an Iframe. Be sure to have the Nagios web UI working if you want to use the reporting and status map features.
The following parameters are found in the Nagios configuration file nagios.cfg
The power of NPC is greatly enhanced by the ability to issue commands to the Nagios process. To enable external commands in Nagios set:
Check external commands as often as possible.
Broker all events.
The path to the event broker module and config file which you will install next. This example assumes Nagios is installed in /usr/local/nagios. Adjust the path to suit your installation.
If you want to use performance data from Nagios plugins to create graphs in cacti then set the following parameter.
Setting host_perfdata_command and service_perfdata_command is not necessary. The performance data will be written to the NPC database where it can be polled by cacti using the perfdata.php script included with NPC.
NOD2DB is part of the NDOUTILS package. Nagios hands events off to NDO2DB via the event broker. NDO2DB handles the actual inserts of Nagios data into the NPC tables.
Instructions for compiling, installing, and configuring NDO2DB are included in the README file of the ndoutils package. The README has four sections. Skip the section on initializing the database.
- Follow the 'COMPILING INSTRUCTIONS' section of the README.
- Skip the 'INITIALIZING THE SQL DATABASE' section of the README
- Follow the 'INSTALLING THE NDOMOD BROKER MODULE' section of the README
- Follow the 'INSTALLING THE NDO2DB DAEMON' section of the README
Edit /usr/local/nagios/etc/ndo2db.cfg and add/update the following parameters:
db_servertype=mysql db_host=localhost (the host/ip where cacti database is running) db_port=3306 db_name=cacti (Your cacti database name) db_prefix=npc_ db_user=<user> (Your cacti database user) db_pass=<pass> (Your cacti user password)
The user/pass you assign needs select, insert, update, delete on all the npc_ tables.
ndo2db can communicates with the Nagios ndo2db.o module via unix socket or TCP. Use whatever works for you (I use the TCP mode) but you need to set it the same in both the ndo2db.cfg and ndomod.cfg.
NOTE: The config_output_options parameter in ndomod.cfg must be set to 2 (config_output_options=2).
Here are working ndo2db.cfg and ndomod.cfg configs. As noted above the database parameters need to be changed for your database.
ndo2db_user=nagios ndo2db_group=nagios socket_type=tcp socket_name=/usr/local/nagios/var/ndo.sock tcp_port=5668 db_servertype=mysql db_host=localhost db_port=3306 db_name=DATABSE_NAME db_user=DATABASE_USER db_pass=DATABASE_PASSWORD db_prefix=npc_ max_timedevents_age=1440 max_systemcommands_age=10080 max_servicechecks_age=10080 max_hostchecks_age=10080 max_eventhandlers_age=44640 debug_level=1 debug_verbosity=1 debug_file=/usr/local/nagios/var/ndo2db.debug max_debug_file_size=1000000
instance_name=default output_type=tcpsocket output=127.0.0.1 tcp_port=5668 output_buffer_items=5000 buffer_file=/usr/local/nagios/var/ndomod.tmp file_rotation_interval=14400 file_rotation_timeout=60 reconnect_interval=15 reconnect_warning_interval=15 data_processing_options=-1 config_output_options=2
NOTE: I had some problems with the ndo2db process dying (regularly) on Fedora Core 7. To get around that I setup the process to respawn via init. If you have trouble with the daemon dying you can add the following line to /etc/inittab. Only do this if ndo2db frequently dies unexpectedly on you.
ndo:345:respawn:/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
After editing inittab issue the following command:
You may see messages like the following in your syslog when using init to respawn ndo2db:
Apr 19 11:11:55 acid init: Id "ndo" respawning too fast: disabled for 5 minutes
Besides muddying up my logs there is no harm and so far this is the only way I have been able to keep ndo2db running.