【发布时间】:2014-03-11 01:31:24
【问题描述】:
我的 powershell nagios 脚本有问题,该脚本安装在 MS Windows Server 2008 64 位上,带有 NRPE_NT 守护进程。
我已经声明了这样的命令:
command[check_files]=cmd /c echo C:\nrpe\libexec\check_file.ps1 $ARG1$; exit($lastexitcode) | powershell.exe -command -
我已将 ExecutionPolicy 设置为不受限制
我已重新启动 NRPE_NT 服务并在控制台上声明命令,如下所示:
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 60 -c check_files -a $ARG1$
现在,为什么我在本地运行它,效果很好:
C:\>cmd /c echo C:\nrpe\libexec\_file.ps1 C:\nrpe; exit($lastexitcode)| powershell.exe -command -
No file/s present with this string
但如果我通过 check_nrpe 运行它,我会收到以下输出:
'-' 是用 -Command 参数指定的:不允许使用 -Command 的其他参数。
在调试模式下,在 NRPE.log 上我可以看到:
运行命令:cmd /c echo C:\nrpe\libexec\check_file.ps1 C:\nrpe; 退出($lastexitcode) | powershell.exe -command - $
命令完成,返回码 0
为什么用这种方式,check_nrpe 在字符串末尾添加一个美元字符($),使整个控件脱轨?
提前致谢
【问题讨论】:
标签: powershell nagios dollar-sign