没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
誉天Cisco / RHCE / RHCA 认证 www.51chongdian.net/bbs
誉天思科红帽授权培训考试中心 www.yutianedu.com
Linux 系统监控之 Nagios 配置教程详解(赵舜东)
实验目的:通过实验熟练掌握 Nagios 这个开源的监控解决方案的实施。
实验环境:Red Hat Enterprise Linux +nagios.3.2.0
实验步骤:
第一部分:Linux 系统监控之 Nagios 详解(一)
一、Nagios 简介
(一)什么是 Nagios,Nagios 有哪些特性。
(二)Nagios 工作原理
二、部署 Nagios 监控服务器
(一)下载所需软件包
(二)安装 Nagios
(三)安装 Nagios 的插件 nagios-plugin
(四)配置检测主机是否存活
(五)第一部分功能测试
第二部分:Linux 系统监控之 Nagios 详解(二)
三、使用 Nagios 监控 Linux 客户端
(一)Nagios 监控服务器的配置
(二)Nagios 监控客户端的配置
四、使用 Nagios 监控 Windows 客户端
(一)Nagios 监控服务器的配置
(二)Nagios 监控客户端的配置
第三部分:Linux 系统监控之 Nagios 详解(三)
五、Nagios 配置文件详解
实验简介:公司进行了机房改造,新系统也上线了,需要一个强大的监控方案,对服务器和各服务的运行情况进行有效的
监控,我第一个想到的就是 Nagios 这个强大的开源解决方案,本文以监控八台服务器和 Nagios 服务器本身为例。根据先
实现、后深入的方式,把本文分为三个部分,开始先实现了功能, 在第三个部分,在对配置的内容进行详细的讲解,
功能实现:实现 Web 浏览器监控,Mail 报警邮件收发,手机短信收发。手机短信怎么收发呢?网上有很多很多的方法,
我推荐一种就是使用 139 信箱,139 信箱有一项免费的功能就是发邮件通知到您的手机上,可以在手机上看邮件内容,免
费的哦。什么?还没有 139 信箱,那么别傻呆了,系统运维必备的信箱,快免费申请吧。
本作品为本站原创作品,如需转载请注明来自UnixHot 技术联盟 实验答疑:zhaoshundong@hotmail.com
誉天Cisco / RHCE / RHCA 认证 www.51chongdian.net/bbs
一、Nagios 简介
官方网站:http://www.nagios.org/ (更多的详细说明请参考官方网站)
Nagios® is a system and network monitoring application. It watches hosts and services that you specify,
alerting you when things go bad and when they get better.Nagios was originally designed to run under Linux,
although it should work under most other unices as well.
Some of the many features of Nagios include:
1.Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.) 监控网络资源
2.Monitoring of host resources (processor load, disk usage, etc.) 监控主机资源
3.Simple plugin design that allows users to easily develop their own service checks
4.Parallelized service checks
5.Ability to define network host hierarchy using "parent" hosts, allowing detection of and distinction
between hosts that are down and those that are unreachable
6.Contact notifications when service or host problems occur and get resolved (via email, pager, or
user-defined method)
7.Ability to define event handlers to be run during service or host events for proactive problem resolution
8.Automatic log file rotation 自动日志轮滚
9.Support for implementing redundant monitoring hosts 支持冗余
10.Optional web interface for viewing current network status, notification and problem history, log file,
etc.
请参考Nagios 中文在线帮助文档:http://www.itnms.net/docs/nagios/cn/build/html/index.html
二、部署 Nagios 监控服务器
(一)下载所需软件包
1.nagios.3.2.0.tar.gz Nagios 的主程序
[root@UnixHot src]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios.3.2.0.tar.gz
2.nagios-plugins-1.4.13.tar.gz Nagios 的插件
[root@UnixHot src]# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
3.nrpe-2.12.tar.gz 代理检测程序
[root@UnixHot src]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
[root@UnixHot src]# ls
nagios-3.2.0.tar.gz nagios-plugins-1.4.13.tar.gz nrpe-2.12.tar.gz
誉天思科红帽授权培训考试中心 www.yutianedu.com
誉天Cisco / RHCE / RHCA 认证 www.51chongdian.net/bbs
誉天思科红帽授权培训考试中心 www.yutianedu.com
(二)安装 Nagios
官方的安装文档:http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html
1.安装前的依赖检查
[root@UnixHot ~]# rpm -q httpd php gcc glibc glibc-common gd gd-devel
2.创建 Nagios 账户和组
[root@UnixHot src]# useradd -m nagios
[root@UnixHot src]#groupadd nagcmd
[root@UnixHot src]# usermod -a -G nagcmd nagios
[root@UnixHot src]#usermod -a -G nagcmd apache
3.编译安装
[root@UnixHot src]# tar xvf nagios-3.2.0.tar.gz
[root@UnixHot src]# cd nagios-3.2.0
(至于每一步的具体意思,我不再详述,因为运行完毕后,提示信息会明确的告诉你,它干了什么,是怎么干的。当然,
还有一个最好的办法,就是看 Makefile 文件,里面都会有注释的。 )
参考 Makefile 文件
[root@UnixHot nagios-3.2.0]# less Makefile
[root@UnixHot nagios-3.2.0]# ./configure --with-command-group=nagcmd \
--with-nagios-user=nagios \
--with-nagios-group=nagios
[root@UnixHot nagios-3.2.0]# make all
[root@UnixHot nagios-3.2.0]# make install
[root@UnixHot nagios-3.2.0]# make install-init (生成 init 启动脚本)
[root@UnixHot nagios-3.2.0]# make install-config (生成一些模板配置文件)
[root@UnixHot nagios-3.2.0]# make install-commandmode (设置相应的权限)
[root@UnixHot nagios-3.2.0]# make install-webconf (生成 Apache 配置文件 nagios.conf)
4.为 Nagios 设置 Web 验证的密码。
(注意第一次添加用户用-c 选项,以后再添加千万别在用这个选项了,会覆盖以前的所有用户的,这点之时在《RHCE 考
前冲刺》我已经讲过了。)
誉天Cisco / RHCE / RHCA 认证 www.51chongdian.net/bbs
誉天思科红帽授权培训考试中心 www.yutianedu.com
[root@UnixHot nagios-3.2.0]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
5.设置 Nagios 的开机启动
[root@UnixHot ~]# chkconfig --add nagios
[root@UnixHot ~]# chkconfig nagios on
6.修改 SELinux
两种方法:
第一种最直接,关闭 SELinux,对于 SELinux 不是很熟悉的用户,请选择此。
[root@UnixHot nagios-3.2.0]# cat /etc/sysconfig/selinux
SELINUX=disabled
第二种给打上正确的安全脉络。
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
(三)安装 Nagios 的插件 nagios-plugin
插件是 Nagios 扩展功能的强大武器,一般好的软件,都支持插件扩展,你可以根据实际的应用,自己开发插件。
[root@UnixHot src]# tar xvf nagios-plugins-1.4.13.tar.gz
[root@UnixHot src]# cd nagios-plugins-1.4.13
[root@UnixHot nagios-plugins-1.4.13]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios
--with-nagios-group=nagios
[root@UnixHot nagios-plugins-1.4.13]# make && make install
(四)配置检测主机是否存活
1.配置文件概述
如果安装上面的步骤,安装完成后,配置文件在安装时放在了/usr/local/nagios/etc/目录下
[root@UnixHot ~]# cd /usr/local/nagios/etc
[root@UnixHot etc]# ls -l
-rw-rw-r-- 1 nagios nagios 11408 08-30 11:55 cgi.cfg (CGI 配置文件)
-rw-r--r-- 1 root root 26 08-30 11:56 htpasswd.users (Apache 的验证密码文件)
誉天Cisco / RHCE / RHCA 认证 www.51chongdian.net/bbs
誉天思科红帽授权培训考试中心 www.yutianedu.com
-rw-rw-r-- 1 nagios nagios 43776 08-30 11:55 nagios.cfg (主配置文件)
drwxrwxr-x 2 nagios nagios 4096 08-30 11:55 objects (对象定义文件目录)
-rw-rw---- 1 nagios nagios 1340 08-30 11:55 resource.cfg (资源配置文件)
我们修要修改的的是 nagios.cfg 和 objects 目录下的文件,来检测主机是否存活。
2.主配置文件 nagios.cfg 的配置。
主配置文件的内容很多,对于这个版本,我们需要修改和添加的主要是对象配置文件,即:cfg_file=<file_name>
cfg_file=/usr/local/nagios/etc/objects/commands.cfg (命令定义文件)
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg (联系人信息定义文件)
cfg_file=/usr/local/nagios/etc/objects/contactgroups.cfg (添加此行 联系人组定义文件)
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg (添加此行 主机定义文件)
cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg (添加此行 主机组定义文件)
cfg_file=/usr/local/nagios/etc/objects/services.cfg (添加此行 服务定义文件)
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg (时间周期定义文件)
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg (注释掉此行)
3.主机定义文件的配置。
[root@UnixHot etc]# vi objects/hosts.cfg
define host{
host_name Nagios-Server
alias Nagios Server
address 192.168.0.206
check_command check-host-alive
check_interval 5
retry_interval 1
max_check_attempts 5
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0
contact_groups sagroup
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
剩余20页未读,继续阅读
资源评论
素还真7784877
- 粉丝: 25
- 资源: 129
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 课程设计-python爬虫-爬取日报,爬取日报文章后存储到本地,附带源代码+课程设计报告
- 软件和信息技术服务行业投资与前景预测.pptx
- 课程设计-基于SpringBoot + Mybatis+python爬虫NBA球员数据爬取可视化+源代码+文档+sql+效果图
- 软件品质管理系列二项目策划规范.doc
- 基于TensorFlow+PyQt+GUI的酒店评论情感分析,支持分析本地数据文件和网络爬取数据分析+源代码+文档说明+安装教程
- 软件定义无线电中的模拟电路测试技术.pptx
- 软件开发协议(作为技术开发合同附件).doc
- 软件开发和咨询行业技术趋势分析.pptx
- 软件测试题详解及答案.doc
- 软件漏洞生命周期管理策略.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功