diff --git a/debian/control b/debian/control index eb993a9..0bc8a6b 100644 --- a/debian/control +++ b/debian/control @@ -13,6 +13,6 @@ Standards-Version: 4.1.2 Package: performance-diagnostics Architecture: any -Depends: python3-bpfcc, python3-minimal, python3-psutil, telegraf, docker-ce, influxdb2, curl, openssl, jq +Depends: python3-bpfcc, python3-minimal, python3-psutil, telegraf, docker-ce, influxdb2, curl, openssl, jq, mawk Description: eBPF-based Performance Diagnostic Tools A collection of eBPF-based tools for diagnosing performance issues. diff --git a/telegraf/connstat-stats.sh b/telegraf/connstat-stats.sh index dc83b0c..596b131 100755 --- a/telegraf/connstat-stats.sh +++ b/telegraf/connstat-stats.sh @@ -16,13 +16,14 @@ # swnd, cwnd, rwnd, rtt (averaged across connections) # connections (count of aggregated conns) # -# mawk (the default awk on Delphix engines) does not flush its stdout buffer -# when writing to a Telegraf execd pipe, even with explicit fflush() calls. -# stdbuf -oL forces line-buffered stdout on awk, so each output line is -# delivered to Telegraf immediately without needing awk to exit. +# mawk (the default awk on Delphix engines) reads a pipe in blocks: it keeps +# reading until its 256 KB input buffer is full, or EOF, before processing any +# record. connstat never exits and writes a few KB per interval, so plain mawk +# prints nothing; stdbuf -oL and fflush() affect only output and don't help. +# -W interactive makes mawk read stdin line by line (and unbuffers stdout). /usr/bin/connstat -PLe -i 10 -T u \ -o laddr,lport,raddr,rport,inbytes,outbytes,retranssegs,suna,unsent,swnd,cwnd,rwnd,rtt \ - | stdbuf -oL awk -F',' ' + | /usr/bin/mawk -W interactive -F',' ' BEGIN { batch_ts = 0 # Load port->service mapping from /etc/services, same as LocalTCPStatsCollector. @@ -53,7 +54,6 @@ BEGIN { inb[key] "," outb[key] "," ret[key] "," sun[key] "," uns[key] "," \ int(sw[key]/n) "," int(cw[key]/n) "," int(rw[key]/n) "," int(rt[key]/n) "," n "," batch_ts } - fflush() ts = $0; sub(/^=[[:space:]]*/, "", ts); batch_ts = ts + 0 delete cnt; delete inb; delete outb; delete ret delete sun; delete uns; delete sw; delete cw; delete rw; delete rt @@ -81,6 +81,5 @@ END { inb[key] "," outb[key] "," ret[key] "," sun[key] "," uns[key] "," \ int(sw[key]/n) "," int(cw[key]/n) "," int(rw[key]/n) "," int(rt[key]/n) "," n "," batch_ts } - fflush() } '