Last active
August 29, 2016 21:59
-
-
Save lmangani/603b69fdf974bc2fd733f0971f47f9ca to your computer and use it in GitHub Desktop.
BASH Script measuring PPS by BFP filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# USAGE: max_pps.sh eth0 'portrange 5060-5090' 2>&1 | tee -a output.log | |
if [ -z "$1" ] | |
then | |
echo "No capture interface supplied!" | |
fi | |
if [ -z "$2" ] | |
then | |
echo "No FILTER supplied!" | |
fi | |
# Output statistics | |
tcpdump -i $1 -l -e -n $2 | \ | |
perl -e '$max=0;$avg=0;$cnt=0;$tot=0; while (<>) {$l++;if (time > $e) {$e=time;if($l > $max){ $max=$l}; $cnt++;$tot+=$l;$avg=$tot/$cnt;print STDERR "{ \"timestamp\":\"",scalar localtime (),"\", \"pps_peak\":$max, \"pps_avg\":$avg }\n";$l=0 }}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment