歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> VMware Linux下Nagios的安裝

VMware Linux下Nagios的安裝

日期:2017/2/28 16:02:52   编辑:Linux教程

Nagios是一個系統監控工具,把不易檢測的主機參數以頁面的形式展現出來,這個配置耗費了我很久的時間!

平台:紅帽RHEL 5.4

本次安裝需要的軟件

nagios-3.2.3.tar.gz(nagios的core)

nagios-plugins-1.4.15.tar.gz(功能插件)

nagios-cn-3.2.3.tar.bz2(中文插件)

其中中文插件的選擇必須和core高度一致

本次安裝需要開啟的服務

apache和sendmail

另外還需以rpm或者yum的方式來安裝php的功能模塊

當然這兩個軟件也可以用源碼編譯的方式來安裝,這裡采用是系統默認安裝的套件

1、安裝前的准備

關閉selinux和清除防火牆規則(為了不影響測試)

[root@localhost ~]# useradd nagios
[root@localhost ~]# passwd nagios

2、安裝nagios的core

[root@localhost ~]# ls nagios-3.2.3.tar.gz
nagios-3.2.3.tar.gz
[root@localhost ~]# tar zxvf nagios-3.2.3.tar.gz

[root@localhost ~]# cd nagios-3.2.3
[root@localhost nagios-3.2.3]# ./configure(環境的設置)

[root@localhost nagios-3.2.3]# make(編譯)
[root@localhost nagios-3.2.3]# make install(安裝)
[root@localhost nagios-3.2.3]# make install-init(制作/etc/rc.d/ini.d/的啟動方式)
[root@localhost nagios-3.2.3]# make install-commandmode(對目錄權限的限制)
[root@localhost nagios-3.2.3]# make install-config(檢測變量的設置,主要在目錄/usr/local/nagios/etc中)
[root@localhost nagios-3.2.3]# make install-webconf(解決和apache的融合)

3、安裝nagios的功能插件

[root@localhost ~]# ls nagios-plugins-1.4.15.tar.gz
nagios-plugins-1.4.15.tar.gz
[root@localhost ~]# tar zxvf nagios-plugins-1.4.15.tar.gz
[root@localhost nagios-plugins-1.4.15]# ./configure

[root@localhost nagios-plugins-1.4.15]# make;make install
4、安裝中文插件

[root@localhost ~]# ls nagios-cn-3.2.3.tar.bz2
nagios-cn-3.2.3.tar.bz2

[root@localhost ~]# tar jxvf nagios-cn-3.2.3.tar.bz2
[root@localhost nagios-cn-3.2.3]# ./configure

[root@localhost nagios-cn-3.2.3]# make all
[root@localhost nagios-cn-3.2.3]# make install

5、一些基本的配置

[root@localhost ~]# cd /etc/httpd/conf
[root@localhost conf]# vi httpd.conf (加上下邊那句話,php的支持)

AddType applicatio/x-httpd-php .php

[root@localhost ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin(設置管理用戶)

New password:
Re-type new password:
Adding password for user nagiosadmin
[root@localhost ~]# cd /usr/local/nagios/etc/
[root@localhost etc]# chown nagios:nagios htpasswd.users

[root@localhost etc]# chmod g+w htpasswd.users
[root@localhost etc]# cat htpasswd.users
nagiosadmin:QfW0M.KNWetv2
6、測試

[root@localhost ~]# /etc/init.d/nagios restart
[root@localhost ~]# /etc/init.d/httpd restart
[root@localhost ~]# /etc/init.d/sendmail restart
在IE地址欄裡輸入http://ip/nagios 出現提示登錄界面,輸入nagiosadmin 和剛才設置的密碼 登錄即可

下邊說下調試過程中出現的問題

初次安裝nagios用源碼的方式安裝所有所需套件,一直出現莫名的錯誤,只好放棄以後再研究,後來決定試試用系統自帶的apache和sendmail和以yum的方式來安裝php,只用源碼的方式安裝配置nagios的套件,這樣的設置在安裝nagios的core的過程中由於沒make install-webconf,所以一直出現權限的問題(Nagios 請檢查HTTP服務器關於該CGI的訪問權限設置),在網上搜尋說是htpasswd.users的權限的問題可是照做了之後仍然不行,後來就查看/usr/local/nagios/etc/cgi.cfg 中關於管理員用戶的限定,後來發現裡邊限定的是nagiosadmin這個用戶,於是就 htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin,直接設置成這個用戶,再次重啟服務之後刷新頁面,上述的錯位就沒了,由於是新手,在安裝這個套件的過程中一直重復,一直嘗試,得來的結果是進一步了解了它的原理,這裡介紹的只是安裝,下邊要學習的配置才是重點(見 http://www.linuxidc.com/Linux/2011-11/47909.htm ),至於安裝就說到這裡!

Copyright © Linux教程網 All Rights Reserved