yum安装nagios(centos6.2)
前提先自行安装好Apache+php
测试环境
主监控机:CentOS 6.2 172.16.1.8
被监控机:CentOS 6.2 172.16.5.11
主监控机设置:
1、安装epel
# cat /etc/issue
CentOS release 6.2 (Final)
Kernel \r on an \m
# rpm -ivh rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/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 nrpe
3、创建一个nagiosadmin 的用户用于Nagios的WEB接口登录,用户认证配置useradd nagiosadmin
# htpasswd -c /etc/nagios/passwd nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
4、修改cgi.cfg文件,找到use_authentication=1 这行,把1改成0
#find -name cgi.cfg -print 查找
#vi /etc/nagios/cgi.cfg
5、启动apache与nagios
# /etc/init.d/httpd restart
# /etc/init.d/nagios start
6、登陆http://localhost/nagios/,输入用户密码后查看是否正常运行
注:别忘记了nagios后面那个/
被监控机设置:
1、安装需要软件
# yum install nagios-plugins nagios-plugins-nrpe nrpe
2、配置nrpe
# vi /etc/nagios/nrpe.cfg 修改监控机的地址或域名
allowed_hosts=127.0.0.1,192.168.1.8
3、修改/etc/hosts.allow增加监控机ip
# echo ‘nrpe:192.168.1.8′ >> /etc/hosts.allow
4、检查 NRPE 是否正常:
监控机上:
# /usr/lib64/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 或者
#/etc/init.d/nrpe start
6、关闭selinux:
#setenforce 0
在回到监控机:
添加nrpe的定义
# vi commands.cfg
# ‘check_nrpe’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
增加主机监控配置项www.cfg
创新互联公司专注于吉隆企业网站建设,响应式网站建设,商城开发。吉隆网站建设公司,为吉隆等地区提供建站服务。全流程按需制作,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务
- ###### define hosts ###################################
- define host {
- host_name cancer-ts4
- address 172.16.5.4
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-ts11
- address 172.16.5.11
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-ts12
- address 172.16.5.12
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-hz4
- address 172.16.3.4
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-hz5
- address 172.16.3.5
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-hz12
- address 172.16.3.12
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-hz13
- address 172.16.3.13
- check_command check-host-alive
- check_interval 1
- max_check_attempts 2
- contact_groups admins
- }
- ######## define service ######################
- define service{
- host_name cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13
- service_description Users
- check_period 24x7
- normal_check_interval 5
- retry_check_interval 2
- max_check_attempts 5
- notification_period 24x7
- contact_groups admins
- check_command check_nrpe!check_users
- }
- define service{
- host_name cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13
- service_description Load
- check_period 24x7
- normal_check_interval 5
- retry_check_interval 2
- max_check_attempts 5
- notification_period 24x7
- contact_groups admins
- check_command check_nrpe!check_load
- }
- define service{
- host_name cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13
- service_description disk
- check_period 24x7
- normal_check_interval 5
- retry_check_interval 2
- max_check_attempts 5
- notification_period 24x7
- contact_groups admins
- check_command check_nrpe!check_hda1
- }
- define service{
- host_name cancer-ts11,cancer-ts12,cancer-ts4,cancer-hz4,cancer-hz5,cancer-hz13,cancer-hz12
- service_description nginx
- check_period 24x7
- normal_check_interval 5
- retry_check_interval 2
- max_check_attempts 5
- notification_period 24x7
- contact_groups admins
- check_command check_nrpe!check_nginx
- }
并把www.cfg添加到nagios主配置项
# echo “cfg_file=/etc/nagios/objects/www.cfg” >> /etc/nagios/nagios.cfg
其他机器如法炮制即可
新闻标题:yum安装nagios(centos6.2)
新闻来源:http://ybzwz.com/article/iespjd.html