91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

nagios的安裝配置方法

發布時間:2021-07-22 23:42:01 來源:億速云 閱讀:384 作者:chen 欄目:移動開發

這篇文章主要講解了“nagios的安裝配置方法”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“nagios的安裝配置方法”吧!

簡單介紹下nagios

開源網絡監控

監控的分類:

狀態的連續監控:對實時狀態進行監控。

狀態的變化監控:但某一時刻監控的狀態發生變化時,就進行匯報。

nagios是一款遵循GPLV2的開源網絡監控軟件,可用來監控制定的多種系統的主機、服務,并在它們的工作狀態發生變化時通知管理員。

1)監控網絡服務(HTTP/POP3/SMTP/PING/MYSQL等)

2)監控主機資源(磁盤利用率、內存利用率、CPU負載等)

3)簡潔的插件設計接口,使得用戶可以輕松開發所需的檢測腳本(運維則可直接找到相關腳本并使用)

4)并行服務模式

5)輕松描述網絡結構,并且能夠區辨“宕機”和“主機不可達”

6)通過郵件或用戶自定義的方式將主機或服務的工作狀態變化情況通知給管理員

7)當服務或主機問題產生與解決時將告警發送給聯系人(通過EMail/短信、用戶定義方式)

8)自動日志滾動

9)可以通過web方式直觀的查看當前網絡狀態、通知和問題歷史、日志文件等,此組件為可選

undefined

Nagios通常由一個主程序(Nagios)、一個插件程序(Nagios-plugins)和四個可選的ADDON(NRPE/NSCA/NSCLIENT++和NDOUTILS)組成。

NRPE:用來在監控的的遠程LINUX/UNIX主機上執行腳本插件以實現對這些主機資源的監控;

              試驗中用到的版本是NRPE-2.1.2.tar.gz

NSCA:用來讓被監控的遠程Linux/Unix主機主動將監控信息發送給Nagios服務器(這在冗余監控模式中,特別要用到)

NSCLIENT++:用來監控Windows主機時安裝在Windows主機上的組件;

NDOUTILS:則用來將NAGIOS的配置信息和各EVETN產生的數據存入數據庫,以實現對這些數據的快速檢索和處理;


NAGIOS是通過配置文件來驅動這個監控流程,因為所有的內容都是可配置的,所以也就非常靈活,功能自然也就槍彈,把太多的工作留給使用者。

1、新添加監控主機

要修改localhost.cfg或windows.cfg配置文件

這里的默認路徑為/usr/local/nagios/etc/objects/localhost.cfg或者/usr/local/nagios/etc/objects/windows.cfg

2、調整監控的命令

要修改commands.cfg配置文件

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

3、要更改聯系人的信息

要修改contacts.cfg配置文件

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

4、要調整監控時間

要修改timeperiods.cfg配置文件

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

5、添加具體的監控服務

要修改services.cfg配置文件,這里信息都是來自其他配置文件的

6、存放相關的命令執行腳本

/usr/local/nagios/libexecls

7、/usr/local/nagios/etc/objects/commands.cfg 定義相關命令


yum 源安裝配置

vi /etc/yum.repos.d/Centos-Media.repo

[xscl]

baseurl=file:///mnt/cdrom/

gpgcheck=0

enabled=1

:wq


安裝nagios必須的基本組件的運行依賴于httpd、gcc和gd.

yum clean all

準備工作:

  1. yum -y install  httpd*  php

  2. yum -y install gcc glibc glibc-common

  3. yum -y install gd gd-devel


groupadd nagcmd

useradd -m nagios

usermod -a -G nagcmd nagios

# usermod -a -G nagcmd apache

#j將apache用戶加入nagcmd組使之工作時具有足夠的權限

下載所需要的安裝組件:

服務器端所用的安裝包:nagios   nagios-plugins  ndoutils(非必須)

linux客戶端:nrpe

windows客戶端:NSCLIENT

創建用戶:

chkconfig httpd on

useradd   nagios

cd /root

上傳軟件包我這里下載的nagios-3.3.1.tar.gz

tar-xzvf nagios-3.3.1.tar.gz

cd nagios

#./configure --with-command-group=nagcmd

make  install

報錯解決方法如下:

