Skip to content

Instantly share code, notes, and snippets.

@samos123
Created September 2, 2025 20:22
Show Gist options
  • Save samos123/659b6c5aeb10bb7c8611f2a548d03a2c to your computer and use it in GitHub Desktop.
Save samos123/659b6c5aeb10bb7c8611f2a548d03a2c to your computer and use it in GitHub Desktop.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: tpu-network-debug
namespace: kube-system
labels:
k8s-app: tpu-network-debug
spec:
selector:
matchLabels:
k8s-app: tpu-network-debug
template:
metadata:
labels:
k8s-app: tpu-network-debug
spec:
nodeSelector:
# Replace with actual TPU VM name
kubernetes.io/hostname: gke-tpu-fa1a3027-sf75
priorityClassName: system-node-critical
hostNetwork: true
hostPID: true
tolerations:
- operator: "Exists"
effect: "NoExecute"
- operator: "Exists"
effect: "NoSchedule"
containers:
- name: "tpu-network-debug"
image: "ubuntu:latest"
securityContext:
privileged: true
command:
- bash
- -c
- |
set -e
INTERFACE=eth0
iteration=0
apt update -y
apt install sysstat -y
apt install ethtool -y
apt install net-tools -y
apt install iproute2 -y
echo "Printing interface GRO settings"
ethtool -k $INTERFACE
while true
do
echo "Loop iteration timestamp: $(date -u)"
echo "##### MPSTAT OUTPUTS #####"
mpstat -P ALL
echo "##### TRAFFIC STATS #####"
# Reading from /proc/net/dev now relies on hostPID:true
(for i in {1..10}; do sleep 0.1; echo $(date +%s.%N) $(grep $INTERFACE /proc/net/dev); done) | awk '{db=$3-b; if (db==0) next; b=$3; dt=$1-t; t=$1 ;printf "dt %8.6f Mbps %12.3f\n", dt, 1e-6*db*8/dt}'
iteration=$((iteration+1))
if [ $((iteration % 10)) -eq 0 ]; then
echo "##### OTHER NETWORK STATS #####"
nstat
ss -tmoi
tc -s -d qdisc sh dev $INTERFACE
echo "##### ETHTOOL -S OUTPUTS #####"
ethtool -S $INTERFACE
fi
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment