一、安裝nagios前的準(zhǔn)備工作
我們提供的服務(wù)有:成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、華州ssl等。為千余家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的華州網(wǎng)站制作公司
1.解決安裝Nagios的依賴關(guān)系:Nagios基本組件的運(yùn)行依賴于httpd、gcc和gd
2. 所需要安裝組件:
服務(wù)端所用的安裝包為 nagios nagios-plugins
linux客戶端 nrpe
windows客戶端 NSClient++
二.下載需求軟件
nagios主程序:wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
nagios插件程序:wget http://down1.chinaunix.net/distfiles/nagios-plugins-1.4.13.tar.gz
apache程序:wget http://autosetup1.googlecode.com/files/httpd-2.2.11.tar.gz
php程序:wget http://museum.php.net/php5/php-5.3.0.tar.gz
三.編譯安裝nagios
1.tar zxf nagios-3.1.2.tar.gz
[root@localhost nagios-3.1.2]# cd nagios-3.1.2
[root@localhost nagios-3.1.2]#./configure --enable-event-broker--prefix=/usr/local/nagios
[root@localhost nagios-3.1.2]#make all
[root@localhost nagios-3.1.2]#make install
[root@localhost nagios-3.1.2]#make install-init
[root@localhost nagios-3.1.2]#make install-config
[root@localhost nagios-3.1.2]#make install-commandmode
在httpd的配置文件目錄(conf.d)中創(chuàng)建Nagios的Web程序配置文件:
[root@localhost nagios-3.1.2]#make install-webconf
創(chuàng)建一個(gè)登錄nagiosweb程序的用戶,這個(gè)用戶帳號(hào)在以后通過web登錄nagios認(rèn)證時(shí)所用:
# htpasswd -c/var/www/nagios/etc/htpasswd.users nagiosadmin
2.編譯安裝nagios-plugins
nagios的所有監(jiān)控工作都是通過插件完成的,因此,在啟動(dòng)nagios之前還需要為其安裝官方提供的插件。
tar zxf nagios-plugins-1.4.13.tar.gz
[root@localhost nagios-plugins-1.4.13]#cd nagios-plugins-1.4.13
[root@localhost nagios-plugins-1.4.13]#./configure --with-nagios-user=nagios --with-[root@localhost nagios-plugins-1.4.13]#nagios-group=nagios -with-MySQL
[root@localhost nagios-plugins-1.4.13]#make
[root@localhost nagios-plugins-1.4.13]#make install
4.配置并啟動(dòng)Nagios
/etc/init.d/nagios start
注:如果啟動(dòng)時(shí)會(huì)報(bào)錯(cuò)
Error: Cannot open main configuration file '/root/nagios-plugins-1.4.13/start' for reading!
Nagios 3.1.2 starting... (PID=14327)
Local time is Fri Feb 28 02:52:22 CST 2014
Bailing out due to one or more errors encountered in the configuration files. Run Nagios from the command line with the -v option to verify your config before restarting. (PID=14327)
使用: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg檢查配置文件沒有發(fā)現(xiàn)錯(cuò)誤
可使用:/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg 嘗試啟動(dòng)
啟動(dòng)成功之后 可以使用top命令查看是否有nagios進(jìn)程(有nagios進(jìn)程說明啟動(dòng)成功)
注: service nagios restart 啟動(dòng)時(shí)再次失敗
Running configuration check...done.
Stopping nagios: done.
Starting nagios:su: warning: cannot change directory to /home/nagios: No such file or directory
This account is currently not available.
done.
可以使用: mkdir /home/nagios 解決
service nagios restart 如果啟動(dòng)時(shí)仍然失敗 但錯(cuò)誤提示是:
Running configuration check...done.
Stopping nagios: done.
Starting nagios:This account is currently not available.
done.
可以在:vi /etc/passwd
找到此行:nagios:x:500:500::/home/nagios:/sbin/nologin(注意紅色字體),把此行改成如下一行
nagios:x:500:500::/home/nagios:/bin/bash
修改后再次重啟 ,啟動(dòng)成功
[root@localhost nagios-3.1.2]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.