nagios3.2 安裝筆記

 安裝前的準備工作


nagios-3.2.0.tar.gz  nagios-cn-3.2.0.tar.bz2  nagios-plugins-1.4.14.tar.gz

apache  php


 1. 爲nagios服務建立用戶及用戶組,這裏建立一個nagcmd的用戶組,把nagios用戶和Web執行用戶都加入到這個組裏:

useradd -m nagios && passwd nagios
groupadd nagcmd 
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache

2.編譯安裝

apache編譯安裝

cd /home/src/http

tar zxvf httpd-2.2.11.tar.gz

mv httpd-2.2.11 http

cd http

./configure --prefix=/usr/local/apache2 --enable-so --with-mpm=worker --enable-cache  --enable-mem-cache --enable-disk-cache- -enable-proxy-balancer  --enable-proxy-ajp  --enable-proxy-http   --enable-proxy-ftp   --enable-proxy-connect  --enable-proxy    --enable-ssl   --enable-static-htpasswd --enable-charset-lite --enable-rewrite    --enable-vhost-alias  (可靈活選擇,如無必要,模塊使用越少則越安全,當然不包括安全模塊等特殊模塊。)

make&&make install

/usr/local/apache2/bin/apachectl -t start #啓動apache

打開頁測試ip:80顯示it works表示成功。

##php5.3 
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --with-gd=/usr/local/gd2 --with-libdir=lib64  --enable-track-vars --with-xml --with-mysql --with-zlib-dir=/usr/local 
出錯時Unable to find libgd.(a|so) anywhere under /usr/local/gd2 
#cp /usr/local/gd2/lib/* /usr/local/gd2/

1 ./configure --prefix=/usr/ local /apache2/htdocs/nagios --with-nagios-user=www --with-nagios-group=www --with- command-user=www --with- command -group=www --with-gd-lib=/usr/local /gd2/lib --with-gd-inc=/usr/ local /gd2/include --with-init- dir =/etc/init.d --with-httpd-conf=/usr/ local/apache2/conf/extra
yum install gb gb-devel httpd php
 
tar zxvf nagios-3.2.0.tar.gz
./configure --prefix=/usr/local/nagios
make all
make install
安裝主程序.CGI和HTML文件
make install-init
在/etc/rc.d/init.d目錄下建立nagios的啓動腳本
make install-commandmode
配置目錄權限
make install-config
安裝nagios的配置文件模板,默認路徑是/usr/local/nagios/etc
 
 
tar jxvf nagios-plugins-1.4.14.tar.gz
插件版本號與主版本號關聯不大
./configure --prefix=/usr/local/nagios
make && make install
安裝完成後在/usr/local/nagios/libexec目錄下,生成很多可執行文件
 
tar zxcf nagios-cn-3.2.0.tar.gz
下載地址:http://sourceforge.net/projects/nagios-cn/files/
./configure  --prefix=/usr/local/nagios
默認路徑即爲/usr/local/nagios所以這裏可以不用添加
make all && make install
 
nagios 3.1.X以後版本需有PHP支持
 
 
3.配置apache和php
httpd.conf
----------------
修改
User apache
Group apache
 
Directoryindex index.php
 
AddType application/x-httpd-php .php
 
增加
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin 
<Directory "/usr/local/nagios/sbin">  
AuthType Basic  
Options ExecCGI  
 AllowOverride None  
Order allow,deny  
 Allow from all  
 AuthName "Nagios Access"  
 AuthUserFile /usr/local/nagios/etc/htpasswd   
 Require valid-user  
 </Directory>  

 Alias /nagios /usr/local/nagios/share  
<Directory "/usr/local/nagios/share">    
 AuthType Basic  
Options None  
 AllowOverride None  
Order allow,deny  
 Allow from all  
 AuthName "nagios Access" 
 AuthUserFile /usr/local/nagios/etc/htpasswd   
Require valid-user  
</Directory>

copy時應注意:
空格字符必須時英文半角
否則啓動時啓動時會報如下錯誤
Invalid command '\xe3\x80\x80\xe3\x80\x80', perhaps mis-spelled or defined by a module not included in the server configuration


4.對web目錄作認證
htpasswd -c /usr/local/nagios/etc/htpasswd admin

5.啓動apache
 apachectl start

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
NRPE的部署
 
NagisoCore----plugin----Nrpe----|-----(SSL)------|----plugin(Ntclient++)---Nrpe
 
NRPE的安裝
1.新建用戶 
useradd -s /usr/sbin/nolgin nagios
 
2.安裝plugin
./configure --prefix=/usr/local/nagios&&make && make install
 
3.安裝NRPE
./confugure --prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
 
4.配置NRPE
vim  /usr/local/nagios/etc/nrpe.cfg 
修改
server_address=127.0.0.1,192.168.10.99(本地)
allowed_address=127.0.0.1,192.168.10.234(遠程)
 
5.啓動守護進程
/usr/local/nagios/bin/nrpe -c /usr/loacl/nagios/etc/nrpe.cfg -d
可以將以上命令加入到rc.local開機自動啓動
 
6.檢查
netstat -antl |grep 5666
 
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章