nagios安裝配置詳解

  1. 1.安裝所需環境
  2. LAMP或者LNMP 
  3. nagios-3.3.1.tar.gz-------------主程序
  4. nagios-plugins-1.4.15.tar.gz----插件
  5. 2.安裝nagios-3.3.1.tar.gz
  6. 添加、修改用戶以及組
  7. [root@localhost nagios]# useradd nagios
  8. [root@localhost nagios]# useradd apache
  9. [root@localhost nagios]# passwd nagios
  10. [root@localhost nagios]# groupadd nagcmd //創建用戶組用於Web接口執行外部命令
  11. [root@localhost nagios]# usermod -g nagcmd nagios
  12. [root@localhost nagios]# usermod -g nagcmd apache
  13. [root@localhost monitor]# tar zxvf nagios-3.3.1.tar.gz -C /usr/local/src/
  14. [root@localhost monitor]# tar zxvf nagios-plugins-1.4.15.tar.gz -C /usr/local/src/
  15. [root@localhost monitor]# cd /usr/local/src/nagios
  16. [root@localhost nagios]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios
  17. --with-nagios-group=nagios --with-command-group=nagcmd --with-gd-lib=/usr/lib/ --with-gd-inc=/usr/include/
  18. 配置成功後會有如下提示:
  19. *** Configuration summary for nagios 3.3.1 07-25-2011 ***:
  20.  
  21. General Options:
    ------------------------- Nagios executable: nagios
    Nagios user/group: nagios,nagios
    Command user/group: nagios,nagcmd
    Embedded Perl: no
    Event Broker: yes
    Install ${prefix}: /usr/local/nagios
    Lock file: ${prefix}/var/nagios.lock
    Check result directory: ${prefix}/var/spool/checkresults
    Init directory: /etc/rc.d/init.d
    Apache conf.d directory: /etc/httpd/conf.d
    Mail program: /bin/mail
    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
  22. [root@localhost nagios]# make all
  23. [root@localhost nagios]# make install
  24. [root@localhost nagios]# make install-init
  25. [root@localhost nagios]# make install-config
  26. [root@localhost nagios]# make install-commandmode
  27. [root@localhost nagios]# vi /usr/local/nagios/etc/objects/contacts.cfg
    修改email地址以接收報警內容
  28. [root@localhost nagios]# make install-webconf
  29. /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
  30. /usr/bin/install: 無法創建普通文件"/etc/httpd/conf.d/nagios.conf": 沒有那個文件或目錄
  31. make: *** [install-webconf] 錯誤 1
  32. [root@localhost nagios]# mkdir -p /etc/httpd/conf.d/
  33. [root@localhost nagios]# /usr/local/webserver/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  34. 3.安裝nagios插件
  35. [root@localhost nagios]# cd ../nagios-plugins-1.4.15/
  36. [root@localhost nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
  37. 配置成功後有如下提示:
  38. --with-apt-get-command:
  39. --with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s
  40. --with-ping-command: /bin/ping -n -U -w %d -c %d %s
  41. --with-ipv6: yes
  42. --with-mysql: /usr/bin/mysql_config
  43. --with-openssl: yes
  44. --with-gnutls: no
  45. --enable-extra-opts: no
  46. --with-perl: /usr/bin/perl
  47. --enable-perl-modules: no
  48. --with-cgiurl: /nagios/cgi-bin
  49. --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin
  50. --enable-libtap: no
  51. [root@bogon nagios-plugins-1.4.15]# make
    [root@bogon nagios-plugins-1.4.15]# make install
  52. 驗證Nagios配置文件
  53. [root@bogon nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    啓動Nagios服務
    [root@bogon nagios]# service nagios start
    4.編輯apache的httpd.conf
  54. 在最後添加:
    ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
  55. <Directory "/usr/local/nagios/sbin">
  56. # SSLRequireSSL
  57. Options ExecCGI
  58. AllowOverride None
  59. Order allow,deny
  60. Allow from all
  61. # Order deny,allow
  62. # Deny from all
  63. # Allow from 127.0.0.1
  64. AuthName "Nagios Access"
  65. AuthType Basic
  66. AuthUserFile /usr/local/nagios/etc/htpasswd.users
  67. Require valid-user
  68. </Directory>
  69. Alias /nagios "/usr/local/nagios/share"
  70. <Directory "/usr/local/nagios/share">
  71. # SSLRequireSSL
  72. Options None
  73. AllowOverride None
  74. Order allow,deny
  75. Allow from all
  76. # Order deny,allow
  77. # Deny from all
  78. # Allow from 127.0.0.1
  79. AuthName "Nagios Access"
  80. AuthType Basic
  81. AuthUserFile /usr/local/nagios/etc/htpasswd.users
  82. Require valid-user
  83. </Directory>
  84. 5.再驗證下
  85. [root@bogon nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    沒有出錯的話,重新啓動nagios和apache
  86. 6.登錄web頁面
  87. http://localehost/nagios
  88. 輸入剛纔設置的用戶名密碼。
  89.  

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章