手机版
你好,游客 登录 注册
背景:
阅读新闻

RHEL下Nagios安装和配置详解

[日期:2011-08-04] 来源:Linux社区  作者:danny_xcz [字体:大 中 小]

服务器先安装好Apache。

从 http://www.nagios.org 下载以下软件:

  • nagios-3.2.3.tar.gz
  • nagios-plugins-1.4.15.tar.gz
  • nrpe-2.12.tar.gz

安装Nagios Core

  1. #切换到root用户  
  2. su -l  
  3.   
  4. #添加nagios用户  
  5. useradd -m nagios  
  6. passwd nagios  
  7.   
  8. #创建nagcmd组,允许用户在web上执行命令.  
  9. groupadd nagcmd  
  10. usermod -a -G nagcmd nagios  
  11. usermod -a -G nagcmd apache  
  12.   
  13. tar xzvf nagios-3.2.3.tar.gz  
  14.   
  15. cd nagios-3.2.3  
  16.   
  17. ./configure --with-command-group=nagcmd  
  18.   
  19. make all  
  20.   
  21. make install  
  22. make install-init  
  23. make install-config  
  24. make install-commandmode  


configure完成后会显示如下提示

  1. General Options:  
  2. -------------------------  
  3.        Nagios executable:  nagios  
  4.        Nagios user/group:  nagios,nagios  
  5.       Command user/group:  nagios,nagcmd  
  6.            Embedded Perl:  no  
  7.             Event Broker:  yes  
  8.        Install ${prefix}:  /usr/local/nagios  
  9.                Lock file:  ${prefix}/var/nagios.lock  
  10.   Check result directory:  ${prefix}/var/spool/checkresults  
  11.           Init directory:  /etc/rc.d/init.d  
  12.  Apache conf.d directory:  /etc/httpd/conf.d  
  13.             Mail program:  /bin/mail  
  14.                  Host OS:  linux-gnu  
  15.   
  16. Web Interface Options:  
  17. ------------------------  
  18.                 HTML URL:  http://localhost/nagios/  
  19.                  CGI URL:  http://localhost/nagios/cgi-bin/  
  20. Traceroute (used by WAP):  /bin/traceroute  

配置文件目录/usr/local/nagios/etc

修改/usr/local/nagios/etc/objects/contacts.cfg中的邮箱地址为 nagios@xxx.edu.cn。该邮箱设置了过滤规则,所有信件转发到 xxx@139.com

将/root/nagios-3.2.3/sample-config/httpd.conf中的片段拷贝到/usr/local/apache2/conf/httpd.conf中

添加nagiosadmin用户

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

安装Nagios Plugins

  1. tar xzvf nagios-plugins-1.4.15.tar.gz  
  2. cd nagios-plugins-1.4.15  
  3.   
  4. ./configure --with-nagios-user=nagios --with-nagios-group=nagios  
  5.   
  6. make  
  7.   
  8. make install  

命令安装在/usr/local/nagios/libexec/目录下

启动Nagios

  1. chkconfig --add nagios #将nagios添加到服务中  
  2. chkconfig nagios on #开启该服务  
  3. chkconfig --list nagios #查看服务启动状态  
  4.   
  5.   
  6. #检查脚本正确性  
  7. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg  
  8.   
  9. service nagios start  

访问 http://ip/nagios/

安装NRPE

先安装Nagios Plugins,如果是在被监控主机上安装,需要先添加nagios用户。

  1. tar xzvf nrpe-2.12.tar.gz  
  2. cd nrpe-2.12  
  3.   
  4. ./configure  
  5. make all  
  6.   
  7. make install-plugin  


安装NRPE Daemon

NRPE Daemon的端口5666

先按照上一步安装NRPE

  1. make install-daemon  
  2. make install-daemon-config  
  3.   
  4. make install-xinetd  


安装完毕后NRPE的配置文件在/usr/local/nagios/etc/nrpe.cfg

编辑/etc/xinetd.d/nrpe

only_from = 127.0.0.1 #这里只能加一个IP

编辑/etc/services,在最后一行加上

nrpe 5666/tcp # NRPE

重启xinetd服务

service xinetd restart

执行下面命令,检查服务有无正常启动

netstat -at | grep nrpe  #应该出现以下提示 tcp 0 0 *:nrpe *:* LISTEN

测试NRPE Deamon服务

#测试本机 /usr/local/nagios/libexec/check_nrpe -H localhost  #测试远程 /usr/local/nagios/libexec/check_nrpe -H 202.195.160.46  #正常会显示 NRPE v2.12

在监控主机上编辑/usr/local/nagios/etc/objects/commands.cfg,加入下面的command。

  1. define command{  
  2.         command_name  check_nrpe  
  3.         command_line  $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$  
  4. } 

重启监控主机的Nagios服务

service nagios restart
linux
相关资讯       redhat  Nagios 
本文评论   查看全部评论 (1)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 1 楼
* 114 发表于 2011/8/26 11:47:12
您可以试试 美信科技的云网管软件