您的位置:首页 > 移动开发 > IOS开发

nagios系列-----通过yum安装Nagios

2014-04-05 20:59 585 查看
通过yum安装Nagios前提先自行安装好Apache+php测试环境
主监控机:CentOS 6.0
被监控机:CentOS 6.2主监控机设置:
1、安装epel
# cat /etc/issue
CentOS release 6.0 (Final)
Kernel \r on an \m# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm 这里应该对应你服务器的版本
2、安装nagios、nagios-plugin与nrpe (nagios 3.3.1版本)
# yum install nagios nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe3、创建一个nagiosadmin 的用户用于Nagios的WEB接口登录,用户认证配置adduser nagiosadmincd /usr/local/mkdir nagioscd nagiosmkdir etc
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin4、修改nagios.conf
修改保存用户密码文件vi /etc/httpd/conf.d/nagios.conf
AuthUserFile /etc/nagios/passwd 修改成–> AuthUserFile /etc/nagios/htpasswd.users
保存退出5、修改cgi.cfg文件,找到use_authentication=1 这行,把1改成0 find -name cgi.cfg -print 查找vi /etc/nagios/cgi.cfg6、启动apache与nagios
# /etc/init.d/httpd restart
# /etc/init.d/nagios start7、登陆http://localhost/nagios/,输入用户密码后查看是否正常运行
注:别忘记了nagios后面那个/,不然……被监控机设置:
1、安装需要软件
# yum install nagios-plugins nagios-plugins-nrpe nrpe2、配置nrpe
# vi /etc/nagios/nrpe.cfg 修改监控机的地址或域名
allowed_hosts=127.0.0.1,192.168.5.113、修改/etc/hosts.allow增加监控机ip
# echo ‘nrpe:192.168.5.22′ >> /etc/hosts.allow4、检查 NRPE 是否正常:
# /usr/lib/nagios/plugins/check_nrpe -H 192.168.5.11
NRPE v2.12
查看相应的端口:netstat -an |grep 5666
防火墙开启5666 允许局域网IP或固定IP连接5、启动 NRPE 守护进程:
# /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d在回到监控机:
添加nrpe的定义
# vi commands.cfg
# ‘check_nrpe’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}增加主机监控配置项11.cfg
define host{
use linux-server
host_name 192.168.5.11
alias 192.168.5.11
address 192.168.5.11
}
define service{
use generic-service
host_name 192.168.5.11
service_description load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name 192.168.5.11
service_description PING
check_command check_ping!100.0,20%!200.0,50%
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name 192.168.5.11
service_description FTP
check_command check_ftp!21
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name 192.168.5.11
service_description SSH
check_command check_ssh
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name 192.168.5.11
service_description HTTP
check_command check_http
max_check_attempts 5
normal_check_interval 1
}并把11.cfg添加到nagios主配置项
# echo “cfg_file=/etc/nagios/objects/11.cfg” >> /etc/nagios/nagios.cfg
其他机器如法炮制即可重启监控机nagios查看效果,关于短信通知参考另外一篇文章http://hi.baidu.com/yuanzelin8/blog/item/3b0bf2161010e771f2de3278.html#Linux
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  服务器 监控 接口