** 使用nagios的前提是你已经正常的安装了apache
1. 安装nagios
** 安装过程中需要你输入一个邮箱地址,同时设置 nagios web 的登录密码 (初始帐号: nagiosadmin)
2. 查看安装版本
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
* Starting nagios3 monitoring daemon nagios3
* already running! [ OK ]
4. 进入
5. 为nagios添加一些有用的插件 (参考 )
http://www.williamsang.com/archives/2060.html
** 上面链接在添加 pnp4nagios插件时,使用时会出现404错误 ,我这里需要 手动添加其apache.conf到/etc/apache2/conf-*下面去
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
** 在最后加上下面这段
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机器的监控代码
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