1. 程式人生 > 實用技巧 >nagios3.3 監控端安裝記錄

nagios3.3 監控端安裝記錄

現在回過頭來看第一次安裝nagios的記錄,發現安裝真的很簡單,自己的安裝記錄顯得很簡單。由於要生產環境應用,所以學了點nagios的東西,在google、baidu也search了很多,發現internet上的也是以安裝的介紹居多,自己的安裝記錄相比較就差了許多,不過也懶,不想該了,將在下篇blog寫下自己對nagios configure的理解,網上這方面介紹較少。

==========================================

這是nagios的監控端配置,被監控端配置將在下篇blog記錄,本人將在應用中不斷修改本篇blog。

nagios的介紹就不羅嗦了,直接看安裝:

1、 安裝前環境

OS:centos5.4 關閉selinux

httpd、php、gcc、gd、glibc、ssl(openssl和openssl-devel)

[email protected]:[/usr/local/nagios]rpm -qa | grep ssl
openssl-0.9.8e-12.el5
openssl097a-0.9.7a-9.el5_2.1
openssl-devel-0.9.8e-12.el5

其實apache不需要到網路上下載,在linux OS 的安裝包裡就有,在上面忘了說明,安裝httpd*.rpm一些包就可以了,另外在安裝rpm包的時候,如果碰到A依賴B,B依賴C,而C又依賴A的時候,在rpm -ivh C.rpm --nodeps 即可安裝。

關閉selinux

在命令列:#setenforce 0
在修改/etc/seliunx/config 中 SELINUX=disabled

在chkconfig --level 345 selinux off

下載檔案

建立使用者並設定密碼:

/usr/sbin/useradd -m nagios
passwd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache

安裝apache

檢查有沒有apache使用者

啟動apache的服務,並輸入http://IP ,如果出現“IT WORKS” ,apache安裝沒有問題。

2、 安裝

nagios安裝

44 tar -xzf nagios-3.3.1.tar.gz
45 ls
46 cd ./nagios
47 ls
48 less INSTALLING
49 ls ./html/
50 ls ./html/docs/
51 less INSTALLING
52 ./configure --with-command-group=nagcmd
53 make all
54 make install
55 make init
56 make install-init
57 make install-commandmode
58 make install-config
59 make install-webconf
65 make install-exfoliation
66 make install-classicui

中間去掉了一些不要的步驟。

配置web登陸使用者名稱和密碼
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

記住這個密碼,是登入web nagios時的使用者名稱和密碼

nagios-plugin 安裝

84 tar -xzf nagios-plugins-1.4.15.tar.gz
85 ls
86 cd ./nagios
87 cd ../nagios-plugins-1.4.15
88 ls
89 ./configure --with-nagios-user=nagios --with-nagios-group=nagios
90 make all
91 make install

nrpe 安裝
94 tar -xzf nrpe-2.13.tar.gz
95 ls
96 cd ./nrpe-2.13
130 ./configure --enable-ssl --enable-command-args
131 make all
132 make install
133 make install-plugin
134 make install-daemon
135 make install-daemon-config
中間缺失的步驟是處理ssl的問題。

vi ./etc/objects/commands.cfg 新增如下內容:

define command{
command_name check_nrpe
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

3、 初步配置

配置為服務啟動

145 chkconfig --add nagios
146 chkconfig --level 345 nagios on

測試nagios 配置檔案是否正確

147 ./bin/nagios -v ./etc/nagios.cfg
出現
Total Warnings: 0
Total Errors: 0

說明nagios 配置沒有問題

修改windwos監控模板

vi /usr/local/nagios/etc/nagios.cfg
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg 去掉#

先重啟httpd:

176 killall httpd
177 /etc/init.d/httpd start

啟動nagios服務:

./bin/nagios -d ./etc/nagios.cfg

發現一個有趣的事情:如果用/usr/local/apache2/bin/httpd 啟動,即預設呼叫/usr/local/apache2/conf/httpd.conf時,無法開啟http://ip/nagios

必須用/etc/init.d/httpd start啟動,呼叫/etc/httpd/conf/httpd.conf啟動,此時目錄改變為:/var/www/html。檢視/etc/init.d/httpd的內容如下:

#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
這時nagios啟動正常。以上原因可能是在安裝nagios時,make install-webconf生產有/etc/httpd目錄及配置。不過我沒驗證過,只是猜測!呵呵

用nagiosadmin和設定的密碼登入:http://ip/nagios

轉載於:https://blog.51cto.com/heliy/745753