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

nagios监控客户端

[复制链接]

尚未签到

发表于 2019-1-15 08:58:19 | 显示全部楼层 |阅读模式
  nagios服务端能检测客户端版本后,接下来的工作则是对客户端的监控,我的配置文件是这样操作的
  把所有的监控主机节点都放到hosts.cfg中,所有主机的服务都放到services.cfg中,如果日后要添加的话,则只需要改动这2个文件就可以了
  cfg_file=/usr/local/nagios/etc/objects/templates.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/nagios/etc/objects/services.cfg
  cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
  cfg_file=/usr/local/nagios/etc/objects/contactgroups.cfg
  cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg
  ####
  cat services.cfg
  #####远程主机host 122.49.3x.xxx###
  define service{
  host_name               xxxx
  service_description     Current Load
  check_command           check_nrpe!check_load
  max_check_attempts      5
  normal_check_interval   3
  retry_check_interval    2
  check_period            24x7
  notification_interval   10
  notification_period     24x7
  notification_options    w,u,c,r
  contact_groups          shyygroup
  }
  ###下面是本机的监控
  define service{
  host_name               xxx
  service_description     Current Users
  check_command           check_local_users!20!50
  max_check_attempts      5
  normal_check_interval   3
  retry_check_interval    2
  check_period            24x7
  notification_interval   10
  notification_period     24x7
  notification_options    w,u,c,r
  contact_groups          shyygroup
  }
  root># cat hostgroups.cfg
  define hostgroup{
  hostgroup_name  shyy-servers
  alias           shyy-servers
  members         xx,xxx   (主机名)
  }
  root># cat contacts.cfg
  define contact {
  contact_name                       nagiosadmin
  alias                              nagios 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      notify-service-by-email
  host_notification_commands         notify-host-by-email
  pager 1371xx
  }
  root>#cat commands.cfg(如下几行是新增的)
  define command{
  command_name  check_nrpe
  command_line  $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
  }
  define command{
  command_name  process-service-perfdata
  command_line   /usr/local/nagios/libexec/process_perfdata.pl
  }
  define command{
  command_name  process-host-perfdata
  command_line  /usr/local/nagios/libexec/process_perfdata.pl
  }
  define command{
  command_name    check_mem
  command_line    $USER1$/check_mem.sh -w $ARG1$ -c $ARG2$
  }
  define command{
  command_name    check_traffic
  command_line    $USER1$/check_traffic.sh -V 2c -C public -H $HOSTADDRESS$ -I $ARG1$ -w $ARG2$ -c $ARG3$ -K -b
  }
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  

  Total Warnings: 0
Total Errors:   0         如果有警告或错误,都是有提示的,根据提示检查配置文件



【nagios客户端】,需要在nagios客户端先定义,/usr/local/nagios/libexec插件下的所有插件都必须要有执行权限,否则会报“NRPE: Command 'xx’ not defined”

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10

command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1

command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z

command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 190 -c 200

command[check_http]=/usr/local/nagios/libexec/check_http -H localhost -p 80

command[check_sda3]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda3

command[check_mysql]=/usr/local/nagios/libexec/check_mysql -H localhost -unagios -p123456

command[check_ping]=/usr/local/nagios/libexec/check_ping -H localhost -w 200.0,20% -c 800.0,40%

command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w 150 -c 100

command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 3 -w 300,400 -c 500,600 -K -B

command[check_5666]=/usr/local/nagios/libexec/check_tcp -H 127.0.0.1 -p 5666

command[check_port]=/usr/local/nagios/libexec/check_tcp -H 127.0.0.1 -p 3306

command[check_java_9801]=/usr/local/nagios/libexec/check_tcp -H 127.0.0.1 -p 9801

command[check_java_9800]=/usr/local/nagios/libexec/check_tcp -H 127.0.0.1 -p 9800

重启nrpe


【nrpe测试】在nagios服务器测试
./check_nrpe -H 122xx -c check_sda3
DISK OK - free space: / 876739 MB (98% inode=99%);| /=12366MB;749349;843018;0;936687
就可以了


如图:


  


  

  

  

  

  





运维网声明 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-663414-1-1.html 上篇帖子: 使用nagios监控oracle 下篇帖子: nagios插件pnp安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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