2.2 nagios 監控用戶端

來源:互聯網
上載者:User

標籤:監控   nagios   用戶端   

           配置用戶端

           安裝 epel 擴充源

[[email protected] ~]# yum install -y epel-release

           安裝 nagios 以及 nagios-plugins

[[email protected] ~]# yum install -y nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe

           編輯設定檔

[[email protected] ~]# vim /etc/nagios/nrpe.cfg

           找到“allowed_hosts=127.0.0.1”改為“allowed_hosts=127.0.0.1,192.168.56.133”後面的ip為服務端ip

           找到“dont_blame_nrpe=0”改為“dont_blame_nrpe=1”

allowed_hosts=127.0.0.1,192.168.56.133dont_blame_nrpe=1

           啟動用戶端

[[email protected] ~]# /etc/init.d/nrpe startStarting nrpe:                                             [確定]

          

           服務端配置:(!!!服務端操作)

           用戶端ip為192.168.56.128,下面定義子設定檔。

[[email protected] ~]# cd /etc/nagios/conf.d/[[email protected] conf.d]# vim 192.168.56.128.cfgdefine host{   use            linux-server   host_name      192.168.56.128   alias          56.128   address        192.168.56.128}define service{   use            generic-service   host_name      192.168.56.128   service_description   check_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.56.128   service_description   check_ssh   check_command   check_ssh   max_check_attempts  5   normal_check_interval  1   notification_interval  60}define service{   use            generic-service   host_name      192.168.56.128   service_description   check_http   check_command     check_http   max_check_attempts   5   normal_check_interval  1}

        說明:“max_check_attempts 5”表示,當nagios檢測到問題時,一共嘗試檢測5次都有問題才會警示,如果該數值為1,那麼檢測到問題就立即警示。“normal_check_interval 1”表示,重新檢測的時間間隔,單位是分鐘,預設是3分鐘。“notification_interval 60”表示,在服務出現異常後,故障一直沒有解決,nagios再次對使用者發出通知的時間,單位是分鐘。如果認為所有的事件只需要一次通知就夠了,可以把這裡的選項設為0。

        

       以上服務不依賴用戶端nrpe服務,比如我們在自己電腦上可以使用ping或者telnet探測遠程任何一台機器是否存活、是否開啟某個連接埠或服務。而當檢測用戶端上的某個具體服務的情況時,就需要藉助於nrpe了,比如想知道用戶端機器的負載或磁碟使用方式。

       編輯完設定檔後,在服務端重啟一下nagios服務。

[[email protected] conf.d]# service nagios restartRunning configuration check...done.Stopping nagios: .done.Starting nagios: done.

       然後在瀏覽器中訪問nagios,重新整理會多出來一個主機,並且多出來三個服務。

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/83/B1/wKiom1d6Wq3gKEFoAAEKqm_cKEI365.png" title="2.2-1.PNG" alt="wKiom1d6Wq3gKEFoAAEKqm_cKEI365.png" />


       只不過這三個服務並不是我們想要的,我想要監控負載和磁碟使用率等服務,這時候就要使用nrpe服務了。繼續在服務端添加服務。

      (!!!服務端操作)

       編輯設定檔

[[email protected] ~]# vim /etc/nagios/objects/commands.cfg

      增加:

define command{        command_name   check_nrpe        command_line   $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$}

        繼續編輯

[[email protected] ~]# vim /etc/nagios/conf.d/192.168.56.128.cfgdefine service{   use            generic-service   host_name      192.168.56.128   service_description  check_load   check_command    check_nrpe!check_load   max_check_attempts   5   normal_check_interval   1}define service{   use            generic-service   host_name      192.168.56.128   service_description  check_disk_hda1   check_command    check_nrpe!check_hda1   max_check_attempts  5   normal_check_interval  1}define service{   use            generic-service   host_name      192.168.56.128   service_description check_disk_hda2   check_command   check_nrpe!check_hda2   max_check_attempts  5   normal_check_interval  1}


        說明:“check_nrpe!check_load”這裡的check_nrpe就是在commands.cfg剛剛定義的,check_load是遠程主機上的一個檢測指令碼。

        (!!!以下用戶端操作)

        在遠程主機上編輯 nrpe.cfg 設定檔

[[email protected] ~]# vim /etc/nagios/nrpe.cfg

        找到 check_load 這一行,這行就是在用戶端上要執行的指令碼。然後把 check_hda1 更改一下:/dev/hda1 改為 /dev/sda1。再加一行檢測sda2的語句。

command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1command[check_hda2]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda2

         用戶端重啟 nrpe 服務

[[email protected] ~]# service nrpe restartShutting down nrpe:                                        [確定]Starting nrpe:                                             [確定]

         服務端重啟 nagios 服務

[[email protected] ~]# service nagios restartRunning configuration check...done.Stopping nagios: done.Starting nagios: done.

         瀏覽器重新整理,又有三個服務出來,稍等一會兒就能看到狀態了。

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M00/83/B0/wKioL1d6WtySI3HNAAFIuWhtdfI611.png" style="float:none;" title="2.2-2.PNG" alt="wKioL1d6WtySI3HNAAFIuWhtdfI611.png" />

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M00/83/B1/wKiom1d6WtyAaQnEAAFUd0j5tgE245.png" style="float:none;" title="2.2-3.PNG" alt="wKiom1d6WtyAaQnEAAFUd0j5tgE245.png" />



本文出自 “散宜生的學習筆記” 部落格,請務必保留此出處http://sanyisheng.blog.51cto.com/11154168/1795723

2.2 nagios 監控用戶端

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.