Nagios+Cacti 安装笔记

Nagios的安装部署和与Cacti的整合

注:所需软件自行下载 gd gd-devel png png-devel jpeg jpeg-devel zlib zlib-devel 保证 安装
第一部分:Nagios的安装

1.安装基础nagios
useradd nagios
wget wget
tar xvf nagios-3.3.1.tar.gz
cd nagios
注:安装到apache web 目录
./configure --prefix=/data/www/wwwroot/nagios  --with-gd-lib=/usr/lib   --with-gd-inc=/usr/include
make all
make install && make install-init && make install-commandmode && make install-config
mv sample-config/httpd.conf /usr/local/apache2/conf/extra/nagios.conf
在apache的配置文件中 加入 Include conf/extra/nagios.conf
注:apache具体地址根据实际情况
htpasswd -c /data/www/wwwroot/nagios/etc/htpasswd.users nagiosadmin
设置管理密码
chkconfig nagios on

2.安装nagios-plugins
wget
tar xvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/data/www/wwwroot/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

3.安装nagios-snmp-plugins
tar xvf nagios-plugins-snmp-0.6.0.gz
cd nagios-plugins-snmp
./configure --prefix=/data/www/wwwroot/nagios
make
make install

客户机

4.nagios-plugins 和 nrpe 安装
wget
tar xvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/data/www/wwwroot/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

wget
tar -zxvf nrpe-2.12.tar.gz && cd nrpe-2.12
./configure --prefix=/data/www/wwwroot/nagios/ --enable-ssl --with-ssl-lib
make all && make install-plugin && make install-daemon && make install-daemon-config

3)配置nrpe

#配置nrpe信息
vi /usr/local/nagios/etc/nrpe.cfg,查找并修改如下一行
allowed_hosts=192.168.1.100,127.0.0.1   #注意修改为nagios服务器的IP:192.168.1.100

#配置监控对象
说明:由监控原理可知被监控端做监控,然后将数据传给监控服务器绘总,设置监控详细参数主要是设置被监控端的nrpe.cfg文件,可以看到里面监控对象
vi /usr/local/nagios/etc/nrpe.cfg,查找并修改如下一行
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 10% -c 5%
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 500 -c 550
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_ping]=/usr/local/nagios/libexec/check_ping -H 192.168.1.1 -w 100.0,20% -c 500.0,60%
............................................#自已添加.......................................................... 
#command[check_http]=/usr/local/nagios/libexec/check_http -I 127.0.0.1 -w 10 -c 20
#command[check_ssh]=/usr/local/nagios/libexec/check_ssh -4 127.0.0.1

4)启动nrpe,并测试
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
echo '/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d &> /dev/null' >> /etc/rc.local
netstat -atulnp | grep 'nrpe'
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      3308/nrpe
/usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12

5)nrpe常见故障

错误一:/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
CHECK_NRPE: Error - Could not complete SSL handshake
解析办法:配置allowed_hosts=192.168.1.100,127.0.0.1,然后kill进程再重启就OK了

错误二:/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
Connection refused by host
解析办法:Nrpe进程没有启动

/data/www/wwwroot/nagios/bin/nrpe -c /data/www/wwwroot/nagios/etc/nrpe.cfg -d

4.其他设置
/data/www/wwwroot/nagios/bin/nagios -v /data/www/wwwroot/nagios/etc/nagios.cfg
检查nagios的配置是否正确,在后面配置nagios过程中我们为了检测配置的是否正确需要不断执行该命令来检查配置文件。

二。cacti安装
wget
yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel intltool
tar zxvf rrdtool-1.4.7.tar.gz
cd rrdtool-1.4.7
 ./configure --prefix=/usr/local/rrdtool --disable-tcl
make && make install
ln -s /usr/local/rrdtool/bin/* /usr/local/bin/

wget
tar xvf net-snmp-5.3.4.tar.gz
cd net-snmp-5.3.4
./configure --prefix=/usr/local/net-snmp
make && make install
ln -s /usr/local/net-snmp/bin/* /usr/local/bin/
cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf
/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf
echo "#/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf " >>/etc/rc.local


wget
tar xvf cacti-0.8.7h.tar.gz
 mv cacti-0.8.7h /data/www/wwwroot/cacti


Mysql>create database cacti;
Mysql>grant all on cacti.* to cacti@'localhost' identified by 'zzzzzzz';
Mysql>flush privileges;
mysql> use cacti;
mysql> source /data/www/wwwroot/cacti/cacti.sql

vim /data/www/wwwroot/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "zzzzzz";
$database_port = "3306";
$database_ssl = false;

在浏览器中访问 cacti 根据提示安装

安装时注意 rrdtool、snmp 程序路径

生成图形
/usr/local/php-5.2.17/bin/php /data/www/wwwroot/cacti/poller.php
crontab -e
*/5 * * * * /usr/local/php-5.2.17/bin/php /data/www/wwwroot/cacti/poller.php  > /dev/null 2>&1

默认设置,账户和密码都是admin,登录后强制提示更改密码

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/88da3bd5d4a6322e715e97002e2e5983.html