溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

yum安裝nagios(centos 6.2)

發(fā)布時(shí)間:2020-06-17 20:39:15 來(lái)源:網(wǎng)絡(luò) 閱讀:2130 作者:zhhmj 欄目:移動(dòng)開(kāi)發(fā)

前提先自行安裝好Apache+php
測(cè)試環(huán)境
主監(jiān)控機(jī):CentOS 6.2  172.16.1.8
被監(jiān)控機(jī):CentOS 6.2  172.16.5.11
主監(jiān)控機(jī)設(shè)置:
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                         這里應(yīng)該對(duì)應(yīng)你服務(wù)器的版本
2、安裝nagios、nagios-plugin與nrpe (nagios 3.3.1版本)
# yum install nagios nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe
3、創(chuàng)建一個(gè)nagiosadmin 的用戶(hù)用于Nagios的WEB接口登錄,用戶(hù)認(rèn)證配置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、啟動(dòng)apache與nagios
# /etc/init.d/httpd restart
# /etc/init.d/nagios start
6、登陸http://localhost/nagios/,輸入用戶(hù)密碼后查看是否正常運(yùn)行
注:別忘記了nagios后面那個(gè)/
被監(jiān)控機(jī)設(shè)置:
1、安裝需要軟件
# yum install nagios-plugins nagios-plugins-nrpe nrpe
2、配置nrpe
# vi /etc/nagios/nrpe.cfg 修改監(jiān)控機(jī)的地址或域名
allowed_hosts=127.0.0.1,192.168.1.8
3、修改/etc/hosts.allow增加監(jiān)控機(jī)ip
# echo ‘nrpe:192.168.1.8′ >> /etc/hosts.allow
4、檢查 NRPE 是否正常:
監(jiān)控機(jī)上:
# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.5.11
NRPE v2.12
查看相應(yīng)的端口:netstat -an |grep 5666
防火墻開(kāi)啟5666 允許局域網(wǎng)IP或固定IP連接
5、啟動(dòng) NRPE 守護(hù)進(jìn)程:
# /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg –d     或者
#/etc/init.d/nrpe start
6、關(guān)閉selinux:
#setenforce 0
在回到監(jiān)控機(jī):
添加nrpe的定義
# vi commands.cfg
# ‘check_nrpe’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
增加主機(jī)監(jiān)控配置項(xiàng)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主配置項(xiàng)
# echo “cfg_file=/etc/nagios/objects/www.cfg” >> /etc/nagios/nagios.cfg
其他機(jī)器如法炮制即可

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI