1

I am having an issue where a Sensu check I am using does not work when it runs using the sensu-client, but if I run the same command that the check issues, I get good results with no errors. I'm attaching screenshots of Sensu running the command and me running the command to show that the command itself works when it is manually ran.

This is what happens when Sensu runs the command.

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

Here is the PowerShell script that the Sensu check is issuing:

[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
}

Would anybody here know why the command works when run manually, but fails when Sensu runs it?

Cameron
  • 11
  • 1
  • That is very strange... I don't know much about powershell, but I would start checking the environment, you could run a script only running "env" in sensu, and compare the output with running "env" on your shell. – Enrique Arriaga Nov 29 '16 at 16:46
  • Thanks for responding, Enrique. From what I can tell, not too much is different from running that command. Here is the output when I do it: http://imgur.com/a/NI6CW. Here is what it looks like when Sensu runs it (Unfortunately, it gets truncated): http://imgur.com/a/TjXgf – Cameron Dec 08 '16 at 05:27

0 Answers0