编译安装nagios

本文主要描述如何编译安装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

创建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:///nagios

你可能感兴趣的:(编译安装nagios)