update
This commit is contained in:
69
NRPE/Check_iis8_app_pool_state.ps1
Normal file
69
NRPE/Check_iis8_app_pool_state.ps1
Normal file
@ -0,0 +1,69 @@
|
||||
<#
|
||||
Ester Niclos Ferreras
|
||||
|
||||
OK UP
|
||||
WARNING
|
||||
CRITICAL Stopped
|
||||
UNKNOWN not found
|
||||
|
||||
|
||||
#>
|
||||
|
||||
|
||||
#
|
||||
# Shell arguments
|
||||
#
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[Parameter(Mandatory=$True,Position=1)]
|
||||
[string]$ApplicationPool
|
||||
)
|
||||
|
||||
$bReturnOK = $TRUE
|
||||
$bReturnCritical = $FALSE
|
||||
$bReturnWarning = $FALSE
|
||||
|
||||
$returnStateOK = 0
|
||||
$returnStateWarning = 1
|
||||
$returnStateCritical = 2
|
||||
$returnStateUnknown = 3
|
||||
|
||||
$DataTexte = ""
|
||||
$strCritical = ""
|
||||
$strWarning = ""
|
||||
|
||||
[System.Reflection.Assembly]::LoadFrom( "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" ) > $null
|
||||
|
||||
$servermanager = [Microsoft.Web.Administration.ServerManager]::OpenRemote("localhost")
|
||||
$apppools = $servermanager.ApplicationPools["$ApplicationPool"]
|
||||
$iis = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\InetStp\ | select setupstring
|
||||
|
||||
# Nagios output
|
||||
$resultstring='IISPOOL UNKNOWN ' + $ApplicationPool + ' ' + $status +' ; ' + $iis.SETUPSTRING + ' '
|
||||
$exit_code = $UNKNOWN
|
||||
|
||||
|
||||
If ($apppools -ne $null) {
|
||||
$status = $apppools.state
|
||||
|
||||
If ($status -eq 'Started') {
|
||||
$str = 'OK '+ $ApplicationPool + ' ' + $status +' ; ' + $iis.SETUPSTRING + ' '
|
||||
}
|
||||
Else {
|
||||
$strCritica = 'CRITICAL '+ $ApplicationPool + ' ' + $status +' ; ' + $iis.SETUPSTRING + ' '
|
||||
$bReturnCritical = $TRUE
|
||||
}
|
||||
}
|
||||
|
||||
If ($bReturnCritical) {
|
||||
write-output $strCritica "|" $DataTexte
|
||||
exit $returnStateCritical
|
||||
}
|
||||
Elseif ($bReturnWarning) {
|
||||
write-output $strWarning "|" $DataTexte
|
||||
exit $returnStateWarning
|
||||
}
|
||||
Else {
|
||||
write-output $str "|" $DataTexte
|
||||
exit $returnStateOK
|
||||
}
|
Reference in New Issue
Block a user