Sha256: 9f5258c46f4fcff86b65288d733f18a775301ae2b7ea1779b53950362b19e5cd

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

#
#   check-windows-http.ps1
#
# DESCRIPTION:
#   This plugin checks availability of link provided as param
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Windows
#
# DEPENDENCIES:
#   Powershell 3.0 or above
#
# 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.
#

#Requires -Version 3.0

[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

6 entries across 6 versions & 1 rubygems

Version Path
sensu-plugins-windows-2.4.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.3.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.2.1 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.2.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.1.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.0.0 bin/powershell/check-windows-http.ps1