歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> Unix教程

FreeBSD 7.0上的nagios安裝完全攻略

NagiosFreeBSD

OS:FreeBSD 7.0

到http://www.nagios.org/download/下載所需的軟件包

1.nagios-3.1.2.tar.gz

2.nagios-plugins-1.4.13.tar.gz

系統需求:

1. Apache

2. GCC編譯器

3. GD庫與開發庫

以上軟件安裝好後,開始安裝nagios。

1.解壓縮

#tar zxvf nagios-2.5.tar.gz

2.建立運行nagios的用戶:

#pw adduser nagios

#passwd nagios

3.創建一個用戶組名為nagcmd用於從Web接口執行外部命令。將nagios用戶和apache用戶都加到這個組中。必須確定web服務器以哪個用戶運行的,通常為:apache。我的服務器配置是www。

#grep “^User” /usr/local/apache2/conf/httpd.conf

#pw groupadd nagcmd

#pw usermod www -G nagcmd

#pw usermod nagios -G nagcmd

運行Nagios配置腳本並使用先前開設的用戶及用戶組

# ./configure –prefix=/usr/local/nagios –with-gd-lib=/usr/local/lib –with-gd-inc=/usr/local/include –with-command-group=nagcmd

*** Configuration summary for nagios 3.1.2 06-23-2009 ***:

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

Check result directory: ${prefix}/var/spool/checkresults

Init directory: /usr/local/etc/rc.d

Apache conf.d directory: /etc/httpd/conf.d

Mail program: /usr/bin/mail

Host OS: freebsd7.0

Web Interface Options:

————————

HTML URL: http://localhost/nagios/

CGI URL: http://localhost/nagios/cgi-bin/

Traceroute (used by WAP): /usr/sbin/traceroute

Review the options above for accuracy. If they look okay,

type ‘make all’ to compile the main program and CGIs.

編譯Nagios程序包源碼

#make all

安裝二進制運行程序、初始化腳本、配置文件樣本並設置運行目錄權限

#make install

運行make install-init前請檢查/usr/loca/etc/rc.d的目錄權限。我的服務器是root:wheel.而Makefile中試root:root.

修改Makefile

INIT_DIR=/usr/local/etc/rc.d

INIT_OPTS=-o root -g root

改為:

INIT_DIR=/usr/local/etc/rc.d

INIT_OPTS=-o root -g wheel

然後運行make install-init。

#make install-init

#make install-commandmode

#make install-config

配置WEB接口

安裝Nagios的WEB配置文件到Apache的conf目錄下。Makefile文件中http的路徑是/etc/httpd/conf.d。修改為自己apache的conf路徑。

#make install-webconf

到此nagios核心程序安裝完成!

客戶化配置

樣例配置文件默認安裝在這個目錄下/usr/local/nagios/etc,這些樣例文件可以配置Nagios使之正常運行,只需要做一個簡單的修改…

用你擅長的編輯器軟件來編輯這個/usr/local/nagios/etc/objects/contacts.cfg配置文件,更改email地址nagiosadmin的聯系人定義信息中的EMail信息為你的EMail信息以接收報警內容。

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

配置WEB接口

配置apache的BASIC認證,創建一個nagiosadmin的用戶用於Nagios的WEB接口登錄。記下你所設置的登錄口令,一會兒你會用到它。

#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

然後修改apache的配置文件

#vi /usr/local/apache/conf/httpd.conf

添加如下內容:

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

<Directory “/usr/local/nagios/sbin”>

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName “Nagios Access”

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd.users

Require valid-user

</Directory>

Alias /nagios /usr/local/nagios/share

<Directory “/usr/local/nagios/share”>

Options None

AllowOverride None

Order allow,deny

Allow from all

AuthName “Nagios Access”

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd.users

Require valid-user

</Directory>

修改完畢,保存文件,並重啟apache:

#/usr/local/apahce/bin/apachectl restart

重啟Apache服務以使設置生效。

編譯並安裝Nagios插件

展開Nagios插件的源程序包

#tar xzf nagios-plugins-1.4.13.tar.gz

#cd nagios-plugins-1.4.11

#./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios-plugins

#make

#make install

安裝完成以後在/usr/local/nagios-plugins-plugins會產生一個libexec的目錄,將該目錄全部移動到/usr/local/nagios目錄下即可。

#mv /usr/local/nagios-plugins-plugins/libexec/ /usr/local/nagios/

啟動Nagios

驗證Nagios的樣例配置文件

#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

出現:

Total Warnings: 0

Total Errors: 0

Things look okay – No serious problems were detected during the pre-flight check

配置文件沒有問題。

啟動nagios

#/usr/lcoal/etc/rc.d/nagios start

登錄WEB接口

你現在可以從WEB方式來接入Nagios的WEB接口了,你需要在提示下輸入你的用戶名(nagiosadmin)和口令,你剛剛設置的,這裡用系統默認安裝的浏覽器,用下面這個超鏈接

http://localhost/nagios/如圖:

Copyright © Linux教程網 All Rights Reserved