nagios 監控配置介紹(一)

來源:互聯網
上載者:User

標籤:nagios

Nagios是一款開源的免費網路監視工具,能有效監控Windows、Linux和Unix的主機狀態,交換器路由器等網路設定,印表機等。

在系統或服務狀態異常時發出郵件或簡訊警示第一時間通知網站營運人員,在狀態恢複後發出正常的郵件或簡訊通知。

作為老牌的監視軟體,大家應該學習,本文介紹使用配置的方法。


650) this.width=650;" src="http://s5.51cto.com/wyfs02/M00/8B/E4/wKiom1hbkbmQyEv3AAJOnCZZW2A007.jpg-wh_500x0-wm_3-wmp_4-s_2141536964.jpg" title="nagios 監控" alt="wKiom1hbkbmQyEv3AAJOnCZZW2A007.jpg-wh_50" />

監控服務端和用戶端安裝省略。


#準備階段

                                 資訊列表

                伺服器名稱              伺服器IP
             nagios server 10.89.1.2
              samba 10.89.1.3
              web-lnmp 10.89.1.34


#1.nagios的監控模式定義及監控模式的選擇

1.1.主動模式,由nagios伺服器端發出的請求主動探測就可以得到資料的監控模式,也就是說不需要再

  用戶端安裝任何外掛程式(適合對 連接埠 URL http ssh mysql rsync等監控)。當然主動模式也可以配置為被動模式探測


1.2.半被動模式,我們把負載,記憶體,硬碟,虛擬記憶體,磁碟IO,溫度,風扇等

對於這些本地資源效能的監控,一般使用半被動模式(通過調用nrpe,snmp)


1.3.被動模式


主動模式:和nrpe無關了,就是利用服務端本地外掛程式直擷取資訊

被動模式:主程式通過check_nrpe外掛程式,和用戶端nrpe進程溝通,調用本地外掛程式擷取資料


#2.佈建服務端

[[email protected] tools]# ll /usr/local/nagios/

total 32

drwxrwxr-x  2 nagios nagios 4096 Jul 14 23:25 bin            #命令的目錄

drwxrwxr-x  3 nagios nagios 4096 Jul 14 23:25 etc            #設定檔的目錄

drwxr-xr-x  2 root   root   4096 Jul 14 23:24 include

drwxrwxr-x  2 nagios nagios 4096 Jul 14 23:25 libexec        #外掛程式

drwxr-xr-x  5 root   root   4096 Jul 14 23:24 perl

drwxrwxr-x  2 nagios nagios 4096 Jul 14 23:21 sbin           #cgi 的程式

drwxrwxr-x 11 nagios nagios 4096 Jul 14 23:24 share          #web程式,nagios介面展示的php程式

drwxrwxr-x  5 nagios nagios 4096 Jul 16 10:03 var            #日誌和資料


[[email protected] tools]# cd /usr/local/nagios/etc

[[email protected] etc]# ls -l

total 76

-rw-rw-r-- 1 nagios nagios 11669 Jul 14 23:21 cgi.cfg

-rw-r--r-- 1 root   root      21 Jul 14 23:22 htpasswd.users  #密碼驗證檔案

-rw-rw-r-- 1 nagios nagios 44710 Jul 14 23:21 nagios.cfg      #nagios主設定檔

-rw-r--r-- 1 nagios nagios  7207 Jul 14 23:25 nrpe.cfg

drwxrwxr-x 2 nagios nagios  4096 Jul 14 23:21 objects

-rw-rw---- 1 nagios nagios  1340 Jul 14 23:21 resource.cfg


#產生hosts.cfg檔案

[[email protected] etc]# cd objects/

[[email protected] objects]# head -51 localhost.cfg >hosts.cfg

[[email protected] objects]# chown nagios.nagios /usr/local/nagios/etc/objects/hosts.cfg 


#產生 services.cfg檔案

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

[[email protected] objects]# chown nagios.nagios /usr/local/nagios/etc/objects/services.cfg 

[[email protected] objects]# ll

total 52

