Instantly share code, notes, and snippets.

Embed
What would you like to do?
linux kernel packet drop stat
#!/usr/bin/env bash
function print() {
for nic in ${@}; do
echo "$nic:"
echo " ifconfig:"
ifconfig $nic | grep drop | sed 's/^\s\+//'
echo " ethtool:"
ethtool -S $nic | grep -E '(err|drop|rx_no_dma_resources)' | grep -v ': 0$' | sed 's/^\s\+//'
echo " tc:"
tc -s qdisc show dev $nic | grep -E -A 1 '\(drop.*'
done
echo "/proc/net/softnet_stat:"
cat /proc/net/softnet_stat | awk '{print $2}' | tr '\n' ' '
echo
if which ovs-dpctl >/dev/null; then
echo "ovs-dpctl show:"
ovs-dpctl show
fi
if grep -q '^nf_conntrack ' /proc/modules; then
echo "conntrack stat:"
awk '{print $11,$12}' /proc/net/stat/nf_conntrack
fi
}
if [[ $# -lt 1 ]]; then
echo "usage: $0 eth0 eth1 ..."
exit 1
fi
print ${@:1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment