linux 架设nagios+cacti+nconf完整配置,生产环境中的配置。

以下是傻瓜配置,复制粘贴可以完成。有空我会写个script来帮助大家进一步解决傻瓜的复制粘贴步骤。

但还是希望大家了解nagios cacti nconf是怎样工作的,框架是怎样的。


下面是配置全过程



1.先安装各个nagios+cacti的依赖包

 

更新源rpm -ivh http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm

yum update

 

yum -y install httpd php php-gd freetype php-mysql php-snmp php-devel mysql mysql-server perl-DBD-MySQL php-pdo net-snmp net-snmp-libs net-snmp-utils net-snmp-devel ruby ruby-devel gcc glibc glibc-common gd gd-devel ntp

 

yum -y install httpd gcc gcc-c++ glibc glibc-common gd* gd-devel php php-mysql mysql mysql-server mysql-devel openssl-devel    (nagios安装需要的依赖包)

 

yum install httpd php php-mysql php-snmp mysql perl-dbd-mysql php-pdo net-snmp-libs net-snmp-utils perl-rrdtool rrdtool-devel rrdtool      *         (cacti需要)

 

再安装其他必要包

yum -y install php-pdo lm_sensors php-snmp net-snmp-utils net-snmp-libs perl-net-naemon perl-pirpc perl-dbi perl-dbd-mysql libcgi glib

 

yum install php-mcrypt libmcrypt mhash (phpmyadmin需要)

 

 

安装webmin

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.580-1.noarch.rpm

rpm -ivh  /home/sotf/webmin/webmin-1.580-1.noarch.rpm

iptables -I INPUT -p tcp --dport 10000 -j ACCEPT

 

安装nagios

useradd nagios

usermod -a �CG nagios apache

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.3.1.tar.gz

cd nagios

tar zxvf nagios

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagios --with-gd-lib=/usr/lib --with-gd-inc=/usr/include --enable-event-broker --enable-embedded-perl

make all

make install

make install-init

make install-commandmode

make install-config

make install-webconf

make install-exfoliation

make install-classicui

service httpd restart

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

安装nagios-plugin

wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz

tar zxvf nagios-plugins

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql --with-gnutls --enable-extra-opts --enable-perl-modules --enable-libtap --with-openssl

 

make

make install

chkconfig �Cadd nagios

chkconfig nagios on

vim /etc/profile

export PATH=$PATH:/usr/local/nagios/bin

service nagios start

 

setenforce 0

 

安装addon

http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz

 

tar zxvf nrpe

./configure --enable-ssl --with-ssl-lib=/lib/

make

make install

 

chown -R nagios.nagios /usr/local/nagios/libexec/

 

 检查配置文件是否正确 :/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg service nagios start

注意:如果你开启了 selinux 需要配置如下二步:
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/ 


安装CACTI

rrdtool

wget http://packages.express.org/rrdtool/rrdtool-1.4.4-1.el5.wrl.i386.rpm

wget http://packages.express.org/rrdtool/rrdtool-devel-1.4.4-1.el5.wrl.i386.rpm

wget http://packages.express.org/rrdtool/rrdtool-perl-1.4.4-1.el5.wrl.i386.rpm

wget http://flexbox.sourceforge.net/centos/5/i386/rrdtool-php-1.4.4-1.el5.i386.rpm

 

yum localinstall -y --nogpgcheck rrdtool-*

 

配置snmp

vim /etc/snmp/snmpd.conf

spacer.gif

service snmpd start

chkconfig snmp on


 

下载cacti

wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz

wget http://www.cacti.net/downloads/cacti-0.8.7h.tar.gz

tar zxvf cacti-0.8.7h.tar.gz

mv cacti-0.8.7h /var/www/html/cacti

 

创建cacti数据库

service mysqld start

mysql

create database cacti;

grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';

flush privileges;

quit

 

cd /var/www/html/cacti/

mysql -ucacti -pcacti cacti < /var/www/html/cacti/cacti.sql

vim /var/www/html/cacti/include/config.php

spacer.gif

vim /var/www/html/cacti/include/global.php

spacer.gif

 

useradd -r -M cacti

chown -R cacti /var/www/html/cacti/rra/

chown -R cacti /var/www/html/cacti/log/

 

su cacti

crontab �Ce

*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1

php /var/www/html/cacti/poller.php

exit

 

进入网页配置

 

整合nagioscacti

安装ndoutils

