任务二、Nagios-server的安装
2.1、创建Nagios用户和组
注:
#useradd Nagios -s /bin/nologin
#groundadd nagcmd
#usermod -a -G nagcmd Nagios
#usermod -a G nagcmd apache
2.2、安装Nagios
2.2.1、上传软件包至操作系统中;
2.2.2、解压软件并进入至文件夹中;
注:
#cd /root/software
#tar zxvf Nagios-4.3.1.tar.gz
#cd Nagios-4.3.1
2.2.3、配置源码;
注:
#cd Nagios-4.3.1
#./configure –with-command-group=nagcmd
2.2.4、编译安装;
注:
#cd Nagios-4.3.1
#make all
#make install
#make install-init
#make install-config
#make install-commandmode
#make install-webconf
#目录核对正确表示安装成功
2.3、安装邮件服务
2.3.1、安装服务
2.3.2、启动服务
2.3.3、发送测试邮件(输入完成后Ctrl+D退出并发送)
2.3.4、指定接收警告信息的邮件地址
2.4、修改web界面登录验证信息
2.4.1、修改登录验证信息
2.4.2、修改nagios用户权限(因为默认用户为nagiosadmin)配置完成需重启http服务
#sed -i ‘s#nagiosadmin#nagios#g’ /usr/local/Nagios/etc/cgi.cfg
2.4.3、检测主配置文件是否有语法错误
#/usr/local/Nagios/bin/Nagios/ -v /usr/local/Nagios/etc/Nagios.cfg
2.5、安装Nagios插件
#tar zxvf Nagios-plugins-2.2.1.tar.gz
#cd Nagios-plugins-2.2.1
#配置
#./configure –with-nagios-user=Nagios –with-nagios-group=nagcmd
#编译并安装
#make && make install
#查看已安装的插件数量
#ls /usr/local/Nagios/libexec/| wc -l
2.6、启动验证服务
2.6.1、启动服务
注:
#chkconfig –add Nagios
#chkconfig Nagios on
#/usr/local/Nagios/bin/Nagios -v /usr/local/Nagios/etc/Nagios.cfg
2.6.2、关闭防火墙
2.6.3、添加防火墙规则并重启防火墙
#firewall-cmd –add-service=http
#firewall-cmd –permanent –add-service=http
2.6.4、重启Nagios服务,并打开web页面验证:192.168.159.140:/Nagios
注:
#/usr/local/Nagios/bin/Nagios -d /usr/local/Nagios/etc/Nagios.cfg
2.6.5、查看本机的监视信息
2.6.6、查看本机的服务信息(期中有一条warning信息)
2.7、安装nrpe
#tar xzvf nrpe-3.2.1.tar.gz
#cd nrpe-3.2.1
#./configure –with-nrpe-user=Nagios \
--with-nrpe-group=Nagios \
--with-nagios-user=Nagios \
--with-nagios-group=Nagios \
--enable-command-args \
--enable-ssl
#make all
#make install-plugin
#make install-daemon
#make install-daemon-config
#检查/usr/local/Nagios/libexec目录下是否已经安装了check_nrpe插件