bestlong 怕失憶論壇

 

 

搜索
bestlong 怕失憶論壇 論壇 MIS Nagios 安裝設定與問題排除
查看: 10032|回復: 3
go

Nagios 安裝設定與問題排除 [複製鏈接]

Rank: 9Rank: 9Rank: 9

1#
發表於 2006-10-15 22:19 |只看該作者 |倒序瀏覽 |打印
官網:http://www.nagios.org/
Nagios 是開放原始碼的監視程式,可用來監視伺服器、服務與網路。

在 FC4 用 yum install nagios 後
檢視 /etc/httpd/conf.d/nagios.conf
  1. ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi-bin/
  2. <Directory /usr/lib/nagios/cgi-bin/>
  3.    Options ExecCGI
  4.    order deny,allow
  5.    deny from all
  6.    allow from 127.0.0.1 192.168
  7.    AuthType Basic
  8.    AuthUserFile /etc/nagios/passwd
  9.    AuthName "nagios"
  10.    require valid-user
  11. </Directory>

  12. Alias /nagios/ /usr/share/nagios/html/
  13. <Directory /usr/share/nagios/html/>
  14.    Options None
  15.    order deny,allow
  16.    deny from all
  17.    allow from 127.0.0.1 192.168
  18.    AuthType Basic
  19.    AuthUserFile /etc/nagios/passwd
  20.    AuthName "nagios"
  21.    require valid-user
  22. </Directory>
複製代碼
依照上列設定內容知道密碼檔路徑與登入帳戶名稱,來建立 Apache 網頁認證用密碼檔
  1. [root@www nagios]# htpasswd -c /etc/nagios/passwd nagios
  2. New password:
  3. Re-type new password:
  4. Adding password for user nagios
  5. [root@www nagios]#