-rw-rw-r-- 1 nagios nagios  7716 Jul 14 23:21 commands.cfg      #存放nagios 命令相關配置,實現nagios命令和linux系統命令關聯

-rw-rw-r-- 1 nagios nagios  2166 Jul 14 23:21 contacts.cfg      #存放警示連絡人的相關設定檔

-rw-r--r-- 1 nagios nagios  1870 Jul 16 12:00 hosts.cfg         #新增,存放具體被監控主機相關配置

-rw-rw-r-- 1 nagios nagios  5403 Jul 14 23:21 localhost.cfg

-rw-rw-r-- 1 nagios nagios  3124 Jul 14 23:21 printer.cfg

-rw-r--r-- 1 nagios nagios     0 Jul 16 12:03 services.cfg      #新增,存放具體被監控服務相關配置

-rw-rw-r-- 1 nagios nagios  3293 Jul 14 23:21 switch.cfg

-rw-rw-r-- 1 nagios nagios 10812 Jul 14 23:21 templates.cfg     #模板設定檔

-rw-rw-r-- 1 nagios nagios  3208 Jul 14 23:21 timeperiods.cfg   #存放警示周期時間等相關配置

-rw-rw-r-- 1 nagios nagios  4019 Jul 14 23:21 windows.cfg



#修改 nagios.cfg 檔案前,備份/etc 目錄防止改錯

[[email protected] etc]# cd ..

[[email protected] nagios]# tar zcvf etc.tar.gz ./etc/

./etc/

./etc/nagios.cfg

./etc/cgi.cfg

./etc/nrpe.cfg

./etc/htpasswd.users

./etc/objects/

./etc/objects/printer.cfg

./etc/objects/localhost.cfg

./etc/objects/contacts.cfg

./etc/objects/windows.cfg

./etc/objects/timeperiods.cfg

./etc/objects/switch.cfg

./etc/objects/commands.cfg

./etc/objects/templates.cfg

./etc/resource.cfg

[[email protected] nagios]# cd etc

[[email protected] etc]# vi nagios.cfg +34


#添加3行,注釋1行

    # You can specify individual object config files as shown below:

      cfg_file=/usr/local/nagios/etc/objects/commands.cfg

      cfg_file=/usr/local/nagios/etc/objects/contacts.cfg

      cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg

      cfg_file=/usr/local/nagios/etc/objects/templates.cfg

#添加這2行

      cfg_file=/usr/local/nagios/etc/objects/services.cfg    

      cfg_file=/usr/local/nagios/etc/objects/hosts.cfg

#注釋1行,這是本機監控

     #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

           

# directive as shown below:

#添加1行(主動式監控使用)

     cfg_dir=/usr/local/nagios/etc/services  #添加services(服務)目錄包含


    #cfg_dir=/usr/local/nagios/etc/servers  #伺服器

    #cfg_dir=/usr/local/nagios/etc/printers #印表機

    #cfg_dir=/usr/local/nagios/etc/switches #交換器

    #cfg_dir=/usr/local/nagios/etc/routers  #路由器

#建立services目錄 並授權

[[email protected] etc]#cd /usr/local/nagios/etc

[[email protected] etc]# mkdir services

[[email protected] etc]# chown -R nagios.nagios services/


[[email protected] etc]# ll

total 80

-rw-rw-r-- 1 nagios nagios 11669 Jul 14 23:21 cgi.cfg

-rw-r--r-- 1 root   root      21 Jul 14 23:22 htpasswd.users

-rw-rw-r-- 1 nagios nagios 44852 Jul 16 11:55 nagios.cfg

-rw-r--r-- 1 nagios nagios  7207 Jul 14 23:25 nrpe.cfg

drwxrwxr-x 2 nagios nagios  4096 Jul 16 12:03 objects

-rw-rw---- 1 nagios nagios  1340 Jul 14 23:21 resource.cfg

drwxr-xr-x 2 nagios nagios  4096 Jul 16 11:56 services          #新增,存放主動式監控項目 


--------------------------------------------------------------------------------------


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

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.