3

你好,

我使用这个插件在 Icinga 2 中创建了一个自定义命令:

https://github.com/justintime/nagios-plugins/blob/master/check_mem/check_mem.pl ​</p>

check_command

object CheckCommand "memory" {
  import "plugin-check-command"
  command = [ PluginDir + "/check_mem" ]

  arguments = {
    "-w" = {
     required = true 
     value = "$mem_warning$"
    }

    "-c" = {
     required = true
     value = "$mem_critical$"
    }
    "-u" = {
     required = true
     value = "$mem_used$"
    }

    "-C" = "$mem_cache$"
  }

  vars.mem_used = true
  vars.mem_cache = true
  vars.mem_warning = 85
  vars.mem_critical = 95

}

服务

apply Service "Memory" {
  import "generic-service"
  check_command = "memory"
  assign where host.address
}

但是插件无法检查内存并在 Icinga Web 2 界面中给出以下输出:

​插件输出

*** 您必须定义 WARN 和 CRITICAL 级别!\ncheck_​mem.​pl v1.​0 - Nagios 插件\n\nusage:​\n check_​mem.​pl -\ncheck_​mem.​pl 绝对没有暗示或明确的保证\n此程序已获得许可根据\nMIT 许可条款(查看源代码了解详情)

你能帮忙,这个检查有什么问题吗?

4

2 回答 2

2

这适用于您的服务

object CheckCommand "memory" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_mem.pl" ]

    arguments = {
      "-w" = {
         value = "$mem_warning$" 
      }
     "-c" = {
        value ="$mem_critical$"
      }
     "-u" = {
        set_if = "$mem_used$"
     }
     "-C" = {
        set_if = "$mem_cache$"
     }  
   }

    vars.mem_warning = 85
    vars.mem_critical = 95
    vars.mem_used = true
    vars.mem_cache = true
}
于 2016-08-22T17:11:16.453 回答
1

像这样给出,您的命令将在运行时从服务中获取值。

apply Service "Memory" {
  import "generic-service"
  check_command = "memory"
  vars.mem_used = true
  vars.mem_cache = true
  vars.mem_warning = 85
  vars.mem_critical = 95
  assign where host.address
}

这将被替换,而执行时参考这将有所帮助。如果您使用的是 NRPE,请更新您的问题,答案可能会有所不同,请参考将 icinga 传递给 NRPE的参数。

于 2016-06-23T14:59:24.993 回答