複製代碼
到 /etc/nagios 目錄下將所有 *.cfg-sample 都複製或改名為 *.cfg
然後檢測 nagios.cfg 設定
  1. [root@www nagios]# nagios -v /etc/nagios/nagios.cfg

  2. Nagios 2.5
  3. Copyright (c) 1999-2006 Ethan Galstad (http://www.nagios.org)
  4. Last Modified: 07-13-2006
  5. License: GPL

  6. Reading configuration data...

  7. Error: Command 'check-host-alive' has already been defined
  8. Error: Could not register command (config file '/etc/nagios/minimal.cfg', starting on line 76)
複製代碼
從訊息中知道 check-host-alive 被重複定義了,執行 grep -n -i check-host-alive * 列出了
  1. bigger.cfg:177: check_command           check-host-alive
  2. bigger.cfg:194: check_command           check-host-alive
  3. bigger.cfg:211: check_command           check-host-alive
  4. bigger.cfg:228: check_command           check-host-alive
  5. bigger.cfg:245: check_command           check-host-alive
  6. bigger.cfg:263: check_command           check-host-alive
  7. bigger.cfg:280: check_command           check-host-alive
  8. bigger.cfg:297: check_command           check-host-alive
  9. bigger.cfg:314: check_command           check-host-alive
  10. bigger.cfg:331: check_command           check-host-alive
  11. bigger.cfg:348: check_command           check-host-alive
  12. bigger.cfg:365: check_command           check-host-alive
  13. bigger.cfg:382: check_command           check-host-alive
  14. bigger.cfg:398: check_command           check-host-alive
  15. bigger.cfg:414: check_command           check-host-alive
  16. checkcommands.cfg:169:# 'check-host-alive' command definition
  17. checkcommands.cfg:171:        command_name    check-host-alive
  18. minimal.cfg:77:        command_name    check-host-alive
  19. minimal.cfg:200:        check_command           check-host-alive
複製代碼
因為 /etc/nagios/nagios.cfg 所引入的 cfg_file 是先 checkcommands.cfg 然後是 minimal.cfg 設定檔。剛好兩個檔案中都有定義 check-host-alive 的部分。列出相關片段:
  1. ### checkcommands.cfg 部分 ###
  2. # Command to check to see if a host is "alive" (up) by pinging it
  3. define command{
  4.         command_name    check-host-alive
  5.         command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 99,99% -c 100,100% -p 1
  6.         }
複製代碼
  1. ### minimal.cfg 部分 ###
  2. # 'check-host-alive' command definition
  3. define command{
  4.         command_name    check-host-alive
  5.         command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 1
  6.         }
複製代碼
因為在 checkcommands.cfg 是獨立的設定,目前先用 # 註解掉該部分再檢查就排除此錯誤訊息。
不過卻又冒出不同錯誤:
  1. [root@www nagios]# nagios -v /etc/nagios/nagios.cfg

  2. Nagios 2.5
  3. Copyright (c) 1999-2006 Ethan Galstad (http://www.nagios.org)
  4. Last Modified: 07-13-2006
  5. License: GPL

  6. Reading configuration data...

  7. Error: Command 'check_local_disk' has already been defined
  8. Error: Could not register command (config file '/etc/nagios/minimal.cfg', starting on line 92)
複製代碼
很熟悉的狀況吧,也是先用同樣去註解的方式解決。不過後續也是一堆類似的問題,覺得這樣的解決問題不對,先復原所有修改並回到原點 nagios.cfg 設定檔檢查。乾脆將下列兩個項目註解掉試試看:
  1. cfg_file=/etc/nagios/checkcommands.cfg
  2. cfg_file=/etc/nagios/misccommands.cfg
複製代碼
果然,檢測 nagios.cfg 設定通過
  1. [root@www nagios]# nagios -v /etc/nagios/nagios.cfg

  2. Nagios 2.5
  3. Copyright (c) 1999-2006 Ethan Galstad (http://www.nagios.org)
  4. Last Modified: 07-13-2006
  5. License: GPL

  6. Reading configuration data...

  7. Running pre-flight check on configuration data...

  8. Checking services...
  9.         Checked 5 services.
  10. Checking hosts...
  11.         Checked 1 hosts.
  12. Checking host groups...
  13.         Checked 1 host groups.
  14. Checking service groups...
  15.         Checked 0 service groups.
  16. Checking contacts...
  17.         Checked 1 contacts.
  18. Checking contact groups...
  19.         Checked 1 contact groups.
  20. Checking service escalations...
  21.         Checked 0 service escalations.
  22. Checking service dependencies...
  23.         Checked 0 service dependencies.
  24. Checking host escalations...
  25.         Checked 0 host escalations.
  26. Checking host dependencies...
  27.         Checked 0 host dependencies.
  28. Checking commands...
  29.         Checked 8 commands.
  30. Checking time periods...
  31.         Checked 1 time periods.
  32. Checking extended host info definitions...
  33.         Checked 0 extended host info definitions.
  34. Checking extended service info definitions...
  35.         Checked 0 extended service info definitions.
  36. Checking for circular paths between hosts...
  37. Checking for circular host and service dependencies...
  38. Checking global event handlers...
  39. Checking obsessive compulsive processor commands...
  40. Checking misc settings...

  41. Total Warnings: 0
  42. Total Errors:   0

  43. Things look okay - No serious problems were detected during the pre-flight check
  44. [root@www nagios]#
複製代碼
試著啟動服務也 OK 了
  1. [root@www nagios]# /etc/init.d/nagios start
  2. Starting network monitor: nagios
  3. [root@www nagios]#
複製代碼
不過這樣僅僅是可以啟動服務而已,還需要針對需要監視的伺服器、服務或網路進行設定。
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw

Rank: 9Rank: 9Rank: 9

2#
發表於 2009-10-6 10:35 |只看該作者
若網頁畫面中出現下列訊息:

It appears as though you do not have permission to view information for any of the services 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 設定將 use_authentication=1 改成 use_authentication=0 
就可以看到資料了,不過可能會有網站安全性的問題。
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw

Rank: 9Rank: 9Rank: 9

3#
發表於 2009-10-7 09:59 |只看該作者
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw

Rank: 9Rank: 9Rank: 9

4#
發表於 2011-6-23 09:42 |只看該作者
在 Fedora 13 環境用 yum 安裝 Nagios 3.2.3

登入 root 權限後執行下列幾行指令

# yum install nagios nagios-plugins-all
# service nagios start
# service httpd restart

這樣就安裝好了,不過要趕快修改登入密碼,因為是使用 http 認證所以請先確認 /etc/httpd/conf.d/nagios.conf 設定檔中的 AuthUserFile 屬性所指定的密碼檔位置,例如:

AuthUserFile /etc/nagios/passwd

這樣就可以用 htpasswd 指令來修改密碼,若是 AuthUserFile 所指定的檔案不存在請用下列指令來修改密碼

# htpasswd -c /etc/nagios/passwd nagiosadmin

若是密碼檔已存在就使用下列指令來修改密碼

# htpasswd /etc/nagios/passwd nagiosadmin

這樣就可以開啟瀏覽器到 http://your.host.name/nagios 登入系統
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw
‹ 上一主題|下一主題

Archiver|怕失憶論壇

GMT+8, 2024-4-23 23:02 , Processed in 0.026691 second(s), 10 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.