link 发表于 2017-4-20 09:56:48

分析Nagios服务与命令还有插件的关系

  http://hi.baidu.com/kouzl/item/d4c598d797969f4ffb5768b4
  个人总:
  服务 ->命令 -> 具体的命令(nagios插件)支持多种开发语言(Shell、Perl、Python、PHP 等)
  **.cfg  commands.cfg    /usr/local/nagios/libexec
  添加一套测试服务试试
  commands.cfg中增加如下:
  # test
  define command{
  command_name    test_command
  command_line     echo  it is test command,arg1=$ARG1$ arg2=$ARG2$  && echo check-test >>/home/check.log
  }
  这里有两参数
  localhosts.cfg中中添加如下:
  #this is a test service
  define service{
  use                             local-service
  host_name                       localhost
  service_description             test service
  check_command                   test_command!lizhs1!san
  }
  !表示分割
  重启服务
  service nagios restart
  http://192.168.237.128/nagios/ 
  中就会多个服务,并把打印信息显示出来
  

 
  如何通过命令 如何与服务的状态挂钩呢?
  shell 通过exit 0|1|... 来判断

[*]0--各方面都正常,检查成功完成。
[*]1--资源处于警告状态。某个地方不太妙。
[*]2--资源处于临界状态。原因可能是主机宕机或服务未运行。
[*]3--未知状态,这未必表明就有问题,而是表明检查没有给出一个清楚明确的状态。
  这样就可以弄点规则,在什么情况下动态的发送邮件通知管理员什么的
  http://os.iyunv.com/art/201301/376725.htm
页: [1]
查看完整版本: 分析Nagios服务与命令还有插件的关系