下载ndoutils

tar xvf ndoutils-1-5.tar

cd ndoutils-1-5

./configure --enable-mysql --disable-pgsql --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql

make

cd src

cp ndomod-3x.o ndo2db-3x file2sock log2ndo /usr/local/nagios/bin/

cd ../db

./installdb -u cacti -p cacti -h localhost -d cacti

cd ../config

cp ndo2db.cfg-sample ndo2db.cfg

cp ndomod.cfg-sample ndomod.cfg

cp ndo2db.cfg ndomod.cfg /usr/local/nagios/etc/

chmod 644 /usr/local/nagios/etc/ndo*

chown nagios.nagios /usr/local/nagios/etc/*

chown nagios.nagios /usr/local/nagios/bin/*

 

修改nagios.cfg配置

spacer.gif

broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg

 

修改ndo2db.cfg

spacer.gif

 

修改ndomod.cfg

25 output_type=tcpsocket

39 output=127.0.0.1

添加ndo2db服务启动

cd /home/soft/nagios/addon/ndoutils-1-5

cp daemon-init /etc/init.d/ndo2db

vim /etc/init.d/ndo2db

spacer.gif

chmod +x /etc/init.d/ndo2db

service ndo2db start

chkconfig ndo2db on

service nagios restart

 

安装ncp

安装cacti-plugin

tar zxvf cacti-plugin-0.8.7h-PA-v3.0.tar.gz

cp -R cacti-plugin-arch/* /var/www/html/cacti/

mysql -ucacti -pcacti cacti<pa.sql

patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff

vim include/config.php

$url_path = "/cacti/";

 

下载npc

tar xvf npc

mv npc /var/www/html/cacti/plugins/

vim /var/www/html/cacti/include/config.php

$plugins[] = 'npc';

 

npc需要安装json

tar xzvf json-1.2.1.tgz

cd json-1.2.1

phpize

./configure

make

make install

php -i | grep php.ini

vim /etc/php.ini

spacer.gif

 

vim /etc/httpd/conf/httpd.conf

spacer.gif

 

usermod -G cacti apache

service httpd restart

php -m

 

 

vim /var/www/html/nagios/etc/ndo2db.cfg

111 db_prefix=npc_

 

mysql -u cacti -p cacti

use cacti;

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;

quit

 

 

安装nconf

mysql

create database nconf;

grant all privileges on nconf.* to nconf@localhost identified by 'nconf';

flush privileges;

quit

 

 

tar xvf nconf-1.2.6-0.tgz -C /var/www/html/

cd /var/www/html/nconf/

chown -R apache.apache config/ temp/ static_cfg/ output/

 

进入web页面配置好

rm -rf INSTALL INSTALL.php UPDATE UPDATE.php

ln -s /usr/local/nagios/bin/nagios bin/nagios

chown -R apache.apache bin

chmod +x /usr/local/nagios/bin/nagios

chmod +x /var/www/html/nconf/ADD-ONS/deploy_local.sh

vim /var/www/html/nconf/ADD-ONE/deploy_local.sh


spacer.gif

 

打开selinux需要添加如下

chcon -t httpd_sys_script_exec_t /var/www/html/nconf/bin/nagios

 

vim /usr/local/nagios/etc/nagios.cfg

spacer.gif

 

安装cacti-spin

tar xvf cacti-spine

./configure

make

make install

到页面设置路径

 

 

加入运行sh

*/1 * * * *  /var/www/html/nconf/ADD-ONS/deploy_local.sh

 

必定要看/usr/local/nagios/etc下的文件权限问题

最后要chown �CR nagios.nagios etc

 

最后将crontab全部改为1分钟



上面是安装server端已经完成,下面配置client

请search:"添加被监控server的详细配置"

添加完后某些服务需要监控才能够修改。look it this notes

nagios 修改用户密码 验证配置 开启 

#验证naigios配置的正确性

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

#验证通过以后 可以执行下面命令作为守护进程

/usr/local/nagios -d /usr/local/nagios/etc/nagios.cfg

#更改web用户名和密码

1.ee /usr/local/nagios/etc/htpasswd.users

2.编辑/usr/local/nagios/etc/cig.cfg   |grep 'authorized'

文件,将开始建立的用户名test添加到里面,允许该账户通过web登陆(如果有多个登陆账号,在后面用,号隔开)。


你可能感兴趣的:(cacti,nagios,nconf)