1、说明
闲暇之余,安装nagios+cacti,想看下终究实现效果;本文档规范网络监控系统安装流程及安装内容,供运维人员在部署新的运营环境时参考使用。
2、Nagios的安装
1、下载
#wget
http://jaist.dl.sourceforge.net/project/nagios/nagios⑶.x/nagios⑶.5.0/nagios⑶.5.0.tar.gz (nagios主程序)
#wgethttp://jaist.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins⑴.4.16.tar.gz (监控插件)
#wgethttp://jaist.dl.sourceforge.net/project/nagios/nrpe⑵.x/nrpe⑵.14/nrpe⑵.14.tar.gz
(nrpe插件)
2、需要的基础套件
#rpm-q gcc glibc glibc-common gd gd-devel openssl-devel httpd php
3、创建用户和组
#useradd nagios
#mkdir /usr/local/nagios
#chown -R nagios.nagios /usr/local/nagios
4、编译安装
#./configure --prefix=/usr/local/nagios
#make all
#make install
#make install-init
#make install-commandmode
#make install-config
#make install-webconf
5、创建Apache用户验证文件
创建1个nagiosadmin账户:
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
6、经常使用的命令
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
7、安装nagios-plugins
#./configure --with-nagios-user=nagios--with-nagios-group=nagios
#make&& make install
8、安装nrpe(监控端)
#./configure
#make all && make install-plugin
9、被监控端安装
1、系统环境
10、下载
#wgethttp://jaist.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins⑴.4.16.tar.gz (监控插件)
#wgethttp://jaist.dl.sourceforge.net/project/nagios/nrpe⑵.x/nrpe⑵.14/nrpe⑵.14.tar.gz (nrpe插件)
11、创建用户
#useradd nagios
#passwd nagios
12、检查基础套件
#rpm-q gcc glibc glibc-common gd gd-devel openssl-devel
13、安装nagios-plugins
#./configure
#make && make install
14、修改目录权限
#chown nagios.nagios /usr/local/nagios
#chown -R nagios.nagios /usr/local/nagios/libexec
15、安装nrpe
#./configure
#make all
#make install-plugin 安装check_nrpe
#make install-daemon
#make install-daemon-config
16、配置nrpe
#vi /usr/local/nagios/etc/nrpe.cfg 添加 allowed_hosts=192.168.40.128
17、启动nrpe
#/usr/local/nagios/bin/nrpe -c/usr/local/nagios/etc/nrpe.cfg -d
18、测试1下
#/usr/local/nagios/libexec/check_nrpe -H localhost
19、随机启动
#echo "/usr/local/nagios/bin/nrpe -c/usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.local
20、配置
1、# vi /usr/local/nagios/etc/objects/commands.cfg
definecommand{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c$ARG1$
}
参考资料:http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html
至此nagios的服务端与客户端搭建完成
3、安装cacti
Cacti的运行需要LAMP(Linux+Apache + MySQL + PHP), RRDTool ,net-snmp , AMP
正确配置各主机网络参数,本实验以1台机器既为服务端也为被监测端
[root@localhost~]#vim/etc/sysconfig/network-scrip/ifcfg-eth0
在被监测端安装net-snmp软件包,net-snmp软件需要用到lm_sensors提供的硬件监视模块,安装时直接使用RHEL5系统光盘中的rpm包文件,顺次安装lm_sensors、net-snmp两个软件包便可。
[root@localhost~]# cd /mnt/Server/
[root@localhostServer]# rpm -ivh lm_sensors⑵.10.0⑶.1.i386.rpm
[root@localhostServer]# rpm -ivh net-snmp⑸.3.1⑴4.el5.i386.rpm
3、配置及启动snmpd服务,修改文件/etc/snmp/snmpd.conf第41、62、85行,设置SNMP访问权限
41行中将default修改成cacti监测服务器的IP地址本实验为192.168.4.1将public修改成同享SNMP信息的组辨认字串publicsvr,62行 将systemview修改成all,85行去掉开头注释符号
41com2sec notConfigUser 192.168.4.1 publicsvr
62access notConfigGroup "" any noauth exact all none none
iewall included .1 80
4、启动snmpd服务并设置为自启动
[root@localhostServer]# service snmpd start
启动 snmpd: [肯定]
[root@localhostServer]# chkconfig --level 35 snmpd on
5、配置监测服务端
Cacti监测服务端需要有apache、mysql、php网站平台的支持,且需要预先安装有gd、zlib等软件包
httpd⑵.2.3⑹.el5
mysql⑸.0.22⑵.1
mysql-server⑸.0.22⑵.1
mysql-connector-odbc⑶.51.12⑵.2
php⑸.1.6⑸.el5
php-mysql⑸.1.6⑸.1.6⑸.el5、
php-common⑸.1.6⑸.1.6⑸.el5、php-pdo⑸.1.6⑸.el5
注:此处用源码包安装以下(也可用yum安装)
编译安装apache
[root@localhostLNS-SG4]# tar zxvf httpd⑵.2.9.tar.gz