nagios服务配置

yum -y install  httpd mysql-server php php-mysql


4526  useradd nagios
4527  groupadd nagcmd
4528  usermod -G nagcmd nagios
4529  usermod -G nagcmd apache
4525  tar -zxvf nagios-3.2.0.tar.gz
4530  cd nagios-3.2.0
运行Nagios配置脚本并使用先前开设的用户及用户组:

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

configure: creating ./config.status
config.status: creating Makefile
config.status: creating subst
config.status: creating pkginfo
config.status: creating base/Makefile
config.status: creating common/Makefile
config.status: creating contrib/Makefile
config.status: creating cgi/Makefile
config.status: creating html/Makefile
config.status: creating module/Makefile
config.status: creating xdata/Makefile
config.status: creating daemon-init
config.status: creating t-tap/Makefile
config.status: creating include/config.h
config.status: creating include/snprintf.h
config.status: creating include/cgiutils.h

Creating sample config files in sample-config/ ...


*** Configuration summary for nagios 3.2.0 08-12-2009 ***:

General Options:
-------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
            Embedded Perl:  no
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
                Lock file:  ${prefix}/var/nagios.lock
   Check result directory:  ${prefix}/var/spool/checkresults
           Init directory:  /etc/rc.d/init.d
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /bin/mail
                  Host OS:  linux-gnu

Web Interface Options:
------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):  /bin/traceroute


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.


编译Nagios程序包源码

make all
======================================
*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

  make install
     - This installs the main program, CGIs, and HTML files

  make install-init
     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs *SAMPLE* config files in /usr/local/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     - This installs the Apache config file for the Nagios
       web interface


*** Support Notes *******************************************

If you have questions about configuring or running Nagios,
please make sure that you:

     - Look at the sample config files
     - Read the HTML documentation
     - Read the FAQs online at http://www.nagios.org/faqs

before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you.  This might include:

     - What version of Nagios you are using
     - What version of the plugins you are using
     - Relevant snippets from your config files
     - Relevant error messages from the Nagios log file

For more information on obtaining support for Nagios, visit:

       http://www.nagios.org/support/

*************************************************************

Enjoy.

[root@localhost /usr/local/src/nagios-3.2.0]#
======================================

安装二进制运行程序、初始化脚本、配置文件样本并设置运行目录权限

make install
====================================
*** Main program, CGIs and HTML files installed ***

You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

  make install-init
     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs sample config files in /usr/local/nagios/etc

make[1]: Leaving directory `/usr/local/src/nagios-3.2.0'
[root@localhost /usr/local/src/nagios-3.2.0]#
=====================================
make install-init
make install-config
make install-commandmode



现在还不能启动Nagios-还有一些要做的...

4)客户化配置

样例配置文件默认安装在这个目录下/usr/local/nagios/etc,这些样例文件可以配置Nagios使之正常运行,只需要做一个简单的修改...

用你擅长的编辑器软件来编辑这个/usr/local/nagios/etc/objects/contacts.cfg配置文件,更改email地址nagiosadmin的联系人定义信息中的EMail信息为你的EMail信息以接收报警内容。

vi /usr/local/nagios/etc/objects/contacts.cfg

5)配置WEB接口

安装Nagios的WEB配置文件到Apache的conf.d目录下

make install-webconf

创建一个nagiosadmin的用户用于Nagios的WEB接口登录。记下你所设置的登录口令,一会儿你会用到它。

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

重启Apache服务以使设置生效。

service httpd restart

6)编译并安装Nagios插件

展开Nagios插件的源程序包

cd ~/downloads tar xzf nagios-plugins-1.4.11.tar.gz cd nagios-plugins-1.4.11

编译并安装插件

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

7)启动Nagios

把Nagios加入到服务列表中以使之在系统启动时自动启动

chkconfig --add nagios chkconfig nagios on

验证Nagios的样例配置文件

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

如果没有报错,可以启动Nagios服务

service nagios start

8)更改SELinux设置

Fedora与SELinux(安全增强型Linux)同步发行与安装后将默认使用强制模式。这会在你尝试联入Nagios的CGI时导致一个"内部服务错误"消息。

如果是SELinux处于强制安全模式时需要做

getenforce

令SELinux处于容许模式

setenforce 0

如果要永久性更变它,需要更改/etc/selinux/config里的设置并重启系统。

不关闭SELinux或是永久性变更它的方法是让CGI模块在SELinux下指定强制目标模式:

chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/ chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

更多有关Nagios的CGI模块增加目标策略的强制权限方式见NagiosCommunity.org的维基百科 http://www.nagioscommunity.org/wiki。

9)登录WEB接口

你现在可以从WEB方式来接入Nagios的WEB接口了,你需要在提示下输入你的用户名(nagiosadmin)和口令,你刚刚设置的,这里用系统默认安装的浏览器,用下面这个超链接

http://localhost/nagios/

点击“服务详情”的引导超链来查看你本机的监视详情。你可能需要给点时间让Nagios来检测你机器上所依赖的服务因为检测需要些时间。

10)其他的变更

确信你机器的防火墙规则配置允许你可以从远程登录到Nagios的WEB服务。

配置EMail的报警项超出了本文档的内容,指向你的系统档案用网页查找或是到这个站点NagiosCommunity.org wiki来查找更进一步的信息,以使你的系统上可以向外部地址发送EMail信息。更多有关通知的信息可以查阅这篇文档。 更多内容可访问www.xinqiaoren.com

你可能感兴趣的:(linux,职场,nagios,休闲)