cd /root/cactinagioshtml
wget http://jaist.dl.sourceforge.net/project/nagios/nagios/nagios-4.x/nagios-4.0.7/nagios-4.0.7.tar.gzmysql
tar –xf nagios-4.0.7.tar.gzios
cd nagios-4.0.7web
./configure –with-command-group=nagios --prefix=/var/www/html/nagios --enable-event-brokersql
make allapache
make install && make install-init && make install-config ssh
make install-commandmode &&make install-webconf測試
設置登陸web界面時http驗證的帳號密碼:.net
htpasswd -c /var/www/html/nagios/etc/htpasswd.users nagiosadmin插件
安裝nagios-plugins
cd /root/cactinagios
Wget http://nagios-plugins.org/download/nagios-plugins-2.0.2.tar.gz
tar –xf nagios-plugins-2.0.2.tar.gz
cd nagios-plugins-2.0.2
./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/var/www/html/nagios –with-mysql
make
mke install
附apache的配置說明:
找到apache的配置文件:/etc/httpd/httpd.conf
找到:
檢查nagios的配置:
/var/www/html/nagios/bin/nagios -v /var/www/html/nagios/etc/nagios.cfg
添加自動啓動:
chkconfig –add nagios
chkconfig nagios on
service nagios start
登錄頁面:
http://localhost/nagios
nagios客戶端的安裝配置:
cd /yunwei
pssh -h ip.txt "mkdir /yunwei"
pscp -h ip.txt nagios-plugins-2.0.2.tar.gz
pssh -h ip.txt "./configure --prefix=/usr/local/nagios"
pssh -h ip.txt "make && make install"
pssh -h ip.txt "chown nagios:nagios /usr/local/nagios" make install-plugin pssh -h ip.txt "wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz"
tar -xf nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
再次查看nagios-plugins目錄就會發現有5個目錄了;
cat /etc/xinetd.d/nrpe
注意:only_from增長監控端主機的ip地址;
編輯/etc/services 文件,增長NRPE服務
service xinetd restart
能夠看到5566端口已經在監聽了;
使用以下命令,測試客戶端是否正常安裝了nrpe插件
/usr/local/nagios/libexec/check_nrpe -H localhost
在監控端,打開commands.cfg,編輯添加以下內容:
# 'check_nrpe' command definition define command{ command_name check_nrpe # 定義命令名稱爲check_nrpe,在services.cfg中要使用這個名稱. command_line
$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ #這是定義實際運行的插件程序. # 這個命令行的書寫要徹底按照check_nrpe這個命令的用法,不知道用法的就用check_nrpe –h查看. }
-c 後面帶的$ARG1$ 參數是傳給nrpe daemon 執行的檢測命令,以前說過了它必須是nrpe.cfg 中所定義的那5條命令中的其中一條。在services.cfg 中
使用check_nrpe 的時候要用 「!」 帶上這個參數。