Skip to content

Instantly share code, notes, and snippets.

@alq666
Last active March 14, 2016 21:32
Show Gist options
  • Save alq666/a3585aaca64ebf064be5 to your computer and use it in GitHub Desktop.
Save alq666/a3585aaca64ebf064be5 to your computer and use it in GitHub Desktop.
Capture RTO, retransmits and lost packets into Datadog
/rto/ {
# $3 rto:xxx
# $10 unacked:x
# $11 retrans:x/y
# $12 lost:x
split($3, arr, ":");
rto = arr[2];
if (match($0, /rto:([[:digit:]]+)/, arr)) rto = arr[1];
if (match($0, /unacked:([[:digit:]]+)/, arr)) unacked = arr[1];
if (match($0, /retrans:([[:digit:]]+)?\/([[:digit:]]+)/, arr)) retrans = arr[1];
if (match($0, /lost:([[:digit:]]+)?/, arr)) lost = arr[1];
d = "system.net.tcp.rto:" rto "|ms";
print d > "/inet4/udp/0/localhost/8125";
close("/inet4/udp/0/localhost/8125");
if (unacked > 0) {
d = "system.net.tcp.unacked:" unacked "|c";
print d > "/inet4/udp/0/localhost/8125";
close("/inet4/udp/0/localhost/8125");
}
if (retrans > 0) {
d = "system.net.tcp.retrans:" retrans "|ms";
print d > "/inet4/udp/0/localhost/8125";
close("/inet4/udp/0/localhost/8125");
}
if (lost > 0) {
d = "system.net.tcp.lost:" lost "|ms";
print d > "/inet4/udp/0/localhost/8125";
close("/inet4/udp/0/localhost/8125");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment