一、nagios 安装

 

    Nagios可以运行在各种版本的linux及主流的unix环境,我的环境有Redhat5.4来部署nagios的。安装完操作系统之后,需要把多余的服务都关掉,只留sshd这个服务。

安装前的准备工作

1.建用户和组

 

[root@localhost ~]# useradd -m nagios

[root@localhost ~]# groupadd nagcmd

[root@localhost ~]# usermod -a -G nagcmd nagios

[root@localhost ~]# usermod -a -G apache nagios

2.安装:安装过程中会用到的一些服务和软件安装

[root@localhost ~]#yum groupinstall "Development Libraries" "Development Tools" "Legacy Software Development" "X Software  Development" -y

[root@localhost ~]# yum install gcc glibc glibc-devel  glibc-common gd gd-devel –y

 

[root@localhost ~]# yum install httpd httpd-devel php -y

3.安装nagios-3.4.1.tar.gz

 

[root@localhost ~]# tar -zvxf nagios-3.4.1.tar.gz

[root@localhost ~]#cd nagios

[root@localhost nagios]#./configure  --prefix=/usr/local/nagios --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd- inc=/usr/include     ----运行Nagios配置脚本,并                                                                          把nagcmd更改为之前所创建的组

[root@localhost nagios]# make all

[root@localhost nagios]# make install

[root@localhost nagios]# make install-init

[root@localhost nagios]# make install-commandmode

[root@localhost nagios]# make install-config

[root@localhost nagios]# make install-webconf

 

[root@localhost ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin      

   --为nagios增添用户nagiosadmin 并设密码。(此时为登录nagiosweb页面而用,并非先前建立的nagios)

 

[root@localhost ~]# chkconfig --add nagios

[root@localhost ~]# chkconfig nagios on

[root@localhost ~]# chkconfig httpd on

           ---做的开机启动

、编译安装Nagios插件nagios-plugins-1.4.16.tar.gz

 

 

 

[root@localhost ~]# tar -zxvf nagios-plugins-1.4.16.tar.gz

[root@localhost ~]# cd nagios-plugins-1.4.16

[root@localhost nagios-plugins-1.4.16]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios

[root@localhost nagios-plugins-1.4.16]# make

[root@localhost nagios-plugins-1.4.16]# make install

 

[root@localhost ~]# service nagios start

Starting nagios: done.

[root@localhost ~]# service httpd start

启动 httpd[确定]

[root@localhost ~]#

到此时已安安装完。

用ie用测试http://192.168.111.105/nagios    如下图: