实战ubuntu安装nagios

 

**  使用nagios的前提是你已经正常的安装了apache

 

1. 安装nagios

写道
sudo apt-get install nagios3

    **  安装过程中需要你输入一个邮箱地址,同时设置 nagios web 的登录密码 (初始帐号: nagiosadmin)

 

2. 查看安装版本

  

写道

 

xiaofei@xiaofei-O-E-M:~$ nagios3 --version

Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL

Website: http://www.nagios.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 3. 启动nagios

 

写道

 

xiaofei@xiaofei-O-E-M:~$ sudo /etc/init.d/nagios3 start
* Starting nagios3 monitoring daemon nagios3
* already running! [ OK ]

4.  进入

 

写道

 

http://localhost/nagios3  (nagiosadmin/第一步中设置的密码)

 

5.  为nagios添加一些有用的插件 (参考 )

http://www.williamsang.com/archives/2060.html 

**  上面链接在添加 pnp4nagios插件时,使用时会出现404错误 ,我这里需要 手动添加其apache.conf到/etc/apache2/conf-*下面去

 

写道

 

cd /etc/apache2/conf-available
sudo ln -sf ../../pnp4nagios/apache.conf pnp4nagios.conf

cd /etc/apache2/conf-enabled
sudo ln -sf ../conf-available/pnp4nagios.conf pnp4nagios.conf

 

6.  查看 localhost信息



 7.  如何查看 使用 check_http 来监控 (本机地址(监控机): 10.10.10.145 ,  被监控机 : 10.10.10.146 , 10.10.10.147)

 

首先 我们重定义一个 bbt_check_http 

 

写道

 

cd /etc/nagios3/

** 在最后加上下面这段

define command{
        command_name    bbt_check_http
        command_line       $USER1$/check_http -H $HOSTNAME$ -I $HOSTADDRESS$ -p $ARG1$ -u $ARG2$ -w $ARG3$ -c $ARG4$ -t $ARG5$
}


** USER1 是预定义宏变量 , 其定义在 resource.cfg 中

 

接着我们开始定义对146,147机器的监控代码 

 

写道
cd /etc/nagios3/conf.d/

sudo touch u146.cfg

sudo vim u146.cfg

 

define host{
        use                     generic-host            ; Name of host template to use
        host_name         10.10.10.146
        alias                    u146
        address               10.10.10.146
        }


define service{
        use                                generic-service
        host_name                    10.10.10.146
        service_description       http://10.10.10.146:8000/
        check_command           bbt_check_http!8000!'/'!10!20!30
        }

 

 **  147 的定义同 上面 146  ,  在这里曾经走了不少弯路,开始一直在 bbt_check_http 这里加上 被控机器 的IP,结果一直不成功, 后来才知道 宏定义的变量 只需要在 define host里定义后此处就不需要了

 

参考 :  http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=26660567&id=3810304

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值