由于公司系统监控(IPMoniter)和网络流量监控(MRTG)分别由不同的软件监控且由几台服务器完成,近期想整合到一起,并改为开源免费的Nagios和Cacti完成。以下为部署日志。
一、安装RHEL7.2
最小化安装,配置IP,时间同步,本地yum源,安装vim(个人习惯)、bash-completion(命令补齐)
1
2
3
4
5
6
7
8
9
| # 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源
二、安装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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| # 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
注:如果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
|