CHECK_NRPE WARNING AND CRITICAL ALERT
Posted: Wed Jun 08, 2016 10:19 am
Good morning,
I have inserted a script on a windows machine to make check_f5 .
My code is this:
The command sending is this:
Where $ARG1 check_f5 and $ARG2$ -a 1 2
Unfortunately, however, it does not respect the constraints placed by me or does not go critical and warning .
Thanks so much.
I have inserted a script on a windows machine to make check_f5 .
My code is this:
Code: Select all
# Credenziali F5
$user = "*****"
$pw = "*****"
$hostname = "******" # PROD
$poolNameLike = "*New-Scheduall-Prod*" # PROD
$StatoGREEN = "AVAILABILITY_STATUS_GREEN"
$StatoBLU = "AVAILABILITY_STATUS_BLUE"
$availabilityLike = "*is available*"
$addr="*********"
Try {
Add-PSSnapin iControlSnapin
$success=Initialize-F5.iControl -HostName $hostname -Username $user -Password $pw
Clear-Host $success
$ic = Get-F5.iControl
# Recupera la lista dei pool
$pools = $ic.LocalLBPool.get_list()
$a=0
# Cicla sulla lista dei pool, skippando tutti quelli non "New-Scheduall-Prod*"
foreach($pool in $pools) {
if($pool -notlike $poolNameLike) { continue }
# Lista dei membri con relative informazioni
$members = Get-F5.LTMPoolMember -Pool $pool
foreach($member in $members) {
if($member.Address -like $addr) {continue}
$port = $members.Port
$name = $members.Name
$availability = $members.Availability
$enable = $members.enabled
$status = $members.Status
if(($member.Availability -eq $StatoGREEN) -or ($member.Availability -eq $StatoBLU)) {
Write-Host "Service Status" $pool " is ok => " $member.Address #OK
}
else
{
$a++;
Write-Host "Service Status" $pool " is ko => " $member.Address #KO
}
}
}
If ($a -eq 0) {
$exitcode= 0
Write-Host "No poolmember down"
Exit $exitcode
}
else {
$exitcode= 2
Write-Host "Poolmember down"
Exit $exitcode
}
} Catch [Exception] {
$exitcode=1
$err = $_.Exception.Message
$err
Exit $a
}
The command sending is this:
Code: Select all
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$
Unfortunately, however, it does not respect the constraints placed by me or does not go critical and warning .
Thanks so much.