【发布时间】:2020-10-21 09:22:59
【问题描述】:
我想通过 powershell 脚本传递两个论点。
这是常规检查
test = cmd /c echo scripts\test.ps1 ;退出($lastexitcode) | powershell.exe -command -
这就是我想要的想法。设置警告和关键。
test = cmd /c echo scripts\test.ps1 -w 10 -c 50 ;退出($lastexitcode) | powershell.exe -command -
如果警告设置为超过 10 则将返回退出 1
如果 critical 设置超过 50,那么它将返回 exit 2
不确定如何在我的脚本中执行此操作。
这是它现在的样子。
$condition = (Get-Service | Where-Object Status -eq "Running").Count
if ($argument warn) {
Write-Output "Warning:" $condition
exit 1
}
ElseIf ($argument critical) {
Write-Output "Critical:" $condition
exit 2
}
【问题讨论】:
标签: powershell nrpe