今天安裝nagios3.3.1,不是第一次安裝了,之前都很順利,這次安裝的時候,在執行命令make install的時候,報錯了。大致如下  


  1. [root@magedunagios]#makeinstall

  2. cd./base&&makeinstall

  3. make[1]:Enteringdirectory`/root/nagios/base'

  4. makeinstall-basic

  5. make[2]:Enteringdirectory`/root/nagios/base'

  6. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/bin

  7. /usr/bin/install-c-m774-onagios-gnagiosnagios/var/www/html/nagios/bin

  8. /usr/bin/install-c-m774-onagios-gnagiosnagiostats/var/www/html/nagios/bin

  9. make[2]:Leavingdirectory`/root/nagios/base'

  10. makestrip-post-install

  11. make[2]:Enteringdirectory`/root/nagios/base'

  12. /usr/bin/strip/var/www/html/nagios/bin/nagios

  13. /usr/bin/strip/var/www/html/nagios/bin/nagiostats

  14. make[2]:Leavingdirectory`/root/nagios/base'

  15. make[1]:Leavingdirectory`/root/nagios/base'

  16. cd./cgi&&makeinstall

  17. make[1]:Enteringdirectory`/root/nagios/cgi'

  18. makeinstall-basic

  19. make[2]:Enteringdirectory`/root/nagios/cgi'

  20. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/sbin

  21. forfilein*.cgi;do\

  22. /usr/bin/install-c-m775-onagios-gnagios$file/var/www/html/nagios/sbin;\

  23. done

  24. make[2]:Leavingdirectory`/root/nagios/cgi'

  25. makestrip-post-install

  26. make[2]:Enteringdirectory`/root/nagios/cgi'

  27. forfilein*.cgi;do\

  28. /usr/bin/strip/var/www/html/nagios/sbin/$file;\

  29. done

  30. make[2]:Leavingdirectory`/root/nagios/cgi'

  31. make[1]:Leavingdirectory`/root/nagios/cgi'

  32. cd./html&&makeinstall

  33. make[1]:Enteringdirectory`/root/nagios/html'

  34. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share

  35. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/media

  36. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/stylesheets

  37. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/contexthelp

  38. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/docs

  39. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/docs/p_w_picpaths

  40. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/p_w_picpaths

  41. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/p_w_picpaths/logos

  42. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/includes

  43. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/includes/rss

  44. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/includes/rss/extlib

  45. /usr/bin/install-c-m775-onagios-gnagios-d/var/www/html/nagios/share/ssi

  46. /usr/bin/install-c-m664-onagios-gnagiosrobots.txt/var/www/html/nagios/share

  47. rm-f/var/www/html/nagios/share/index.html

  48. rm-f/var/www/html/nagios/share/main.html

  49. rm-f/var/www/html/nagios/share/side.html

  50. forfilein*.php;\

  51. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share;done

  52. forfileinstylesheets/*.css;\

  53. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/stylesheets;done

  54. forfileincontexthelp/*.html;\

  55. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/contexthelp;done

  56. forfileinp_w_picpaths/*.gif;\

  57. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths;done

  58. forfileinp_w_picpaths/*.jpg;\

  59. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths;done

  60. forfileinp_w_picpaths/*.png;\

  61. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths;done

  62. forfileinp_w_picpaths/*.ico;\

  63. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths;done

  64. forfileinp_w_picpaths/logos/*.*;\

  65. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/p_w_picpaths/logos;done

  66. forfileinincludes/*.*;\

  67. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/includes;done

  68. forfileinincludes/rss/*;\

  69. do/usr/bin/install-c-m664-onagios-gnagios$file/var/www/html/nagios/share/includes/rss;done

  70. /usr/bin/install:omittingdirectory`includes/rss/extlib'

  71. /usr/bin/install:omittingdirectory`includes/rss/htdocs'

  72. /usr/bin/install:omittingdirectory`includes/rss/scripts'

  73. make[1]:***[install]Error1

  74. make[1]:Leavingdirectory`/root/nagios/html'

  75. make:***[install]Error2


很糾結啊,google了一下,有解決方案,好像是makefile里有語法錯誤,具體怎么導致的不清楚,執行完以下命令,就OK了

  1. # sed-i's:forfileinincludes/rss/\*;:forfileinincludes/rss/\*.\*;:g'./html/Makefile

  2. # sed-i's:forfileinincludes/rss/extlib/\*;:forfileinincludes/rss/extlib/\*.\*;:g'./html/Makefile

  3. 然后,執行以下命令,來完成安裝

預配置Nagios主程序的環境以及指定安裝路徑
[root@nagios-3.3.1]# ./configure --prefix=/usr/local/nagios
預配置成功后將返回配置環境信息
----------------------------------------------------
*** Configuration summary for nagios 2.9 04-10-2007 ***:

General Options:
-------------------------
       Nagios executable:  nagios
       Nagios user/group:  nagios,nagios
      Command user/group:  nagios,nagios
           Embedded Perl:  no
            Event Broker:  yes
       Install ${prefix}:  /usr/local/nagios
               Lock file:  ${prefix}/var/nagios.lock
          Init directory:  /etc/rc.d/init.d
                 Host OS:  linux-gnu

Web Interface Options:
------------------------
                HTML URL:  http://localhost/nagios/
                 CGI URL:  http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):  /bin/traceroute


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

請注意看最后的提示,如果對以上反饋信息接受的話,則需要繼續執行“make all”命令來編譯主程序以及CGI。


.編譯Nagios主程序
[root@KCentOS5C nagios-2.9]# make all
Nagios主程序編譯成功后將返回信息
-----------------------------------------------------
*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
如果在編譯當中沒有發生錯誤的話,那么可以照以下這些命令繼續操作。

 make install
    - This installs the main program, CGIs, and HTML files
 執行“make install”命令來對主程序,CGI以及HTML網頁進行安裝。

 make install-init
    - This installs the init script in /etc/rc.d/init.d
 執行“install-init”命令來在/etc/rc.d/init.d/目錄中安裝啟動腳本。

 make install-commandmode
    - This installs and configures permissions on the
      directory for holding the external command file
 執行“install-commandmode”命令來安裝和配置外部命令對Nagios主路徑操作的權限。(這里所謂的外部命令主要是指Apache服務通過CGI來對Nagios的進行的操作。用戶將通過Web以執行CGI程序腳本的方式來對Nagios的檢測結果進行讀取和調用。)

 make install-config
    - This installs *SAMPLE* config files in /usr/local/nagios/etc
      You'll have to modify these sample files before you can
      use Nagios.  Read the HTML documentation for more info
      on doing this.  Pay particular attention to the docs on
      object configuration files, as they determine what/how
      things get monitored!
 執行“make install-config”命令將會在/usr/local/etc/這個Nagios編譯安裝的主配置路徑下安裝示例配置模板,這將對于之后的配置制定幫助很大。

*** Support Notes *******************************************
這些關于支持的信息就不再詳細講了

If you have questions about configuring or running Nagios,
please make sure that you:

    - Look at the sample config files
    - Read the HTML documentation
    - Read the FAQs online at http://www.nagios.org/faqs

before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you.  This might include:

    - What version of Nagios you are using
    - What version of the plugins you are using
    - Relevant snippets from your config files
    - Relevant error messages from the Nagios log file

For more information on obtaining support for Nagios, visit:

http://www.nagios.org/support/

*************************************************************

Enjoy.
-----------------------------------------------------


5.安裝Nagios主程序、CGI以及網頁
[root@KCentOS5C nagios-2.9]# make install
安裝完Nagios主程序、CGI和網頁的之后將提示安裝成功信息以及剩余可操作的步驟
-----------------------------------------------------
*** Main program, CGIs and HTML files installed ***

You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

 make install-init
    - This installs the init script in /etc/rc.d/init.d

 make install-commandmode
    - This installs and configures permissions on the
      directory for holding the external command file

 make install-config
    - This installs *SAMPLE* config files in /usr/local/nagios/etc
      You'll have to modify these sample files before you can
      use Nagios.  Read the HTML documentation for more info
      on doing this.  Pay particular attention to the docs on
      object configuration files, as they determine what/how
      things get monitored!
-----------------------------------------------------


6.安裝Nagios的系統啟動腳本
[root@KCentOS5C nagios-2.9]# make install-init
安裝完Nagios的系統啟動腳本之后將提示腳本安裝成功信息以及剩余可操作的步驟
-----------------------------------------------------
*** Init script installed ***

You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

 make install-commandmode
    - This installs and configures permissions on the
      directory for holding the external command file

 make install-config
    - This installs *SAMPLE* config files in /usr/local/nagios/etc
      You'll have to modify these sample files before you can
      use Nagios.  Read the HTML documentation for more info
      on doing this.  Pay particular attention to the docs on
      object configuration files, as they determine what/how
      things get monitored!
-----------------------------------------------------


7.將Nagios的啟動腳本添加到系統服務當中去
[root@KCentOS5C ~]# chkconfig --add nagios

8.將Nagios服務加入到系統啟動服務當中去
[root@KCentOS5C ~]# chkconfig nagios on

9.安裝和配置外部命令對Nagios主路徑的操作權限
[root@KCentOS5C nagios-2.9]# make install-commandmode
安裝配置外操作權限后將提示配置成功信息以及剩余可操作步驟
-----------------------------------------------------
*** External command directory configured ***

You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

 make install-config
    - This installs *SAMPLE* config files in /usr/local/nagios/etc
      You'll have to modify these sample files before you can
      use Nagios.  Read the HTML documentation for more info
      on doing this.  Pay particular attention to the docs on
      object configuration files, as they determine what/how
      things get monitored!
-----------------------------------------------------


10.將Apache服務宿主用戶加到nagios組里面
這樣做是為了讓Apache有適當的權限能夠通過CGI腳本程序對Nagios進行調用,否則Apache將沒有權限調用Nagios,用戶通過Web將無法訪問Nagios處理的所有信息。
[root@KCentOS5C nagios-2.9]# usermod -G n apache


11.安裝Nagios的配置模板
[root@KCentOS5C nagios-2.9]# make install-config
安裝完畢Nagios的配置模板后將反饋安裝成功的提示信息。
-----------------------------------------------------
*** Sample config file installed ***

Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

If you have questions about configuring Nagios properly, please:
      - Look at the sample config files
      - Read the HTML documentation
      - Read the FAQs online at http://www.nagios.org/faqs
*BEFORE* you post a question to one of the mailing lists.
-----------------------------------------------------


為email指定您想用來接收nagios警告信息的郵件地址,默認是本機的nagios用戶:

# vi /usr/local/nagios/etc/objects/contacts.cfg

email        nagios@localhost       #這個是默認設置

# make install-webconf

#在/etc/httpd/conf.d/nagios.conf生成web相關配置文件,用于定義nagios使用的CGI選項,web的身份認證等

[root@station71 nagios]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

New password:

Re-type new password:

Adding password for user nagios

#為nagios的web頁面創建賬號密碼,對訪問進行身份認證

service httpd restart

chkconfig httpd on

啟動httpd,并設置開機啟動

進入Nagios-plugins插件包目錄
[root@KCentOS5C ~]# cd nagios-plugins-1.4.10

3.預配置Nagios-plugin插件程序的環境以及指定安裝路徑

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql

[root@ nagios-plugins-1.4.10]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql預配置完成的話將會建立Makefile并反饋檢測系統環境的結果。
-----------------------------------------------------
config.status: creating po/Makefile
           --with-apt-get-command:
             --with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s
              --with-ping-command: /bin/ping -n -U -w %d -c %d %s
                      --with-ipv6: yes
                     --with-mysql: no
                   --with-openssl: yes
                    --with-gnutls: no
                      --with-perl: /usr/bin/perl
            --enable-perl-modules: no
                    --with-cgiurl: /nagios/cgi-bin
              --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin
-----------------------------------------------------

4.編譯Nagios-plugin插件程序
[root@KCentOS5C nagios-plugins-1.4.10]# make

5.安裝Nagios-plugin插件程序

[root@KCentOS5C nagios-plugins-1.4.10]# make install

6.查看安裝情況

[root@KCentOS5C nagios-plugins-1.4.10]# ll /usr/local/nagios/

-----------------------------------------------------
total 28
drwxrwxr-x 2 nagios nagios 4096 Oct  5 13:25 bin
drwxrwxr-x 2 nagios nagios 4096 Oct  5 19:03 etc
drwxr-xr-x 2 root   root   4096 Oct  5 19:07 libexec
drwxrwxr-x 2 nagios nagios 4096 Oct  5 13:25 sbin
drwxrwxr-x 9 nagios nagios 4096 Oct  5 19:07 share
drwxrwxr-x 4 nagios nagios 4096 Oct  5 19:08 var

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

只要Nagios主路徑下出現libexec目錄就說明安裝成功了,這個目錄里面存放著就是Nagios插件執行程序。但是有個問題,就是剛安裝好會有一些目錄和文件的屬主是root。這里的libexec就有這個問題。

4.編譯Nagios-plugin插件程序
[root@KCentOS5C nagios-plugins-1.4.10]# make

5.安裝Nagios-plugin插件程序

[root@KCentOS5C nagios-plugins-1.4.10]# make install

6.查看安裝情況

[root@KCentOS5C nagios-plugins-1.4.10]# ll /usr/local/nagios/

-----------------------------------------------------
total 28
drwxrwxr-x 2 nagios nagios 4096 Oct  5 13:25 bin
drwxrwxr-x 2 nagios nagios 4096 Oct  5 19:03 etc
drwxr-xr-x 2 root   root   4096 Oct  5 19:07 libexec
drwxrwxr-x 2 nagios nagios 4096 Oct  5 13:25 sbin
drwxrwxr-x 9 nagios nagios 4096 Oct  5 19:07 share

drwxrwxr-x 4 nagios nagios 4096 Oct  5 19:08 var

7/ cd /usr/local/nagios/libexec

ll

[root@localhost libexec]# ll

total 6436

-rwxr-xr-x. 1 root root 376516 Jun  4 19:06 check_apt

-rwxr-xr-x. 1 root root   2254 Jun  4 19:06 check_breeze

-rwxr-xr-x. 1 root root 128392 Jun  4 19:06 check_by_ssh

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_clamd -> check_tcp

-rwxr-xr-x. 1 root root  85678 Jun  4 19:06 check_cluster

-r-sr-xr-x. 1 root root 123723 Jun  4 19:06 check_dhcp

-rwxr-xr-x. 1 root root 121722 Jun  4 19:06 check_dig

-rwxr-xr-x. 1 root root 417871 Jun  4 19:06 check_disk

-rwxr-xr-x. 1 root root   9148 Jun  4 19:06 check_disk_smb

-rwxr-xr-x. 1 root root 129579 Jun  4 19:06 check_dns

-rwxr-xr-x. 1 root root  80681 Jun  4 19:06 check_dummy

-rwxr-xr-x. 1 root root   3056 Jun  4 19:06 check_file_age

-rwxr-xr-x. 1 root root   6318 Jun  4 19:06 check_flexlm

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_ftp -> check_tcp

-rwxr-xr-x. 1 root root 123705 Jun  4 19:06 check_hpjd

-rwxr-xr-x. 1 root root 519173 Jun  4 19:06 check_http

-r-sr-xr-x. 1 root root 133809 Jun  4 19:06 check_icmp

-rwxr-xr-x. 1 root root  93400 Jun  4 19:06 check_ide_smart

-rwxr-xr-x. 1 root root  15137 Jun  4 19:06 check_ifoperstatus

-rwxr-xr-x. 1 root root  12601 Jun  4 19:06 check_ifstatus

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_imap -> check_tcp

-rwxr-xr-x. 1 root root   6890 Jun  4 19:06 check_ircd

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_jabber -> check_tcp

-rwxr-xr-x. 1 root root 106623 Jun  4 19:06 check_ldap

lrwxrwxrwx. 1 root root     10 Jun  4 19:06 check_ldaps -> check_ldap

-rwxr-xr-x. 1 root root 106565 Jun  4 19:06 check_load

-rwxr-xr-x. 1 root root   6020 Jun  4 19:06 check_log

-rwxr-xr-x. 1 root root  20287 Jun  4 19:06 check_mailq

-rwxr-xr-x. 1 root root  93126 Jun  4 19:06 check_mrtg

-rwxr-xr-x. 1 root root  92471 Jun  4 19:06 check_mrtgtraf

-rwxr-xr-x. 1 root root 129508 Jun  4 19:06 check_mysql

-rwxr-xr-x. 1 root root 122490 Jun  4 19:06 check_mysql_query

-rwxr-xr-x. 1 root root 105598 Jun  4 19:06 check_nagios

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_nntp -> check_tcp

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_nntps -> check_tcp

-rwxr-xr-x. 1 root root 127807 Jun  4 19:06 check_nt

-rwxr-xr-x. 1 root root 130198 Jun  4 19:06 check_ntp

-rwxr-xr-x. 1 root root 119287 Jun  4 19:06 check_ntp_peer

-rwxr-xr-x. 1 root root 117856 Jun  4 19:06 check_ntp_time

-rwxr-xr-x. 1 root root 159492 Jun  4 19:06 check_nwstat

-rwxr-xr-x. 1 root root   8324 Jun  4 19:06 check_oracle

-rwxr-xr-x. 1 root root 109022 Jun  4 19:06 check_overcr

-rwxr-xr-x. 1 root root 105553 Jun  4 19:06 check_pgsql

-rwxr-xr-x. 1 root root 132787 Jun  4 19:06 check_ping

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_pop -> check_tcp

-rwxr-xr-x. 1 root root 396825 Jun  4 19:06 check_procs

-rwxr-xr-x. 1 root root 106620 Jun  4 19:06 check_real

-rwxr-xr-x. 1 root root   9584 Jun  4 19:06 check_rpc

-rwxr-xr-x. 1 root root   1412 Jun  4 19:06 check_sensors

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_simap -> check_tcp

-rwxr-xr-x. 1 root root 445174 Jun  4 19:06 check_smtp

-rwxr-xr-x. 1 root root 447023 Jun  4 19:06 check_snmp

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_spop -> check_tcp

-rwxr-xr-x. 1 root root 103128 Jun  4 19:06 check_ssh

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_ssmtp -> check_tcp

-rwxr-xr-x. 1 root root 108201 Jun  4 19:06 check_swap

-rwxr-xr-x. 1 root root 158985 Jun  4 19:06 check_tcp

-rwxr-xr-x. 1 root root 105150 Jun  4 19:06 check_time

lrwxrwxrwx. 1 root root      9 Jun  4 19:06 check_udp -> check_tcp

-rwxr-xr-x. 1 root root 117678 Jun  4 19:06 check_ups

-rwxr-xr-x. 1 root root  83418 Jun  4 19:06 check_users

-rwxr-xr-x. 1 root root   2939 Jun  4 19:06 check_wave

-rwxr-xr-x. 1 root root 109707 Jun  4 19:06 negate

-rwxr-xr-x. 1 root root 103234 Jun  4 19:06 urlize

-rwxr-xr-x. 1 root root   1939 Jun  4 19:06 utils.pm

-rwxr-xr-x. 1 root root   2728 Jun  4 19:06 utils.sh

8、

7.遞歸更改Nagios主路徑的屬主

[root@KCentOS5C nagios-plugins-1.4.10]# chown -R nagios.nagios /usr/local/nagios/

8.遞歸增加Nagios主路徑同組用戶讀寫屬性

[root@KCentOS5C nagios-plugins-1.4.10]# chmod -R g+wr /usr/local/nagios/

四.配置Apache服務:
1.備份Apache服務的主配置文件
[root@KCentOS5C ~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.backup

2.配置Apache服務的主配置文件
[root@KCentOS5C ~]# vi /etc/httpd/conf/httpd.conf
這里主要改動以下這些參數:
-----------------------------------------------------
ServerName *:80

配置Apache的服務器名,如果有域名的話請填寫正確的服務器名。

Include conf.d/*.conf

確認Apache擴展配置文件的存放路徑。
-----------------------------------------------------


3.察看Nagios網頁配置模板文件
[root@KCentOS5C ~]# less nagios-2.9/sample-config/httpd.conf
-----------------------------------------------------
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
# Last Modified: 11-26-2005
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file.  Customize the paths, etc. as
# needed to fit your system.

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

設定了Nagios的CGI執行目錄對應的系統路徑。

<Directory "/usr/local/nagios/sbin">
#  SSLRequireSSL
  Options ExecCGI
  AllowOverride None
  Order allow,deny
  Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
  AuthName "Nagios Access"
  AuthType Basic
  AuthUserFile /usr/local/nagios/etc/htpasswd.users

這里指定了訪問用戶帳戶庫文件。
  Require valid-user
</Directory>

Alias /nagios "/usr/local/nagios/share"

設定了Nagios的網頁URL對應的系統路徑。

<Directory "/usr/local/nagios/share">
#  SSLRequireSSL
  Options None
  AllowOverride None
  Order allow,deny
  Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
  AuthName "Nagios Access"
  AuthType Basic
  AuthUserFile /usr/local/nagios/etc/htpasswd.users

這里指定了訪問用戶帳戶庫文件
  Require valid-user
</Directory>
-----------------------------------------------------
基本上這個文件可以直接使用。根據這個配置文件中指定的AuthUserFile項,它指定的是通過Apache訪問Nagios的合法用戶的帳戶名單庫文件,需要使用htpasswd命令對這個名單庫進行用戶的添加。而默認安裝環境下在/usr/local/nagios/etc/目錄下是沒有htpasswd.user這個文件的,所以需要手動添加。請特別注意,用root身份建立的htpasswd.user文件的權限問題,應該在建立該文件完畢后立即更改為nagios用戶nagios組的所有權,并且要增加Nagios同組用戶讀寫權限。


4.整合Nagios網頁配置文件到Apache中
將Nagios網頁配置文件作為Apache的擴展配置文件復制改名到Apache的擴展配置文件目錄/etc/httpd/conf.d/目錄下
[root@KCentOS5C ~]# cp nagios-2.9/sample-config/httpd.conf /etc/httpd/conf.d/nagios-httpd.conf

5.建立Nagios的網頁訪問用戶帳戶文件(這里必須要與Nagios網頁配置文件當中AuthUserFile指定的路徑文件名一致)
[root@KCentOS5C ~]# touch /usr/local/nagios/etc/htpasswd.user

6.更改Nagios網頁訪問用戶帳戶文件的屬主
[root@KCentOS5C ~]# chown nagios.nagios /usr/local/nagios/etc/htpasswd.users

7.對Nagios網頁訪問用戶帳戶文件增加同組成員讀寫權限(這主要是賦給apache這個系統用戶)
[root@KCentOS5C ~]# chmod g+wr /usr/local/nagios/etc/htpasswd.users

8.察看Nagios網頁訪問用戶帳戶文件的屬性信息
[root@KCentOS5C ~]# ll /usr/local/nagios/etc/htpasswd.users
-rw-rw-r-- 1 nagios nagios 0 Oct  5 14:05 /usr/local/nagios/etc/htpasswd.users

9.添加htpasswd.user用戶
我添加了一個kanecruise用戶,口令是123456。
[root@KCentOS5C ~]# htpasswd -m /usr/local/nagios/etc/htpasswd.user kanecruise
------------------------------------------------------------
New password: 123456
Re-type new password: 123456
Adding password for user kanecruise
------------------------------------------------------------


10.察看htpasswd的使用方法,這里我就解釋一些比較重要和常用的。
[root@KCentOS5C ~]# htpasswd
-------------------------------------------------------------
Usage:
       htpasswd [-cmdpsD] passwordfile username
       htpasswd -b[cmdpsD] passwordfile username password
       htpasswd -n[mdps] username
       htpasswd -nb[mdps] username password

-c  Create a new file.
    建立新的帳戶庫文件。

-n  Don't update file; display results on stdout.

-m  Force MD5 encryption of the password.
    添加一個MD5口令加密的新用戶。

-d  Force CRYPT encryption of the password (default).

-p  Do not encrypt the password (plaintext).
    添加一個口令不加密的新用戶。

-s  Force SHA encryption of the password.
    添加一個SHA口令加密的新用戶。

-b  Use the password from the command line rather than prompting for it.

-D  Delete the specified user.
    刪除一個指定的用戶

On Windows, NetWare and TPF systems the '-m' flag is used by default.
在Windows、NetWare以及TPF這些操作系統中“-m”參數(啟用MD5對口令加密)是默認使用的
On all other systems, the '-p' flag will probably not work.
在其他的所有操作系統中“-p”(不對口令啟用加密)參數將可能會引起失敗。
-------------------------------------------------------------


11.檢查htpasswd帳戶文件
[root@KCentOS5C ~]# cat /usr/local/nagios/etc/htpasswd.users
-------------------------------------------------------------
kanecruise:$apr1$Qwk9h/..$HaRakpabADGZL10dwPcrx1
-------------------------------------------------------------
用戶添加正確,并且口令都以MD5的方式加密了。

五.Nagios的配置文件:
默認下Nagios編譯安裝后都沒有現成的配置文件,它們都以模板配置文件的方式在/usr/local/nagios/etc/這個主配置路徑下,需要手動復制并配置成可用的配置文件。

1.處理Nagios的主配置文件
Nagios的主配置文件為nagios.cfg。
[root@KCentOS5C ~]# cp /usr/local/nagios/etc/nagios.cfg-sample /usr/local/nagios/etc/nagios.cfg

2.配置Nagios的主配置文件
[root@KCentOS5C ~]# vi /usr/local/nagios/etc/nagios.cfg
主要修改和確認以下幾個較重要的配置項,其余的類似優化涉及到的配置調整這里暫不交待了。這次不像上回我用RPM包安裝Nagios那次的配置方式,這次我打算將所有Nagios功能定義配置都集中在localhost.cfg這一個文件當中去,而命令定義文件commands.cfg獨立保存一個文件,因此除了這兩個文件不注釋外,其他的Nagios功能定義文件都保持注釋狀態。
-------------------------------------------------------------
log_file=/usr/local/nagios/var/nagios.log
確認Nagios服務的日志記錄文件,需要確認此項是解注狀態的。默認編譯安裝后沒有該文件,要手動添加并指定適當的讀寫權限。

cfg_file=/usr/local/nagios/etc/commands.cfg
在Nagios中將對應功能插件定義成命令的命令定義文件,需要確認此項是解注狀態的。默認編譯安裝后也沒有該文件,需要從模版復制。

cfg_file=/usr/local/nagios/etc/localhost.cfg
設定Naigos對象功能定義的配置文件,需要確認此項是解注狀態的。默認編譯安裝后也沒有該文件,需要從模版復制。

cfg_file=/usr/local/nagios/etc/resource.cfg

設定Nagios的資源文件,需要確認此項是解注狀態的。默認編譯安裝后也沒有該文件,需要從模版復制。

#cfg_file=/usr/local/nagios/etc/contactgroups.cfg
#cfg_file=/usr/local/nagios/etc/contacts.cfg
#cfg_file=/usr/local/nagios/etc/dependencies.cfg
#cfg_file=/usr/local/nagios/etc/escalations.cfg
#cfg_file=/usr/local/nagios/etc/hostgroups.cfg
#cfg_file=/usr/local/nagios/etc/hosts.cfg
#cfg_file=/usr/local/nagios/etc/services.cfg
#cfg_file=/usr/local/nagios/etc/timeperiods.cfg
#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
以上這些分塊功能的定義配置文件需要保持注釋,因為這些文件的作用都已經集中到localhost.cfg這一個文件當中去了。

nagios_user=nagios
nagios_group=nagios
設定Nagios服務的宿主用戶和組。

#check_external_commands=0
check_external_commands=1
設定Nagios外部檢查命令功能開關,默認是值0。將原來的注釋掉,更改為值1,必須要打開該功能,否則CGI將不能調用。

command_check_interval=15s
#command_check_interval=-1
設定命令檢查的時間間隔,將原來值-1的項注釋掉,啟用原來備用值為15s(15秒)。這項的時間間隔值請按實際需求情況設定。
-------------------------------------------------------------

對Nagios的主日志文件的操作如下:

手動建立Nagios主日志文件
[root@KCentOS5C ~]# touch /usr/local/nagios/var/nagios.log


改變Nagios主日志文件的屬主。

[root@KCentOS5C ~]# chown nagios.nagios /usr/local/nagios/var/nagios.log


添加同組成員的讀寫權限。

[root@KCentOS5C ~]# chmod g+rw /usr/local/nagios/var/nagios.log


查看日志文件的屬性。

[root@KCentOS5C ~]# ll /usr/local/nagios/var/nagios.log
-rw-rw-r-- 1 nagios nagios 0 Oct  5 15:28 /usr/local/nagios/var/nagios.log


3.處理Nagios的CGI配置文件:
[root@KCentOS5C ~]# cp /usr/local/nagios/etc/cgi.cfg-sample /usr/local/nagios/etc/cgi.cfg

4.配置Nagios的CGI配置文件
[root@KCentOS5C ~]# vi /usr/local/nagios/etc/cgi.cfg
這里主要注意關于訪問用戶身份驗證的配置項的設定。Nagios系統將各種操作行為的授權用戶分的非常的仔細,所以在實際應用當中可以分的非常細,什么用戶可以做哪些操作而哪些用戶又沒有權限做哪些操作。但是這里我只簡單的授權給同一個用戶。請特別注意,這里的授權用戶的對象必須只能夠是在htpasswd中添加注冊過的用戶。
-------------------------------------------------------------
use_authentication=1
設定啟用身份驗證。

authorized_for_system_information=kanecruise
設定系統信息的授權用戶。

authorized_for_configuration_information=kanecruise
設定配置信息的授權用戶。

authorized_for_system_commands=kanecruise
設定系統命令的授權用戶。

authorized_for_all_services=kanecruise
設定全部監測服務的授權用戶。

authorized_for_all_hosts=kanecruise
設定全部被監測主機的授權用戶。

authorized_for_all_service_commands=kanecruise
設定全部監測服務命令的授權用戶。

authorized_for_all_host_commands=kanecruise
設定全部主機命令的授權用戶。
-------------------------------------------------------------

5.處理Nagios的命令定義文件
[root@KCentOS5C ~]# cp /usr/local/nagios/etc/commands.cfg-sample /usr/local/nagios/etc/commands.cfg

6.處理Nagios的資源文件

[root@KCentOS5C ~]# cp /usr/local/nagios/etc/resource.cfg-sample /usr/local/nagios/etc/resource.cfg


目前來說暫時不需要對Nagios命令定義文件做什么修改。但是如果要添加新的命令或者修改現有命令的定義的話,則需要修改該文件。

感謝各位的閱讀,以上就是“nagios的安裝配置方法”的內容了,經過本文的學習后,相信大家對nagios的安裝配置方法這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

鄯善县| 资讯| 三江| 塔城市| 濮阳市| 唐山市| 奉新县| 上虞市| 湘潭市| 水城县| 静乐县| 贵溪市| 栾川县| 临武县| 桐梓县| 宁明县| 甘孜县| 同德县| 略阳县| 东丽区| 新宾| 资阳市| 三穗县| 克东县| 神池县| 缙云县| 平利县| 嵩明县| 运城市| 合川市| 丰宁| 祁东县| 武山县| 行唐县| 兴国县| 巴青县| 抚顺市| 新郑市| 揭阳市| 右玉县| 鸡西市|