xref: /aosp_15_r20/external/bcc/tools/gethostlatency_example.txt (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1*387f9dfdSAndroid Build Coastguard WorkerDemonstrations of gethostlatency, the Linux eBPF/bcc version.
2*387f9dfdSAndroid Build Coastguard Worker
3*387f9dfdSAndroid Build Coastguard Worker
4*387f9dfdSAndroid Build Coastguard WorkerThis traces host name lookup calls (getaddrinfo(), gethostbyname(), and
5*387f9dfdSAndroid Build Coastguard Workergethostbyname2()), and shows the PID and command performing the lookup, the
6*387f9dfdSAndroid Build Coastguard Workerlatency (duration) of the call in milliseconds, and the host string:
7*387f9dfdSAndroid Build Coastguard Worker
8*387f9dfdSAndroid Build Coastguard Worker# ./gethostlatency
9*387f9dfdSAndroid Build Coastguard WorkerTIME      PID    COMM          LATms HOST
10*387f9dfdSAndroid Build Coastguard Worker06:10:24  28011  wget          90.00 www.iovisor.org
11*387f9dfdSAndroid Build Coastguard Worker06:10:28  28127  wget           0.00 www.iovisor.org
12*387f9dfdSAndroid Build Coastguard Worker06:10:41  28404  wget           9.00 www.netflix.com
13*387f9dfdSAndroid Build Coastguard Worker06:10:48  28544  curl          35.00 www.netflix.com.au
14*387f9dfdSAndroid Build Coastguard Worker06:11:10  29054  curl          31.00 www.plumgrid.com
15*387f9dfdSAndroid Build Coastguard Worker06:11:16  29195  curl           3.00 www.facebook.com
16*387f9dfdSAndroid Build Coastguard Worker06:11:25  29404  curl          72.00 foo
17*387f9dfdSAndroid Build Coastguard Worker06:11:28  29475  curl           1.00 foo
18*387f9dfdSAndroid Build Coastguard Worker
19*387f9dfdSAndroid Build Coastguard WorkerIn this example, the first call to lookup "www.iovisor.org" took 90 ms, and
20*387f9dfdSAndroid Build Coastguard Workerthe second took 0 ms (cached). The slowest call in this example was to "foo",
21*387f9dfdSAndroid Build Coastguard Workerwhich was an unsuccessful lookup.
22*387f9dfdSAndroid Build Coastguard Worker
23*387f9dfdSAndroid Build Coastguard Worker
24*387f9dfdSAndroid Build Coastguard WorkerUSAGE message:
25*387f9dfdSAndroid Build Coastguard Worker
26*387f9dfdSAndroid Build Coastguard Worker# ./gethostlatency -h
27*387f9dfdSAndroid Build Coastguard Workerusage: gethostlatency [-h] [-p PID]
28*387f9dfdSAndroid Build Coastguard Worker
29*387f9dfdSAndroid Build Coastguard WorkerShow latency for getaddrinfo/gethostbyname[2] calls
30*387f9dfdSAndroid Build Coastguard Worker
31*387f9dfdSAndroid Build Coastguard Workeroptional arguments:
32*387f9dfdSAndroid Build Coastguard Worker  -h, --help         show this help message and exit
33*387f9dfdSAndroid Build Coastguard Worker  -p PID, --pid PID  trace this PID only
34*387f9dfdSAndroid Build Coastguard Worker
35*387f9dfdSAndroid Build Coastguard Workerexamples:
36*387f9dfdSAndroid Build Coastguard Worker    ./gethostlatency           # time getaddrinfo/gethostbyname[2] calls
37*387f9dfdSAndroid Build Coastguard Worker    ./gethostlatency -p 181    # only trace PID 181
38