天天看點

nagios監控故障排除

1、安裝完nagios及nagios-plugins時,卡在這了,forbidden 禁止通路

apache日志顯示如下

Directory index forbidden by Options directive: /usr/local/nagios/share/”

1、apache的配置問題預設頁面是否是index.php,還有是否支援php子產品(ll /etc/httpd/conf.d/php.conf)

2、相應目錄的權限問題 是否可讀

3、是否正确配置的賬戶驗證,

如下示例:

配置http驗證 【配置驗證時注意驗證使用者的名字,建議為nagiosadmin,不然就記得修改cgi.cfg及contact.cfg保持賬号的一緻,不然就會遇到下面的錯誤5.】

兩種方式

第一種方式,在安裝nagios的時候,直接makeinstall –webconf

這個會在/etc/httpd/conf.d/生成一個nagios.conf檔案

<a>htpasswd-c /etc/nagios/htpasswd.users  nagiosadmin</a>

第二種方式

直接自行配置nagios的http驗證,可直接在主配置檔案nagios.conf中添加如下

ScriptAlias/nagios/cgi-bin /usr/local/nagios/sbin

&lt;Directory "/usr/local/nagios/sbin"&gt;

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthType Basic

AuthUserFile/etc/nagios/htpasswd

//用于此目錄通路身份驗證的檔案

Require valid-user

&lt;/Directory&gt;

Alias /nagios/usr/local/nagios/share

&lt;Directory"/usr/local/nagios/share"&gt;

Options None

#//用于此目錄通路身份驗證的檔案

htpasswd-c /etc/nagios/htpasswdnagios

2、The requested URL/nagios/cgi-bin/statusmap.cgi was not found on this server.

<a target="_blank" href="http://blog.51cto.com/attachment/201308/171305326.png"></a>

沒有map圖形,

yuminstall gd-devel -y

重新編譯,

若是源碼安裝gd-devel,需要手動來指明gd-lib的存放,通過yum安裝的不需要,可以自動加載到

./configure --with-gd-lib=/usr/lib  --with-gd-inc=/usr/include

make install; makeinstall-init; make install-config; make install-commandmode; make install-webconf

重新開機nagios服務

3、錯誤:

Error: Service check command'check_nrpe' specified in service 'check_total_procs' for host '192.168.15.183'not defined anywhere!

沒有定義nagios的指令模闆

編輯commands.cfg 添加即可

例:define command {

       command_name  check_nrpe

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

}

4、安裝nrpe,編譯的時候提示以下資訊checkingfor SSL headers... configure: error: Cannot find ssl headers原因是缺少openssl-devel包,yum -yinstall openssl-devel 問題解決!

5、It appears as thoughyou do not have permission to view information for any of the hosts yourequested...

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

and check the authorization options in your CGI configuration file.

解決:

第一種:

配置cgi.cfg

78 use_authentication=1預設值為1,改為0,即取消賬号驗證

第二種:同樣也是配置cgi.cfg中的參數,

在末行模式下執行 %s/nagiosadmin/username/g

此username是你在htpasswd生成的自定義驗證使用者

開啟認證認證的使用者必須是 cgi.cfg 配置檔案裡有的預設是 nagiosadmin

  如果你建立的其他使用者需要添加進去多使用者用逗号分開

   authorized_for_system_information=nagiosadmin

   authorized_for_configuration_information=nagiosadmin

   authorized_for_system_commands=nagiosadmin

   authorized_for_all_services=nagiosadmin

   authorized_for_all_hosts=nagiosadmin

   authorized_for_all_service_commands=nagiosadmin

   authorized_for_all_host_commands=nagiosadmin

  如果不是 nagiosadmin 需要到後面添加

  例子 authorized_for_system_information=nagiosadmin,username

願積極跟貼,共建nagios故障解決手冊。。。

本文轉自 劉園  51CTO部落格,原文連結:http://blog.51cto.com/colynn/1263963