天天看点

源代码安装Nagios 4.X

以下为本人翻译installing nagios core from source的作品

目的

     旨在告诉大家在Ubuntu和CentOS服务器下,基于源码如何安装Nagios Core和Nagios Plugins。

目标群众

     对基于想用源代码安装Nagios Core的任何人

先决条件

     对于Ubuntu用户,执行这个文档的所有步骤需要root权限,下面的命令可以切换到root。

     sudo -i

    安装Nagios平台需要安装的包

    对于RHEL/CentOS用户:

    yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

    对于Ubuntu用户:

    sudo apt-get install wget install build-essential apache2 php5-gd wget libgd2-xpm libgd2-xpm-dev

libapache2-mod-php5

下载Nagios Core和Nagios Plugins

    对于所有的系统,在你的终端执行下列命令:

   cd /tmp

    wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.2.tar.

    wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

   这样你就获得Nagios核心包和所需的插件包。

添加Nagios用户和用户组

   为了让Nagios进程可以运行,下一步添加合适的用户和用户组:

   useradd nagios

    groupadd nagcmd

    usermod -a -G nagcmd nagios

    usermod -a -G nagcmd apache

Nagios Core安装    

    tar zxvf nagios-4.0.2.tar.gz 

     tar zxvf nagios-plugins-1.5.tar.gz

    切换到新Nagios目录并安装相应包

    cd nagios

    对于RHEL/CentOS用户:

    ./configure --with-command-group=nagcmd 

    ./configure --with-nagios-group=nagios --with-command-group=nagcmd -–with-mail=/usr/bin/sendmail

    所有的系统<b>:</b>

    make all

     make install 

     make install-init 

     make install-config 

     make install-commandmode 

     make install-webconf 

     cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/

     chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

     /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

     /etc/init.d/nagios start

    /etc/init.d/httpd start        

为Web Access创建一个默认用户

    添加一个默认用户:

     htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Nagios Plugin安装

     cd /tmp/nagios-plugins-1.5 

      ./configure --with-nagios-user=nagios --with-nagios-group=nagios 

      make 

      make install 

Nagios Service安装

      下面的命令将注册Nagios daemon,随着系统一并启动

     chkconfig --add nagios

      chkconfig --level 35 nagios on

      chkconfig --add httpd

      chkconfig --level 35 httpd on

     对于Ubuntu:

      ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Nagios Web Interface

     经过上述的步骤配置,你可以通过Web浏览器去访问:

     http:///nagios

    用户密码认证在你刚刚添加的/usr/local/nagios/etc/htpasswd.users文件里面.

    如果你有任何的疑问,可以访问Nagios的支持论坛如下:

    http://support.nagios.com/forum/

    Nagios Core 文档:

    http://library.nagios.com/library/products/nagioscore/manuals/

继续阅读