# yum install -y httpd gcc glibc glibc-common gd gd-devel php php-gd ntp
# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz
# make install && make install-init && make install-commandmode && make install-config && make install-webconf
# htpasswd -c /var/www/html/nagios/etc/htpasswd.users nagiosadmin
# wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
# wget http://www.cacti.net/downloads/cacti-0.8.7h.tar.gz
mysql> grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';
$database_default = "cacti"; //默认数据库名
$database_hostname = "localhost"; //主机名
$database_username = "cacti"; //登陆数据库用户名
$database_password = "cacti"; //登陆数据库密码
$database_port = "3306";
*/1 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
# php /var/www/html/cacti/poller.php > /dev/null 2>&1
# wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz/download
# ./configure --prefix=/var/www/html/nagios --enable-mysql --disable-pgsql --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql
# cp -v src/{ndomod-3x.o,ndo2db-3x,file2sock,log2ndo} /var/www/html/nagios/bin
# cp -v config/{ndo2db.cfg-sample,ndomod.cfg-sample} /var/www/html/nagios/etc
# mv /var/www/html/nagios/etc/ndo2db.cfg-sample /var/www/html/nagios/etc/ndo2db.cfg
# mv /var/www/html/nagios/etc/ndomod.cfg-sample /var/www/html/nagios/etc/ndomod.cfg
broker_module=/var/www/html/nagios/bin/ndomod-3x.o config_file=/var/www/html/nagios/etc/ndomod.cfg
# /var/www/html/nagios/bin/ndo2db-3x -c /var/www/html/nagios/etc/ndo2db.cfg
# echo "/var/www/html/nagios/bin/ndo2db-3x -c /var/www/html/nagios/etc/ndo2db.cfg" >> /etc/rc.local
# wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz
$url_path = "/cacti/";
从web进入cacti,启用cacti plugin扩展
$plugins[] = 'npc';
# wget http://pkgs.fedoraproject.org/repo/pkgs/php-pecl-json/json-1.2.1.tgz/d8904d2f004ceec85eeacf524cd25539/json-1.2.1.tgz
AddType application/x-httpd-php .php .phtml
DirectoryIndex index.html index.html.var index.php
alter table npc_eventhandlers add long_output TEXT NOT NULL default '' after output;
alter table npc_hostchecks add long_output TEXT NOT NULL default '' after output;
alter table npc_hoststatus add long_output TEXT NOT NULL default '' after output;
alter table npc_notifications add long_output TEXT NOT NULL default '' after output;
alter table npc_servicechecks add long_output TEXT NOT NULL default '' after output;
alter table npc_servicestatus add long_output TEXT NOT NULL default '' after output;
alter table npc_statehistory add long_output TEXT NOT NULL default '' after output;
alter table npc_systemcommands add long_output TEXT NOT NULL default '' after output;
在Settings->npc中 ,勾上Remote Commands
Nagios Command File Path= /var/www/html/nagios/var/rw/nagios.cmd
mysql> grant all privileges on nconf.* to nconf@localhost identified by 'nconf';
# wget http://sourceforge.net/projects/nconf/files/nconf/1.2.6-0/nconf-1.2.6-0.tgz/download
# chown -R apache.apache config/ temp/ static_cfg/ output/
# ln -s /var/www/html/nagios/bin/nagios bin/nagios
# chmod +x /var/www/html/nconf/bin/generate_config.pl
# chmod +x /var/www/html/nconf/ADD-ONS/deploy_local.sh
点击Generate Nagios config尝试生成配置文件,以测试是否与nagios成功关联
注意:nconf在点击【Generate Nagios config】后将您的生成nagios配置文件是/var/www/html/nconf/output/NagiosConfig.tgz,而并非直接导入nagios中。
1.在web页面对监控服务和主机配置完毕,点击【Generate Nagios config】
cfg_dir=/var/www/html/nagios/etc/Default_collector
cfg_dir=/var/www/html/nagios/etc/global
ndomod: Could not open data sink! I'll keep trying, but some output may get lost...
检查 /nagios/etc目录的权限是否足够的大
event_broker_options=-1