设为首页 收藏本站
查看: 1102|回复: 0

nagios实验与理解

[复制链接]

尚未签到

发表于 2019-1-14 13:43:31 | 显示全部楼层 |阅读模式
  linux客户端需要的软件有:nagios-plugins、nrpe
  windows客户端需要安装:NSClient++.msi文件
  Nagios服务器/usr/local/nagios/etc/objects目录下放被监控主机的cfg文件,使用use语句引用templates.cfg模板中的对象属性,
  linux中nagios配置详解http://bbs.linuxtone.org/thread-2328-1-1.html
  [root@centos objects]#vi /usr/local/nagios/etc/objects/windows.cfg
  define host{
  use             windows-server  ; Inherit default values from a template
  host_name       server  ; The name we're giving to this host
  alias           My Windows Server       ; A longer name associated with the host
  address         192.168.0.8     ; IP address of the host
  }
  之后在/usr/local/nagios/etc/nagios.cfg文件中添加该路径,重启nagios服务就会在WEB出现。
  上面是少量监控的配置方法。★★★
  检查nagios配置文件语法错误:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  ★nagios服务器监控linux主机的操作
  Linux下Nagios的安装与配置 http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html
  必须下载安装nrpe-2.*.tar.gz
  tar xzf nrpe-2.8.1.tar.gz
  cd nrpe-2.8.1
  ./configure
  make all
  make install-plugin
  -------------------
  tar xzf nrpe-2.8.1.tar.gz
  cd nrpe-2.8.1
  ./configure
  make all
  make install-plugin
  make install-daemon
  make install-daemon-config
  为被监控远程主机定义host和service
  1、定义check_nrpe命令
  在文件/usr/local/nagios/etc/objects/commands.cfg后面增加:
  # 'check_nrpe' command definition
  define command{
  command_name check_nrpe
  command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
  }
  2、创建/usr/local/nagios/etc/objects/remotehost.cfg
  #host定义示例部分:
  define host{
  use linux-server
  host_name remotehost
  address 192.168.0.252
  }
  #Service定义示例部分:
  define service{
  use generic-service
  service_description Root Partition
  check_command check_nrpe!check_disk
  }
  3、添加此文件到nagios.cfg全局配置文件中
  vi /usr/local/nagios/etc/nagios.cfg
  cfg_file=/usr/local/nagios/etc/objects/remotehost.cfg
  配置之前做好文件备份“/usr/local/nagios/etc/objects/*”和“nagios.cfg”
  ★★★★★添加大量被监控主机方法
  需要新建的文件:contactgroups.cfg  contacts.cfg  hostgroups.cfg  hosts.cfg services.cfg  timeperiods.cfg
  参照http://sery.blog.运维网.com/10037/20520
  ◆vi /usr/local/nagios/etc/objects/hosts.cfg          //主机配置文件路径
  define host{
  host_name      centos
  alias       centos
  address       192.168.0.253
  max_check_attempts       5
  #check_interval       1
  #retry_interval       1
  check_period       24x7
  contact_groups       sa_groups
  notification_interval       30
  #first_notification_delay
  notification_period       24x7
  notification_options      d,u,r
  }
  copy以上内容,修改主机名和ip即可, 如:red-192.168.0.252
  ◆vi /usr/local/nagios/etc/objects/hostgroups.cfg       //主机组配置文件路径
  define hostgroup{
  hostgroup_name       http_hosts
  alias       http_hosts
  members       red,centos
  }
  类似该文档下面继续添加。
  也可以创建一个文件加入多个被监控主机的信息
  ◆vi /usr/local/nagios/etc/objects/services.cfg       //服务配置文件路径
  define service {
  host_name        centos
  service_description   check-host-alive
  check_period          24x7
  max_check_attempts    4
  normal_check_interval 3
  retry_check_interval  2
  contact_groups        http_hosts
  notification_interval   10
  notification_period     24x7
  notification_options    w,u,c,r
  check_command           check-host-alive  //检查主机是否存活
  }
  copy以上内容,修改主机名和ip即可
  ◆vi timeperiods.cfg    //监视时段配置文件路径
  define timeperiod{
  timeperiod_name 24x7
  alias           24 Hours A Day, 7 Days A Week
  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
  }
  ◆vi contacts.cfg       //联系人配置文件路径
  define contact {
  contact_name         sa    //不要有空格,使用tab键
  alias                system administrator
  service_notification_period    24x7
  host_notification_period       24x7
  service_notification_options   w,u,c,r
  host_notification_options       d,u,r
  service_notification_commands  service-notify-by-sms,service-
  notify-by-email  //这个命令读配置文件miscommands.cfg
  host_notification_commands     host-notify-by-email,host-noti
  fy-by-sms      //这个命令读配置文件miscommands.cfg
  email                          sery@163.com
  pager                          13333333333 //手机号,收报警短信
  }
  copy以上内容,修改其他联系人就是
  ◆vi contactgroups.cfg  //联系组配置文件路径
  define contactgroup {
  contactgroup_name    sagroup  //不要用空格,使用tab键
  alias                system administrator group
  members              sa,sery  //本例有2个成员
  }
  把以上所有创建的文件添加在nagios.cfg全局配置文件中
  Starting nagios:This account is currently not available nagios启动报错
  解决方法:
  修改/etc/passwd
  将/sbin/nologin改成/bin/bash
  ★★NRPE客户端的安装
  http://blog.csdn.net/jiedushi/article/details/6524375
  nagios 客户端安装LINUX
  ./configure
  make all
  make install-plugin
  make install-daemon
  make install-daemon-config
  yum install xinetd
  make install-xinetd
  检查NRPE正确安装与否命令:/usr/local/nagios/libexec/check_nrpe -H  localhost


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-663238-1-1.html 上篇帖子: nagios错误分析 下篇帖子: 为nagios编写检查Mem脚本
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表