Sha256: f0058a8a2b0ce08b4f32615b5fb8e5d20a74b035be84df17ea948b15272d256a

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

#
#   check-windows-http.ps1
#
# DESCRIPTION:
#   This plugin checks availability of link provided as param
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Windows
#
# DEPENDENCIES:
#   Powershell
#
# USAGE:
#   Powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -NoLogo -File C:\\etc\\sensu\\plugins\\check-windows-http.ps1 https://google.com
#
# NOTES:
#
# LICENSE:
#   Copyright 2016 sensu-plugins
#   Released under the same terms as Sensu (the MIT license); see LICENSE for details.
#

[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True,Position=1)]
   [string]$CheckAddress
)

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

try {
  $Avaliable = Invoke-WebRequest $CheckAddress -ErrorAction SilentlyContinue
}

catch {
  $errorandler = $_.Exception.request
}

if (!$Avaliable) {
  Write-Host CRITICAL: Could not connect  $CheckAddress!
  Exit 2 
}

if ($Avaliable) {
   if ($Avaliable.statuscode -eq 200) {
      Write-Host OK: $CheckAddress is avaliable!
      Exit 0
   } else {
      Write-Host CRITICAL: URL $CheckAddress is not accessable!
      Exit 2
   }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sensu-plugins-windows-1.0.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-0.1.0 bin/powershell/check-windows-http.ps1