在rhel6下安裝nagios
我安裝的時候選擇的是這幾個包。
nagios-3.4.3.tar.gz、nagios-plugins-1.4.14.tar.gz、nrpe-2.12.tar.gz
因爲其他的包太難下載了。國外的網站,你懂的。
服務端:
需要安裝nagios 和nagios-plugins nrpe。安裝之前要把編譯環境都安裝好了。比如gcc之類的。
通過本地yum源,安裝開發環境。
yum groupinstall “Development tools”
openssl不知道是不是開發工具裏面的。
安裝之前要創建相應的用戶和組
#groupadd -g 6000 nagios
#groupadd -g 6001 nagcmd
#useradd -u 6000 -g nagios -G nagcmd -d /home/nagios nagios
安裝nagios。首先解壓。打開。然後./configure –help一下。
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd --enable-event-broker --enable-nanosleep --enable-embedded-perl --with-perlcache
然後開始make
make all
make install
make install-init
make install-commandmode
make install-webconf
make install-config
如果要nagios和apache一起使用。那麼就要配置apache了。
需要配置php。
vim httpd.conf
AddType application/x-httpd-php .php
DirectoryIndex index.html index.html.var index.php
#然後要添加nagios的目錄
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType basic
Authuserfile /usr/local/nagios/etc/.htpasswd.users
Require valid-user
</Directory>
ScriptAlias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AllowOverride None
Options None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType basic
Authuserfile /usr/local/nagios/etc/.htpasswd.users
Require valid-user
</Directory>
還要更改apache的附屬組
usermod -a -G nagios:nagcmd apache
完成之後就可以重啓服務。然後進入http://localhost/nagios
訪問了
service httpd restart
service nagios restart
chkconfig httpd on
chkconfig --add nagios
chkconfig nagios on
打開之後可以看到在監控本機。
現在添加一個linux用於監控
被監控端:
要安裝nagios-pligins 和nrpe即可
安裝之前要建用戶建組和上面的差不多。
先安裝nagios-plugins
安裝的時候指定用戶 組 命令組 和安裝路徑
然後make ;make install-plugin; make install-daemon;make install-daemon;make install-daemon-config
重啓
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d " >>/etc/rc.d/rc.local
然後在監控端 開啓一個object 把裏面localhost.cfg複製一份。然後進行修改。把ip地址什麼的改了。然後測試一下有沒有出錯。
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
然後重新啓動。然後在網頁裏面就可以看到了。
總結
nagios的基本安裝不難。但是要開發監控插件還是有點複雜。
需要了解nagios的文件結構。
比如nagios.cfg這個主配置文件裏面。可以看到其他要加載的配置文件的信息。
其他配置文件都可以很靈活的配置。比如把localhost拷貝一份,稍微修改一下。就可以作爲被控端的。
其他等日後再詳細補充。