nagios_install.md
1.78 KB
nagios安装和配置
nagios安装及配置
//------------- 安装nagios及配置 ------------//
// 安装epel-release
yum -y install epel-release
// 产看是否安装了nagios
rpm -qa | grep nagios
// 安装nagios
yum install nagios* nrpe
// 启动服务,设置开机自启
systemctl enable nagios
systemctl start nagios
// 设置nagios后台管理员密码
htpasswd -bc /etc/nagios/passwd nagiosadmin nagiosadmin2jsp
用户名建议使用默认的nagiosadmin,否则需要修改/etc/nagios/cgi.cfg文件,替换nagiosadmin到自定义用户名
//------------- 安装nagios客户端nrpe centos7 -----------//
// 安装epel-release
yum -y install epel-release
// 查看是否安装了nrpe
rpm -qa | grep nrpe
// 安装nrpe和nagions-plugins
yum install nrpe nagios-plugins*
// 服务端,客户端防火墙配置nrpe规则,如下图
firewall-cmd --add-service=my_nrpe --permanent
firewall-cmd --reload
// 客户端配置 /etc/nagios/nrge.cfg,添加allow_hosts,如下图:
// 客户端,服务端启动nrpe服务,开机自启
systemctl enable nrpe
systemctl start nrpe
// 服务端测试是否可以连接客户端nrpe
//------------- 安装nagios客户端nrpe centos6 -----------//
// 安装同上,防火墙配置略 // 启动服务,开机自启 chkconfig --add=nrpe chkconfig nrpe on service nrpe start // 注这里有时候会碰到一个问题,使用service方式启动不起来 // 查看 /var/log/messages 显示创建不了pid文件 // 最后查证是启动脚本的问题 cd /etc/init.d // 修改nrpe启动脚本 将第一行的 #!/bin/sh 改成 #!/bin/bash vi nrpe
//-------------- nrpe的日志配置 -------------//
// 查看nrpe用户对应的目录,/var/run/nrpe
cat /etc/passwd | grep nrpe
// /etc/nagios/nrpe.cfg中配置日志文件,开启debug,如下图: