Thursday, 13 March 2014

Apple: Get Total Sent Traffic From Your Mac With UNIX Command

The UNIX command below allows you to get the total sent traffic from your MacBook.
 #!/bin/sh

DataOut=`netstat -bi | grep -v Obytes | grep -v "-" | grep "^en" | awk '{ x += $10 } END { print x }'`
DataOut2=`netstat -bi | grep -v Obytes | grep -v "-" | grep "^lo" | awk '{ x += $6 } END { print x }'`
DataTol=( $DataOut + $DataOut2 )

echo "0:$DataTol:OK"
* Note: The output from the script can be read by Paessler PRTG. 

No comments:

Post a Comment