Skip to content

Instantly share code, notes, and snippets.

@MattHodge
Last active August 29, 2015 14:22
Show Gist options
  • Save MattHodge/a3c81e8601b300f14868 to your computer and use it in GitHub Desktop.
Save MattHodge/a3c81e8601b300f14868 to your computer and use it in GitHub Desktop.
Sensu Windows Check
Param
(
# Param1 help description
[Parameter(Mandatory=$true)]
$ServiceName
)
$status = (Get-Service -name $ServiceName)
if ($status.Status -ne 'Running')
{
Write-Output "$($status.DisplayName) ($($status.Name)) is not currently running!"
exit 2
}
else
{
Write-Output "$($status.DisplayName) ($($status.Name)) is running."
exit 0
}
{
"checks": {
"service_w32time": {
"command": "powershell.exe -noprofile -executionpolicy unrestricted -nologo -file C:\\opt\\sensu\\conf.d\\check-service.ps1 -ServiceName w32time",
"subscribers": [
"production"
],
"interval": 10,
"how_to_fix": "Restart the service"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment