** 使用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.
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 ]
* 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
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 中
** 在最后加上下面这段
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
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
相关推荐
Nagios是一款强大的开源系统监控工具,主要用于监测网络服务、主机和各种系统资源的状态。它由Nagios Core和一...通过以上书籍,读者可以更全面地了解Nagios的安装、配置、使用和维护,提升在IT运维领域的专业技能。
- **主要内容**:提供了超过 100 个实战案例,涵盖 Ubuntu Server 的安装、配置、管理等多个方面。 - **章节结构**:从基础入门到高级应用,逐步深入讲解。 - **实践意义**:通过实际操作来学习和掌握 Ubuntu Server...
在Ubuntu或Debian系统中,可以通过`sudo apt-get install haproxy`命令来安装。安装完成后,需要编辑HAProxy的配置文件`/etc/haproxy/haproxy.cfg`。 配置文件中,`global`部分定义了HAProxy的一些全局设置,如日志...
本《Linux网站建设技术指南》将深入探讨Linux系统下如何搭建、管理和优化网站,为开发者和运维人员提供宝贵的实战经验。 首先,我们需要了解Linux的基础知识。Linux是一种自由和开放源代码的操作系统,其中最常用的...
1. **选择合适的版本**:根据需求选择合适的Linux发行版,例如Ubuntu、CentOS或Debian等。 2. **创建安装介质**:使用USB闪存驱动器或光盘来制作启动盘。 3. **配置BIOS/UEFI**:进入计算机的BIOS/UEFI设置,将启动...
7. **监控与报警**:Zabbix、Nagios等监控工具的安装与配置,实现对系统状态的实时监控。 通过这两本书的学习,读者不仅可以了解Linux的基础知识,还能掌握实际操作技能,为成为合格的Linux系统管理员打下坚实基础...