全部博文(403)
分类: 系统运维
2009-12-01 09:38:42
The purpose of this guide is to outline the minimum steps necessary to get NPC installed and running.
Below are the minimum requirements:
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 . 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 version 2.0 or higher before installing NPC.
Grab the latest version of NPC from the downloads section and do the following steps:
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
$plugins[] = 'npc';
Click the NPC tab. The 1st load of NPC may be slow as all the javascript for the interface is loaded and cached.
Without NDO2DB feeding Nagios data into NPC the dashboard (and other screens) will be empty and should look like .
Next, there are a few NPC settings to add/update. click the Console tab -> Settings (under Configuration heading) -> NPC tab.
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=1
Check external commands as often as possible.
command_check_interval=-1
Broker all events.
event_broker_options=-1
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.
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
If you want to use performance data from Nagios plugins to create graphs in cacti then set the following parameter.
process_performance_data=1
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.
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=(Your cacti database user) db_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.cfg
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
ndomod.cfg
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:
telinit Q
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.