Power Shell to Monitor port 22
Posted: Fri Jan 24, 2020 3:01 pm
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
}
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
}