Power Shell to Monitor port 22
I have windows server that has connection to external Linux machine port 22 and I would like to monitor this connection.
I did find this Powershell script but Nagios Server we page status for this script is always warning (yellow).
Can you please help
returnStateOK = 1
$returnStateCritical = 0
$Ipaddress= 'x.x.x.x'
$Port= '22'
$t = New-Object Net.Sockets.TcpClient
$t.Connect($Ipaddress,$Port)
if($t.Connected)
{
Write-Host "OK"
exit $returnStateOK
}else
{
Write-Host "Port $'Not OK' "
exit $returnStateCritical
}
Power Shell to Monitor port 22
Re: Power Shell to Monitor port 22
You'll need to change these lines:
https://assets.nagios.com/downloads/nag ... inapi.html
Nagios considers a return code of 1 as a WARNING. OK is 0, WARNING is 1, CRITICAL is 2, and UNKNOWN is 3.returnStateOK = 1
$returnStateCritical = 0
https://assets.nagios.com/downloads/nag ... inapi.html
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
Younes.khabchaouy
- Posts: 2
- Joined: Fri Feb 09, 2018 11:42 am
Re: Power Shell to Monitor port 22
Hello
Thank You for you answer. The change works for me
returnStateOK = 0
$returnStateCritical = 2
Plugin Return Code Service State Host State
0 OK UP
1 WARNING UP or DOWN/UNREACHABLE*
2 CRITICAL DOWN/UNREACHABLE
3 UNKNOWN DOWN/UNREACHABLE
Thank You for your kind support
Thank You for you answer. The change works for me
returnStateOK = 0
$returnStateCritical = 2
Plugin Return Code Service State Host State
0 OK UP
1 WARNING UP or DOWN/UNREACHABLE*
2 CRITICAL DOWN/UNREACHABLE
3 UNKNOWN DOWN/UNREACHABLE
Thank You for your kind support
Re: Power Shell to Monitor port 22
Glad to help!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.