On 2021-06-10, Valdrin MUJA <valdrin_m...@outlook.com> wrote:
> Hello,
>
> I'm trying to figure out how much packets are being forwarded on my OpenBSD 
> firewall.
> Here a small script i wrote.
>
>
> #!/bin/sh
>
>
> VAL1=`netstat -s | grep 'packets forwarded' | head -1 | awk -F ' ' '{print 
> $1}'`
>
> sleep 1
>
> VAL2=`netstat -s | grep 'packets forwarded' | head -1 | awk -F ' ' '{print 
> $1}'`
>
>
> echo "$(($VAL2-$VAL1))"
>
>
> But i can not be sure if i am doing the right thing?
> Can anyone check it please.
> Thanks.
>

If you are only interested in IPv4 then yes that'll do it.
This would save some cpu cycles though:

VAL1=`netstat -s | awk '/packets forwarded/ { print $1; exit }'`


Reply via email to