File tree Expand file tree Collapse file tree 5 files changed +115
-0
lines changed Expand file tree Collapse file tree 5 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ interface=$1
4+
5+ if [[ -z " $interface " ]]; then
6+ echo " Usage: $0 <interface>"
7+ exit 0
8+ fi
9+
10+ if [[ ! -e " /sys/class/net/$interface " ]]; then
11+ echo " $interface is not a valid interface" 1>&2
12+ exit 1
13+ fi
14+
15+ for trafdir in " ingress" " egress" ; do
16+ prios=$( tc filter show dev " $interface " " $trafdir " | grep pping_tc | cut -f 5 -d ' ' )
17+
18+ while IFS= read -r p || [[ -n " $p " ]]; do
19+ if [[ " $p " =~ ^[0-9]+ ]]; then
20+ tc filter del dev " $interface " " $trafdir " prio " $p "
21+ fi
22+ done <<< " $prios"
23+
24+ done
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ MAX_WAIT_ITER=10
4+ pping_path=${1:- " /var/log/pping/pping.out.json" }
5+ instance=$2 # pping service instance to reload
6+
7+ pping_folder=$( dirname " $pping_path " )
8+ pping_file=$( basename " $pping_path " )
9+
10+ if [[ ! -f " $pping_path " ]]; then
11+ # Nothing to rotate
12+ exit 0
13+ fi
14+
15+ dailyfolder=" $pping_folder /$( date -Idate) "
16+ if ! mkdir -p " $dailyfolder " ; then
17+ exit 1
18+ fi
19+
20+ newplace=" $dailyfolder /$pping_file .$( date -Iseconds) "
21+ if ! mv " $pping_path " " $newplace " ; then
22+ exit 1
23+ fi
24+
25+
26+ if [[ -n " $instance " ]] && systemctl is-active --quiet " pping@$instance .service" ; then
27+ systemctl reload " pping@$instance .service"
28+ fi
29+
30+ # Compress the old file (once ePPing has stopped writing to it)
31+ if [[ -f " $newplace " ]]; then
32+ for (( i = 0 ; i < MAX_WAIT_ITER; i++ )) ; do
33+ if fuser -s " $newplace " ; then
34+ sleep 1
35+ else
36+ gzip " $newplace "
37+ exit $?
38+ fi
39+ done
40+ fi
41+
42+ echo " Timed out waiting for $newplace to become unused, unable to compress it" 1>&2
43+ exit 1
Original file line number Diff line number Diff line change 1+ [Unit]
2+ Description =ePPing - Passive monitoring of network RTTs on %i
3+ After =network.service
4+ Wants =rotate-pping@%i.timer
5+
6+ # Uncomment below if running with LibreQoS
7+ # After=lqosd.service
8+
9+ [Service]
10+ # Ensure folder for saving output to exists
11+ ExecStartPre =/usr/bin/mkdir -p /var/log/pping/%i
12+
13+ # Rotate any old output first to ensure ePPing can start writing to its intended file
14+ ExecStartPre =/opt/bpf-examples/pping/scripts/rotate-pping-output.sh /var/log/pping/%i/pping.%i.json
15+
16+ WorkingDirectory =/opt/bpf-examples/pping
17+ ExecStart =/opt/bpf-examples/pping/pping -i %i -l -r 10 -a 10 -F json -w /var/log/pping/%i/pping.%i.json
18+
19+ # On systemctl reload, send a SIGHUP to ePPing which causes it to reopen its output file
20+ ExecReload =kill -HUP $MAINPID
21+
22+ Restart =on-failure
23+ RestartSec =60
24+
25+ # Set to whatever maximum memory footprint you can tolerate
26+ # Note, hard-kills the ePPing process without allowing it to clean up. Consider
27+ # running /scripts/cleanup-tc-progs after.
28+ MemoryMax =4G
29+
30+ [Install]
31+ WantedBy =default.target
Original file line number Diff line number Diff line change 1+ [Unit]
2+ Description =Rotates the output file from ePPing on %i (pping@%i.service)
3+
4+ [Service]
5+ Type =oneshot
6+ ExecStart =/opt/bpf-examples/pping/scripts/rotate-pping-output.sh /var/log/pping/%i/pping.%i.json %i
Original file line number Diff line number Diff line change 1+ [Unit]
2+ Description=Rotate ePPing output for %i periodically
3+ PartOf=pping@%i.service
4+
5+ [Timer]
6+ Unit=rotate-pping@%i.service
7+
8+ # Rotate ePPing output every X seconds
9+ OnActiveSec=60
10+ OnUnitActiveSec=60
11+ AccuracySec=1us
You can’t perform that action at this time.
0 commit comments