您好,
我使用此插件在Icinga 2中创建了一个自定义命令:
https://github.com/justintime/nagios-plugins/blob/master/check_mem/check_mem.pl
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 \ n句柄:\ n check_mem.pl - \ ncheck_mem.pl绝对没有任何暗示或明确的保证\ n该程序已获得许可根据\ nMIT许可证的条款(详见源代码)
你能帮忙吗,这张支票出了什么问题?
答案 0 :(得分: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
}
这将在执行 refering this will help 时被替换。如果您使用的是NRPE,请更新您的问题,答案可能会有所不同请参考arguments passing icinga to NRPE。
答案 1 :(得分:1)
这适用于您的服务
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
}