天天看點

nagios監控-多使用者管理

我們nagios監控的主機大概有200多台,包含幾個合作廠家的機器,nagios平時都是我們這邊在維護,其他廠家基本上不會上去看或作其他操作。最近一合作廠家希望可以通路nagios看看自己的機器的運作情況,對于我們這邊來說也是希望可以為每個廠家配置設定一個不同的使用者名,登入後都隻能檢視和管理自己機器的資訊而不能檢視其他廠家的主機資訊。

    剛開始我想到在搭nagios的時候,使用者驗證是用apache來做的,接到這個需求後的第一反應是這個東西可能做不了。但接着一想,不應該啊,nagios本身至少會有一些使用者配置的吧,于是看了下文檔,還真的發現有:http://yourserverIP/nagios/docs/cgiauth.html

      對着文檔配置後,可以實作需求,記錄如下:

   (1)新增一個apache使用者,如userA

     [[email protected] ~]# htpasswd /usr/local/nagios/etc/htpasswd.users userA

   (2)更改cgi.cfg配置

     [[email protected] ~]# vi /usr/local/nagios/etc/cgi.cfg

     use_authentication=1

     如果隻允許檢視,不允許管理,加上下面配置

     authorized_for_read_only=userA

   (3)将userA設為聯系人

     [[email protected] ~]# vi /usr/local/nagios/etc/objects/contacts.cfg  #添加如下配置

      define contact{

                     contact_name                   userA

                     use                                      generic-contact

                    alias                                     userA

            }

        (4)在屬于userA的主機、服務配置檔案的聯系人中加入userA:

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

           define host {

              host_name [email protected]

              alias [email protected]

              address 10.1.1.22

              contacs userA

              contact_groups sys_admins

              check_command check-host-alive

              max_check_attempts 5

              notification_interval  3

              notification_period 24x7

              notification_options d,u,r

           }

      (5)重新開機nagios後生效

        [[email protected] ~]#  /etc/init.d/nagios restart