Q:

Windows Network Interface Monitoring - Nagios/Powershell

Function netstat {

Get-WmiObject Win32_PerfFormattedData_Tcpip_NetworkInterface | where{$_.Name -eq "vmxnet3 Ethernet Adapter"} | % { 'OK | Rx-B/s=
{0:0}; Tx-B/s={1:0}' -f ($_.BytesReceivedPersec), ($_.BytesSentPersec)}
}

I created the above powershell script to graph network interface with Nagios.
My concern is that nagios polls the client every 10 minutes and executes this script. So, only the stat at the time of the poll is reported back. How can I make the reporting realtime by either modifying the script so the data is collected realtime or any other means?

A:

Instead of a PowerShell script, use the CheckCounter/Check_Pdh command from the CheckSystem module that comes with NSClient++ - it's pretty much built for this.
The counter name passed to check_nrpe will be something like: 
\Network Interface(vmxnet3 Ethernet Adapter)\Bytes Sent/sec
\Network Interface(vmxnet3 Ethernet Adapter)\Bytes Received/sec

Although you might need to escape the slashes (see this article)

