TCP Connections stats for Nagios Monitoring (NRPE)
Standardized script to get TCP Connections stats for Nagios Monitoring
$StatsTCP = Get-WmiObject -class Win32_PerfFormattedData_Tcpip_TCPv4 -ComputerName localhost -Namespace root\CIMV2 $ConnectionsActive = $StatsTCP | % {$_.ConnectionsActive} $ConnectionsPassive = $StatsTCP | % {$_.ConnectionsPassive} $ConnectionsEstablished = $StatsTCP | % {$_.ConnectionsEstablished} $ConnectionsReset = $StatsTCP | % {$_.ConnectionsReset} Write-Host "OK - tcp connections: $ConnectionsActive, $ConnectionsPassive, $ConnectionsEstablished, $ConnectionsReset | active=$ConnectionsActive; passive=$ConnectionsPassive; established=$ConnectionsEstablished; reset=$ConnectionsReset;" exit 0
NRPE Handler
[NRPE Handlers] command[check_tcp]=cmd /c echo scripts\tcp_stats.ps1 | powershell.exe -command -