您好,如何进行这样的检查:
/usr/lib/nagios/plugins/check_nt -H 192.168.110.130 -p 12489 -s ****** -v COUNTER -l "\\Paging File(_Total)\\% Usage","Paging File usage is %.2f %%" -w 60 -c 90
我的实际检查命令如下所示:
object CheckCommand "check_windows_pagefile" {
import "plugin-check-command"
import "ipv4-or-ipv6"
command = [ PluginDir + "/check_nt" ]
arguments = {
"-H" = "$component_ip$"
"-p" = "12489"
"-s" = "$nsclient_password$"
"-v" = "COUNTER"
"-l" = "\"\\\\Paging File(_Total)\\\\% Usage\",\"Paging File usage is %.2f %%\""
"-w" = "60"
"-c" = "90"
}
}
但是这只得到我" NSClient - 错误:命令返回无效:check_pdh"
但是如果我执行第一个命令bash就可以了。
这就是icinga2 log:
'/usr/lib/nagios/plugins/check_nt' '-H' '192.168.110.130' '-c' '90' '-l' '"\\Paging File(_Total)\\% Usage","Paging File usage is %.2f %%"' '-p' '12489' '-s' '******' '-v' 'COUNTER' '-w' '60'
这也行不通:
'/usr/lib/nagios/plugins/check_nt' '-H' '192.168.110.130' '-c' '90' '-l' '\\Paging File(_Total)\\% Usage','Paging File usage is %.2f %%' '-p' '12489' '-s' '******' '-v' 'COUNTER' '-w' '60'
只有这个有效:
'/usr/lib/nagios/plugins/check_nt' '-H' '192.168.110.130' '-c' '90' '-l' "\\Paging File(_Total)\\% Usage","Paging File usage is %.2f %%" '-p' '12489' '-s' '******' '-v' 'COUNTER' '-w' '60'
有人在check_nt插件中遇到过icinga2和counter的经历吗?
如何解决单/双引号问题?
答案 0 :(得分:2)
首先,我发现无法轻松禁用icinga默认报价。
但有两种解决方案。
1。)丑陋的人。
不要使用"参数"并自己将命令构建为字符串。
object CheckCommand "check_windows_pagefile" {
import "plugin-check-command"
import "ipv4-or-ipv6"
command = PluginDir + "/check_nt -l \"\\Paging File(_Total)\\% Usage\",\"Paging File usage is %.2f %%\" -H $component_ip$ -p 12489 -s $component_eav_nsclient_password$ -v COUNTER -w 60 -c 90"
}
2.。)使用自定义参数处理程序。
template CheckCommand "command-without-quotes-from-vars" {
command = {{
var command = macro("$command$");
for (key => value in macro("$arguments$")) {
command += " " + key + " " + macro(value)
}
return command
}}
}
object CheckCommand "check_windows_pagefile" {
import "plugin-check-command"
import "ipv4-or-ipv6"
import "command-without-quotes-from-vars"
vars.command = PluginDir + "/check_nt"
vars.arguments = {
"-H" = "$component_ip$"
"-p" = "12489"
"-s" = "$component_eav_nsclient_password$"
"-v" = "COUNTER"
"-l" = "\"\\Paging File(_Total)\\% Usage\",\"Paging File usage is %.2f %%\""
"-w" = "60"
"-c" = "90"
}
}