Sensu命令通过命令行运行,但通过sensu失败

时间:2016-11-29 00:22:36

标签: powershell sensu

我遇到一个问题,我使用的Sensu检查在使用sensu-client运行时不起作用,但如果我运行检查发出的相同命令,我会得到很好的结果,没有错误。我附上运行该命令的Sensu的屏幕截图,然后运行该命令以显示该命令本身在手动运行时有效。

This is what happens when Sensu runs the command.

Here is what happens when I run the same command with PowerShell

以下是Sensu检查发出的PowerShell脚本:

[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True,Position=1)]
   [int]$WARNING,

   [Parameter(Mandatory=$True,Position=2)]
   [int]$CRITICAL
)

$ThisProcess = Get-Process -Id $pid
$ThisProcess.PriorityClass = "BelowNormal"

$Counter = ((Get-Counter '\SMTP Server(_TOTAL)\Cat: Categorizations failed (DS logon failure)').CounterSamples)

$Path = ($Counter.Path).Trim("\\") -replace " ","_" -replace "\\","." -replace "[\{\}]","" -replace "[\[\]]",""
$Value = [System.Math]::Truncate($Counter.CookedValue)
$Time = [int][double]::Parse((Get-Date -UFormat %s))
If ($Value -ge $CRITICAL) {
  Write-Host "CatCategorizationsFailedDSLogonFailure CRITICAL:  Value is at $Value"
  Exit 2
}
Elseif ($Value -ge $WARNING) {
  Write-Host "CatCategorizationsFailedDSLogonFailure WARNING:  Value is at $Value"
  Exit 1
}
Else {
  Write-Host "CatCategorizationsFailedDSLogonFailure OK: Value is at $Value"
  Exit 0
}

这里有人知道为什么命令在手动运行时有效,但在Sensu运行时失败了吗?

0 个答案:

没有答案