Traffic stats for Nagios Monitoring (NRPE)

Standardized script to get NIC traffic stats for Nagios Monitoring

$NIC_Traffic = Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName localhost -Namespace root\CIMV2 | Where {$_.Name -eq "BASP Virtual Adapter"}
$BytesReceived = $NIC_Traffic | % {$_.BytesReceivedPersec}
$BytesSent = $NIC_Traffic | % {$_.BytesSentPersec}

Write-Host "Traffic in: ${BytesReceived},00 bit/s (0,00%), traffic out: ${BytesSent},00 bit/s (0,00%) | traffic_in=${BytesReceived}bit/s;0;10000000000 traffic_out=${BytesSent}bit/s;0;10000000000"
exit 0

NRPE Handler

[NRPE Handlers]
command[check_traffic]=cmd /c echo scripts\traffic.ps1 | powershell.exe -command -

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top