本文主要描述如何編譯安裝nagios主程序及nagios插件,
安裝依賴包
[root@nagios ~]# yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp unzip
下載相應的nagios core包及插件
[root@nagios ~]# cd /usr/local/src/
[root@nagios src]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.2.tar.gz
[root@nagios src]# wget http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
添加Nagios用戶和用戶組
[root@nagios src]# useradd nagios
[root@nagios src]# groupadd nagcmd
[root@nagios src]# usermod -a -G nagcmd nagios
安裝Nagios的主程序
[root@nagios ~]# tar zxvf nagios-4.2.2.tar.gz
[root@nagios ~]# cd nagios-4.2.2
[root@nagios nagios-4.2.4]# ./configure --with-command-group=nagcmd
[root@nagios nagios-4.2.4]# make all && make install && make install-init && make install-commandmode && make install-config
[root@nagios nagios-4.2.4]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
[root@nagios nagios-4.2.4]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
[root@nagios nagios-4.2.4]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
然后啟動nagios服務進程:
[root@nagios nagios-4.2.4]# /etc/init.d/nagios start
[root@nagios nagios-4.2.4]# /etc/init.d/httpd start
創(chuàng)建nagios web界面的默認用戶
[root@nagios nagios-4.2.4]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
安裝nagios插件
[root@nagios nagios-4.2.4]# cd /usr/local/src/
[root@nagios src]# tar zxf nagios-plugins-2.2.1.tar.gz
[root@nagios src]# cd nagios-plugins-2.2.1
[root@nagios nagios-plugins-2.2.1]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@nagios nagios-plugins-2.2.1]# make && make install
設置nagios服務開機自啟
[root@nagios nagios-plugins-2.2.1]# chkconfig --add nagios
[root@nagios nagios-plugins-2.2.1]# chkconfig --level 35 nagios on
[root@nagios nagios-plugins-2.2.1]# chkconfig --add httpd
[root@nagios nagios-plugins-2.2.1]# chkconfig --level 35 httpd on
訪問nagios:http://<your.nagios.server.ip>/nagios