首页 > 代码库 > RHEL7.2安装Nagios4.2.1+Cacti0.8.8h
RHEL7.2安装Nagios4.2.1+Cacti0.8.8h
由于公司系统监控(IPMoniter)和网络流量监控(MRTG)分别由不同的软件监控且由几台服务器完成,近期想整合到一起,并改为开源免费的Nagios和Cacti完成。以下为部署日志。
一、安装RHEL7.2
最小化安装,配置IP,时间同步,本地yum源,安装vim(个人习惯)、bash-completion(命令补齐)
# yum install vim # yum install bash-completion # yum install chrony # systemctl enable chronyd # systemctl start chronyd # vim /etc/chrony.conf server 10.100.2.5 iburst //增加一行时间源 # yum install ntpdate # ntpdate 10.100.2.5
配置CentOS 163 yum源
# yum install wget # wget http://mirrors.163.com/centos/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm # wget http://mirrors.163.com/centos/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm # wget http://mirrors.163.com/centos/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm # wget http://mirrors.163.com/.help/CentOS7-Base-163.repo # rpm -qa|grep yum //检查redhat是否安装了yum,及有哪些Yum包 # rpm -qa|grep yum|xargs rpm -e --nodeps //删除redhat自带的yum包 # rpm -ivh yum-3.4.3-132.el7.centos.0.1.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm # mv CentOS7-Base-163.repo /etc/yum.repos.d/ # vim /etc/yum.repos.d/CentOS7-Base-163.repo //通过":1,$s/$releasever/7/gc"和":1,$s/$basearch/x86_64/gc"查找和替换文件内容 # yum clean all //清除yum缓存 # yum makecache //重建缓存,以提高搜索软件包速度 # yum update //更新系统(省略)
二、安装Nagios
1、下载软件包并安装Nagios
Nagios-4.2.1:
http://nchc.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.2.1/nagios-4.2.1.tar.gz
Nagios-plugins-2.1.3:
https://nagios-plugins.org/download/nagios-plugins-2.1.3.tar.gz
NRPE-3.0.1:
https://codeload.github.com/NagiosEnterprises/nrpe/tar.gz/3.0.1
官方安装文档:Nagios QuickstartInstallation Guides
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart.html
# yum install httpd php gcc glibc glibc-common gd gd-devel # yum install unzip //编译所需,否则会报错。 # useradd -M -s /sbin/nologin nagios # usermod -aG nagios apache # tar zxvf nagios-4.2.1.tar.gz # cd nagios-4.2.1/ # make all # make install # make install-init # make install-config # make install-commandmode # make install-webconf # vim /usr/local/nagios/etc/objects/contacts.cfg email xxx@xxx.com //修改nagios警告信息的邮件地址 # htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios //配置登录账号和密码
2、安装nagios-plugins插件
# tar zxvfnagios-plugins-2.1.3.tar.gz
# cd nagios-plugins-2.1.3/
# ./configure--with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
# chown -R nagios.nagios/usr/local/nagios/
# systemctl enable httpd
# systemctl start httpd
# systemctl enable nagios
# systemctl start nagios
# /etc/init.d/nagios checkconfig //检查nagios配置文件是否有错误,或使用以下命令检查:
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# firewall-cmd --zone=public --add-service=http –permanent
# firewall-cmd –reload
# systemctl restart firewalld
使用http://10.100.2.158/nagios登录控制台,输入配置的账号密码即可登录。
注:如果web管理员不是使用默认的nagiosadmin,需要修改cgi.cfg
# vim /usr/local/nagios/etc/cgi.cfg
//把所有的nagiosadmin改为自定义的用户名,否则查看Services时会提示权限不够。
默认HTTP会有告警信息,解决办法:在/var/www/html目录新建一个空白index.html文件即可。
# touch /var/www/html/index.html
重启nagios和httpd服务,等待几分钟即恢复正常。
3、安装NRPE插件
# tar zxvf nrpe-3.0.1.tar.gz
# cd nrpe-3.0.1/
# yum install openssl-devel
//解决checking for SSL headers... configure: error: Cannotfind ssl headers错误问题
# ./configure--with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios--with-nagios-group=nagios --enable-command-args --enable-ssl
# make all //编译和安装nrpe
# make install-plugin
# make install-daemon
# make install-config //注:nrpe3.0以下请使用# make install-daemon-config
待编辑.....
三、安装Cacti
四、集成Nagios和Cacti
RHEL7.2安装Nagios4.2.1+Cacti0.8.8h