大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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

创新互联公司专注于吉隆企业网站建设,响应式网站建设,商城开发。吉隆网站建设公司,为吉隆等地区提供建站服务。全流程按需制作,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务

 

  1. ###### define hosts ################################### 
  2. define host { 
  3.         host_name               cancer-ts4 
  4.         address                 172.16.5.4 
  5.         check_command           check-host-alive 
  6.         check_interval          5 
  7.         max_check_attempts      2 
  8.         contact_groups          admins 
  9.  
  10. define host { 
  11.         host_name               cancer-ts11 
  12.         address                 172.16.5.11 
  13.         check_command           check-host-alive 
  14.         check_interval          5 
  15.         max_check_attempts      2 
  16.         contact_groups          admins 
  17.  
  18. define host { 
  19.         host_name               cancer-ts12 
  20.         address                 172.16.5.12 
  21.         check_command           check-host-alive 
  22.         check_interval          5 
  23.         max_check_attempts      2 
  24.         contact_groups          admins 
  25.  
  26. define host { 
  27.         host_name               cancer-hz4 
  28.         address                 172.16.3.4 
  29.         check_command           check-host-alive 
  30.         check_interval          5 
  31.         max_check_attempts      2 
  32.         contact_groups          admins 
  33.  
  34. define host { 
  35.         host_name               cancer-hz5 
  36.         address                 172.16.3.5 
  37.         check_command           check-host-alive 
  38.         check_interval          5 
  39.         max_check_attempts      2 
  40.         contact_groups          admins 
  41.  
  42. define host { 
  43.         host_name               cancer-hz12 
  44.         address                 172.16.3.12 
  45.         check_command           check-host-alive 
  46.         check_interval          5 
  47.         max_check_attempts      2 
  48.         contact_groups          admins 
  49.  
  50. define host { 
  51.         host_name               cancer-hz13 
  52.         address                 172.16.3.13 
  53.         check_command           check-host-alive 
  54.         check_interval          1 
  55.         max_check_attempts      2 
  56.         contact_groups          admins 
  57.  
  58. ######## define service ###################### 
  59. define service{ 
  60.         host_name                       cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13 
  61.         service_description             Users 
  62.         check_period                    24x7 
  63.         normal_check_interval           5 
  64.         retry_check_interval            2 
  65.         max_check_attempts              5  
  66.         notification_period             24x7 
  67.         contact_groups                  admins 
  68.         check_command                   check_nrpe!check_users  
  69.         } 
  70. define service{ 
  71.         host_name                       cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13 
  72.         service_description             Load 
  73.         check_period                    24x7 
  74.         normal_check_interval           5 
  75.         retry_check_interval            2 
  76.         max_check_attempts              5 
  77.         notification_period             24x7  
  78.         contact_groups                  admins 
  79.         check_command                   check_nrpe!check_load  
  80.         } 
  81. define service{ 
  82.         host_name                       cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13 
  83.         service_description             disk 
  84.         check_period                    24x7 
  85.         normal_check_interval           5 
  86.         retry_check_interval            2 
  87.         max_check_attempts              5 
  88.         notification_period             24x7  
  89.         contact_groups                  admins 
  90.         check_command                   check_nrpe!check_hda1  
  91.         } 
  92.  
  93. define service{ 
  94.         host_name                       cancer-ts11,cancer-ts12,cancer-ts4,cancer-hz4,cancer-hz5,cancer-hz13,cancer-hz12 
  95.         service_description             nginx 
  96.         check_period                    24x7 
  97.         normal_check_interval           5 
  98.         retry_check_interval            2 
  99.         max_check_attempts              5 
  100.         notification_period             24x7  
  101.         contact_groups                  admins 
  102.         check_command                   check_nrpe!check_nginx 
  103.         } 

并把www.cfg添加到nagios主配置项
# echo “cfg_file=/etc/nagios/objects/www.cfg” >> /etc/nagios/nagios.cfg
其他机器如法炮制即可


文章名称:yum安装nagios(centos6.2)
当前网址:http://dzwzjz.com/article/iespjd.html
在线咨询
服务热线
服务热线:028-86922220
TOP