Nagios新增訪問web頁面的使用者
在安裝Nagios的時候只定義了一個有admin許可權的使用者。但是在實際使用過程中,也許需要讓其他的使用者可以訪問頁面檢視host或service的情況。因此我們需要新增額外的不具備admin許可權的使用者來訪問web頁面。
假設我們要再建立一個叫viewer的使用者,並授權這個使用者可以檢視所有的hosts和services的情況。
1. 用htpasswd新增使用者
htpasswd /usr/local/nagios/etc/htpasswd.users viewer
輸入密碼並確認
2. 修改/usr/local/nagios/etc/cgi.cfg檔案
# GLOBAL HOST/SERVICE VIEW ACCESS
# These two options are comma-delimited lists of all usernames that
# can view information for all hosts and services that are being
# monitored. By default, users can only view information
# for hosts or services that they are contacts for (unless you
# you choose to not use authorization). You may use an asterisk (*)
# to authorize any user who has authenticated to the web server.
authorized_for_all_services=nagios
authorized_for_all_hosts=nagios,viewer
和
# READ-ONLY USERS
# A comma-delimited list of usernames that have read-only rights in
# the CGIs. This will block any service or host commands normally shown
# on the extinfo CGI pages. It will also block comments from being shown
# to read-only users.
#authorized_for_read_only=user1,user2
authorized_for_read_only=viewer
因為viewer只需要檢視web頁面,不需要執行命令,所以只在這兩處新增。如果read_only的地方不新增,那麼viewer將獲得在具體的host或者service頁面執行比如re-schedule等命令的許可權。
3. 重啟httpd和nagios服務
4. 在web介面用viewer賬戶登入,即可檢視所有hosts和services的情況,但在具體到某個host或service頁面的時候,右側會顯示:
Host Commands
Your account does not have permissions to execute commands. |