Sha256: c6a52c54cc770249c828fabca3eca1ee07457f1ceb23b2cca32446136e7b2fc4

Contents?: true

Size: 1.13 KB

Versions: 9

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 {
  $Available = Invoke-WebRequest $CheckAddress -ErrorAction SilentlyContinue
}

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

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sensu-plugins-windows-3.0.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.9.1 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.9.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.8.1 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.8.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.7.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.6.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.5.0 bin/powershell/check-windows-http.ps1
sensu-plugins-windows-2.4.1 bin/powershell/check-windows-http.ps1