nagios 監控配置介紹(二)

來源:互聯網
上載者:User

標籤:nagios

#佈建服務端監控用戶端


[[email protected] etc]# cd objects/


[[email protected] objects]# vi hosts.cfg

# Define a host for the local machine


define host{

        use                     linux-server

        host_name               1.3-samba

        alias                   1.3-samba

        address                 10.89.1.3

        }



define host{

       use                      linux-server

       host_name                1.2-nagios

       alias                    1.2-nagios

       address                  10.89.1.2

       }



define host{

       use                      linux-server

       host_name                1.34-web-lnmp

       alias                    1.34-web-lnmp

       address                  10.89.1.34

       }


define host{

       use                      linux-server

       host_name                1.34-web

       alias                    1.34-web

       address                  10.89.1.34

       }


# Define an optional hostgroup for Linux machines


define hostgroup{

        hostgroup_name  linux-servers ; The name of the hostgroup

        alias           Linux Servers ; Long name of the group

        members         1.3-samba,1.2-nagios,1.34-web-lnmp,1.34-web

        }


儲存退出


檢查文法,先編輯nagios檔案,使出錯資訊顯示出來

[[email protected] objects]# vim /etc/init.d/nagios +183

 $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;   修改為:

 $NagiosBin -v $NagiosCfgFile

儲存退出


檢查文法,如果報錯如下:

[[email protected] objects]# /etc/init.d/nagios checkconfig

Checking services...

Error: There are no services defined!

        Checked 0 services.


解決方案:

[[email protected] objects]# vi services.cfg 


define service {

        use                     generic-service

        host_name               1.3-samba

        service_description     Disk Partition

        check_command           check_nrpe!check_disk



再檢查文法

[[email protected] objects]# /etc/init.d/nagios checkconfig


Total Warnings: 1

Total Errors:   0


Things look okay - No serious problems were detected during the pre-flight check

 OK.

[[email protected] objects]# 


如果報下面錯誤:


Error:Service check command ‘check_nrpe‘ specified in service ‘Disk Partition‘ for

 host ‘10-client01‘ not defined anywhere!

則編輯commands.cfg 檔案:

[[email protected] objects]# vi commands.cfg


再末尾加上


# ‘check_nrpe‘ command definition

define command{

        command_name    check_nrpe

        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

        }


注意:command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ 實際上就是使用這個命令探測:

[[email protected] objects]#/usr/local/nagios/libexec/check_nrpe -H 10.89.1.3 -c check_disk


儲存並退出

再檢查文法

[[email protected] objects]# /etc/init.d/nagios checkconfig


沒有錯誤的情況下:


[[email protected] objects]# /etc/init.d/nagios reload

Running configuration check...done.

Reloading nagios configuration...done

[[email protected] objects]# 


http://10.89.1.2/nagios

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/8B/E0/wKioL1hblIjRr84hAABeqkBD1sI501.jpg-wh_500x0-wm_3-wmp_4-s_3414212499.jpg" title="登入提示" alt="wKioL1hblIjRr84hAABeqkBD1sI501.jpg-wh_50" />



如果登入後提示錯誤:

It appears as though you do not have permission to view information for any of the hosts you requested...



If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI

and check the authorization options in your CGI configuration file.


編輯 cgi.cfg

[[email protected] objects]# cd ../

[[email protected] etc]# vi cgi.cfg


# PHYSICAL HTML PATH

# This is the path where the HTML files for Nagios reside.  This

# value is used to locate the logo images needed by the statusmap

# and statuswrl CGIs.


physical_html_path=/usr/local/nagios/share


:g/nagiosadmin/s//alvin/g           #替換nagiosadmin 為 alvin,該使用者是我安裝的時候添加的


儲存並退出

[[email protected] objects]# /etc/init.d/nagios reload


本文出自 “知識改變命運” 部落格,請務必保留此出處http://ahtornado.blog.51cto.com/4826737/1885155

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.