gethostlatency.bt(8)

πŸ“¦
version 0.27.0 Β· 4 versions
, in alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, nixos 26.05, nixpkgs unstable, ubuntu resolute, ubuntu stonking

✨ gethostlatency.bt(8) β€” bestie edition ✨

okay so this is a page from the System Manager's Manual and the star of the show is gethostlatency.bt β€” say hi πŸ‘‹


🌸 NAME 🌸

gethostlatency.bt β€” shows you the latency for getaddrinfo / gethostbyname[2] calls. it runs on bpftrace / eBPF, no cap πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

gethostlatency.bt

that's it. that's the whole vibe. no flags, no drama, just run it πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

so what this cutie does is trace and print every time gethostbyaddr(), getaddrinfo(), gethostbyname(), and gethostbyname2() get called β€” system wide β€” and then it tells you:

  • the responsible PID and command name πŸ‘‘
  • the latency of the call (duration) in milliseconds ⏱️
  • and the host string 🏠

it's giving DNS detective energy fr fr πŸ”

this tool is lowkey iconic for identifying DNS latency β€” like, it shows you which remote host name lookups were slow, and by how much. obsessed.

⚠️ heads up bestie: this tool currently uses dynamic tracing of user-level functions and registers, so it may need modifications to match your software and processor architecture. it's not one-size-fits-all, okay? πŸ™ˆ
πŸ‘‘ and since this uses BPF, only the root user can use this tool. root access only, periodt.

🌈 REQUIREMENTS 🌈

  • CONFIG_BPF
  • bcc

that's the whole shopping list πŸ›οΈ


⭐ EXAMPLES ⭐

trace host lookups (getaddrinfo / gethostbyname[2]) system wide:

# gethostlatency.bt

and that's it, she's running πŸ’«


πŸ“ FIELDS πŸ“

  • TIME β€” time of the command, in HH:MM:SS format πŸ•
  • PID β€” process ID of the client performing the call πŸ†”
  • COMM β€” process (command) name of the client performing the call 🏷️
  • LATms β€” latency of the call, in milliseconds ⏱️
  • HOST β€” host name string: the target of the lookup 🎯

🧚 OVERHEAD 🧚

the rate of lookups should be relatively low, so the overhead is not expected to be a problem. breathe, bestie, it's fine 😌✨


πŸ’œ SOURCE πŸ’œ

this is from bpftrace πŸ¦‹

https://github.com/bpftrace/bpftrace

also β€” go look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool πŸ“„βœ¨

and for the lore: this is a bpftrace version of the bcc tool of the same name. the bcc tool provides command line options πŸ‘€

https://github.com/iovisor/bcc

🌸 OS 🌸

Linux 🐧 (of course)


πŸ’… STABILITY πŸ’…

Unstable β€” in development. she's still growing, give her grace πŸ™


πŸ‘‘ AUTHOR πŸ‘‘

Brendan Gregg β€” the icon, the legend, the moment ⭐


🫢 SEE ALSO 🫢

go read those too, iykyk πŸ’–


and that's the whole page!! this was filed under USER COMMANDS, dated 2018-09-08, and it's the gethostlatency.bt(8) page in case you forgot where you were πŸ’€ mwah, go trace some lookups bestie πŸŽ€βœ¨πŸ¦‹