版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Nagios监控操作手册操作系统:suse10、suse10.3,融创天下测试运维部,陈建红 2008-12-10,大纲, Nagios简介 Nagios服务器端的安装 Nagios被监控端的安装 功能配置 Nagios的应用,Nagios 简介,Nagios监控采用的是一对多的模式。 即由一台主服务器去检测多台客户端,主服 务器端获得各客户端的状态后,以网页的形式显 示各客户端的状态,当某些客户端状态出现异常 时可以通过短信或邮件通知各联系人。 要实现状态的检测,首先一个重点就是要建 立起主服务器与客户端的连通性。 总体的模式请看下图:,Nagios服务器端的安装,一建立用户nagios和群
2、组nagios: groupadd nagios useradd -G nagios nagios groupadd nagcmd usermod -G nagcmd nagios usermod -G nagcmd wwwrun 二安装nagios 和Nagios-Plugins 1.解压 nagios-3.0.3.tar.gz: tar -zxvf nagios-3.0.3.tar.gz 2.cd nagios-3.0.3 ./configure -with-command-group=nagcmd make all make install make install-init make
3、install-commandmode make install-config make install-webconf 3.建立登录用户和密码(nagiosadmin为用户名) htpasswd2 -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 4.解压nagios-plugins-1.4.13.tar.gz: tar -zxvf nagios-plugins-1.4.13.tar.gz,5.cd nagios-plugins-1.4.13 ./configure -with-nagios-user=nagios -with-nagio
4、s-group=nagios make make install 6.重启apache: service apache2 restart 7.启动nagios : cd /usr/local/nagios/bin/ 检查文件:./nagios -v /usr/local/nagios/etc/nagios.cfg (没错误就可启服务了) service nagios start 三安装NRPE,只要check_nrpe 插件 1.解压 nrpe-2.12.tar.gz: tar -zxvf nrpe-2.12.tar.gz 2.cd nrpe-2.12 ./configure 注意:对于sus
5、e10系统,有时编译时会出现找不到SSL,此时需要先安装一个名为 openssl-devel-0.9.8a-18.4.i586.rpm的包,然后再去重新编译! ( rpm ivh openssl-devel-0.9.8a-18.4.i586.rpm ) make all make install-plugin,Nagios被监控端的安装,一建立用户和组 groupadd nagios useradd -g nagios ngaios 二安装nagios-plugins插件 1.解压nagios-plugins-1.4.13.tar.gz: tar -zxvf nagios-plugins-1.
6、4.13.tar.gz 2.cd nagios-plugins-1.4.13 ./configure make make install 三启动xinetd(启不来,则yast里选择安装一下xinetd服务) service xinetd start 四安装NRPE ./configure make all make install-plugin make install-daemon make install-daemon-config make install-xinetd #将 nrpe 随 xinetd一起服务,五配置 编辑文件/etc/xinetd.d/nrpe,设置服务器端的ip
7、only_from = 0 #此处添加的ip为0 在文件/etc/services里增加一行语句 nrpe 5666/tcp # NRPE 重启xinetd: service xinetd restart 六防火墙允许服务 防火墙打开5666端口 测试服务: /usr/local/nagios/libexec/check_nrpe -H localhost #运行上面语句后要是出现” NRPE v2.12 “ ,表明服务正常 结: 以上nagios 的服务器端和被监控端安装完后,可用以下方法检测主机与客户端的连通性! 登录服务器
8、端(0),运行”/usr/local/nagios/libexec/check_nrpe H 2” (2为被监控端),要是出现” NRPE v2.12 “ ,表明两机连通,服务正常!,功能配置,目前我们监控的功能有检测cpu是否异常和ES进程是否存在(最主要的监控),同时当某一项状态出现异常时,会通过飞信发通知信息到各联系人手机中,以及时解决问题。 我们是通过以下配置来实现上述功能的: 一被监控端机器的文件配置(只需改一个地方) 编辑文件 vi /usr/local/nagios/etc/nrpe.cfg 在此文件里增加一
9、条语句: commandcheck_ES=/usr/local/nagios/libexec/check_procs -c 1:1 -a /etc/ESUI/ 该语句的意思是定义一个命令,名为”check_ES”,用于检测ES进程是否存在. 被监控端机器的文件配置已完成! 二服务器端的文件配置 (引用当前0服务器的配置) 该机器涉及到的配置文件有: 目录/usr/local/nagios/etc/objects/下的 timeperiods.cfg localhost.cfg hosts.cfg services.cfg commands.cfg contacts.cf
10、g 和目录/usr/local/nagios/etc/下的nagios.cfg 文件.,nagios.cfg与timeperiods.cfg文件, nagios.cfg文件 编辑文件vi nagios.cfg ,增加以下语句: 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/timeperiods.cfg cfg_file =/usr/local/nag
11、ios/etc/objects/services.cfg cfg_file =/usr/local/nagios/etc/objects/localhost.cfg cfg_file =/usr/local/nagios/etc/objects/hosts.cfg 一般情况下,上面的语句都已经存在的了,要是哪一条不存在,就手动去增加那一条就行了. timeperiods.cfg文件 编辑文件vi timeperiods.cfg ,增加以下语句: define timeperiod timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week
12、sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 ,localhost.cfg文件, localhost.cfg文件 编辑文件vi localhost.cfg ,增加以下语句: define service use local-service host_name 31 service_description SSH check_command
13、 check_ssh notifications_enabled0 define service use local-service host_name 31 service_description HTTP check_command check_http notifications_enabled0 这里定义了两个服务用于检测本机的ssh功能和http功能是否正常,31是本机的对外公网IP,对内就是0.,hosts.cfg文件, hosts.cfg文件 编辑文件vi hosts.cfg,增加以下语句: define h
14、ost host_name 5017 ; /被监控主机的名称 alias 5017 ; /别名 address 7 ; /被监控主机的IP地址 check_command check_ssh ; /监控主机是否存活 max_check_attempts 3 ; /检查失败后重试的次数 check_period 24x7 ; /检查的时间段24x7 notification_interval 10 ; /提醒的频率 contact_groups admins ; notification_period 24x7 ; /提醒的周期, 24x7 notification_op
15、tions d,u,r ; /指定什么情况下提醒 define host host_name 5042 ; alias 5042 ; address 2 ; check_command check_ssh ; max_check_attempts 3 ; check_period 24x7 ; notification_interval 10 ; contact_groups admins ; notification_period 24x7 ; notification_options d,u,r ; 可根据需要,添加更多的被监控主机,services.cfg文件,
16、services.cfg文件 编辑文件vi services.cfg,增加以下语句: define service service_description CPU host_name 5017,5042 ;该处可添加多个主机名进去 check_command check_nrpe!check_load active_checks_enabled 1 notifications_enabled 1 check_period 24x7 max_check_attempts 3 normal_check_interval 2 retry_check_interval 2 contact_groups
17、 admins notification_options w,u,c,r notification_interval 10 notification_period 24x7 register 1 define service service_description ES host_name 5017,5042 ;该处可添加多个主机ip进去 check_command check_nrpe!check_ES active_checks_enabled 1 notifications_enabled 1 check_period 24x7 max_check_attempts 3 normal_c
18、heck_interval 2 retry_check_interval 2,services.cfg文件,contact_groups admins notification_options w,u,c,r notification_interval 10 notification_period 24x7 register 1 define service service_description TMDS display_name 润迅CMNET专线 host_name DS check_command check_ping!100.0,20%!500.0,60% active_checks
19、_enabled 1 notifications_enabled 1 check_period 24x7 max_check_attempts 3 normal_check_interval 2 retry_check_interval 2 contact_groups admins notification_options w,u,c,r notification_interval 10 notification_period 24x7 register 1 ,contacts.cfg文件, contacts.cfg文件 编辑文件vi contacts.cfg,增加以下语句: define
20、contact contact_name nagiosadmin5;/联系人的名称 alias 陈建红 service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands notify-sms host_notification_commands notify-sms pager#以上是各联系人的信息,可按需求添加,
21、下面再定义一个联系人组 define contactgroup contactgroup_name admins alias Nagios Administrators members nagiosadmin,nagiosadmin2,nagiosadmin3,nagiosadmin4,nagiosadmin5 ,commands.cfg文件, commands.cfg 文件 编辑文件vi commands.cfg, 增加以下语句: #notify-sms define command command_name notify-sms command_line /bin/sms -f-p rft420e -t $CONTACTPAGER$ -m Nagios警告:$HOSTNAME$ $SERVICEDISPLAYNAME$异常$TIME$ 我们在该文件里定义了一个短信通知的命令,该命令在contacts.cfg文件里调用! 注rft420e分别是飞信里的手机号和密码,想改用另一个手机号发通知信息,可更改此信息. 至此,所有文件的配置已完成! 三短信通知功能的实现 我们在c
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026 年秋季支原体肺炎居家照护科普
- 2026年我们的节日:中国农民丰收节
- 钢便桥拆除施工方案
- 二年级美术冀教版冲刺阶段第二单元同步测试卷基础版A卷
- 二年级美术寒假衔接书法基础综合题冲刺提升卷易错强化版
- 2026海事公约更新周期内船舶模拟培训产品合规性溢价机制报告
- 2026智能制造转型中实木平板门传统工匠技艺数字化传承报告
- 2026国产高端卧式拌料机核心密封件材料替代与供应链安全深度研究报告
- 2026功能性醋包在银发经济中的代谢干预价值与商业闭环研报
- 2026住院医师规培-吉林-吉林住院医师规培(医学检验科)历年参考题库含答案详解
- 2026年船舶专业正高级船舶电子员考试练习题及答案
- 2026年德惠市公益性岗位人员招聘(378人)笔试参考题库及答案详解
- (一检)2026-2027学年福州市高三年级适应性练习地理试题(含答案)
- 某机械制造厂安全生产规范
- 2025年通信工程师中级通信专业实务(终端与业务)考试真题及答案
- 《电力重大事故隐患判定标准及治理监督管理规定》国家能源局解读课件
- 2026年秋季学期小学统编版语文六年级上册(新教材)教学计划附教学进度表
- 工伤保险条例练习题及完整答案
- 26秋四年级上册数学第一单元提优卷《北师大版》
- 班级值日班长轮值制度及一日工作流程表(中学适用)
- 钢结构凉亭施工方案
评论
0/150
提交评论