我的 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 - 命令 - $
命令完成,返回码 0
为什么以这种方式,check_nrpe 在字符串末尾添加一个美元字符 ($),从而使整个控件脱轨?
提前致谢