regolith-linux/regolith-i3xrocks-config

net-traffic fails when connected to VPN and causes CPU load

Closed this issue · 5 comments

While trying to figure out why I get a continuous 15% CPU load without any applications running, I found that it was because the net-traffic script continuously fails.

Running it by hand gives:

» /usr/share/i3xrocks/net-traffic
cat: /sys/class/net/static/statistics/rx_bytes: No such file or directory

Indeed there is no static entry in /sys/class/net:

» ls /sys/class/net
br-adad92378979  docker0  lo  ppp0  virbr0  virbr0-nic  wlp59s0

The mistake happens in the line IF="${BLOCK_INSTANCE:-$(ip route show default | awk 'NR==1 { print $5 }')}", where ip route gives:

» ip route show default
default dev ppp0 proto static scope link metric 50 
default via 192.168.0.1 dev wlp59s0 proto dhcp metric 600

So it picks up the wrong column, or the wrong line. Changing the line in the script to the following makes it work and puts my CPU at ease both with and without being connected to the VPN:

IF="${BLOCK_INSTANCE:-$(ip route show default | grep 'via' | awk 'NR==1 { print $5 }')}"

However I don't know if that is a good solution in the general case.

You can work around this issue by specifying the interface directly in the settings, i.e. setting the variable BLOCK_INSTANCE to wlp59s0.

Thank you for contributing this edge case, I'll come up with a matching test and then fix this bug in the script 🙂

@sgvandijk I'm afraid since I don't have a VPN connection handy you'll have to play guinea pig for me, if that's okay ..

What does the command

ip route show default 0.0.0.0/0

yield on your machine? Still two lines of output?

@moritzheiber thanks for the workaround, I will use that instead, silly I missed that.

That command indeed still shows the same two lines:

» ip route show default 0.0.0.0/0
default dev ppp0 proto static scope link metric 50 
default via 192.168.0.1 dev wlp59s0 proto dhcp metric 600 

@sgvandijk I've changed the awk syntax ever so slightly and it should work for you now (at least my test cases are passing). Could you verify by testing out the modifications from the PR?

@moritzheiber I gave the modifications a try and they work successfully for me, thanks for the quick resolution! 👍