I have a patch that basically did what OP wanted - allows client to pass
more detailed information to server for client tracking. It's a useful
feature, for debugging and in future, for ZK to support multi-tenancy and
enforced quota. I'll try upstream that patch via
https://issues.apache.org/jira/browse/ZOOKEEPER-3147.
On Wed, Sep 12, 2018 at 3:10 AM, Shawn Heisey <apache@elyograg.org> wrote:
> On 9/12/2018 2:33 AM, wangyongqiang0617@163.com wrote:
>
>> from zk log, i can get the ip and port, i think if zk can print the
>> process info with the ip and port , will help us in some cases
>>
>
> What precisely are you after? A java program can typically report what
> PID its process has, but I don't know that any other process information is
> available. I have not checked to see whether ZK logs the PID it's using at
> any point. Usually such information is logged at startup (if it is ever
> logged at all) and not anywhere else.
>
> With the port number, you can use a program like lsof or netstat to
> determine the pid, and I think this works on both the client and server
> side. Here's an example of that for another Java program. This isn't
> zookeeper, but the same thing will work for ZK too.
>
> root@smeagol:~# lsof -Pn -i:45499
> COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
> java 8713 elyograg 35u IPv6 95610 0t0 TCP 127.0.0.1:45499
> (LISTEN)
> java 8713 elyograg 62u IPv6 6442866 0t0 TCP 127.0.0.1:52686->
> 127.0.0.1:45499 (CLOSE_WAIT)
> java 8713 elyograg 67u IPv6 6443911 0t0 TCP 127.0.0.1:52792->
> 127.0.0.1:45499 (CLOSE_WAIT)
> java 8713 elyograg 78u IPv6 6446143 0t0 TCP 127.0.0.1:52814->
> 127.0.0.1:45499 (ESTABLISHED)
> java 8713 elyograg 83u IPv6 6444628 0t0 TCP 127.0.0.1:45499->
> 127.0.0.1:52814 (ESTABLISHED)
> java 8713 elyograg 84u IPv6 6443524 0t0 TCP 127.0.0.1:52710->
> 127.0.0.1:45499 (CLOSE_WAIT)
> java 8713 elyograg 85u IPv6 6442460 0t0 TCP 127.0.0.1:52360->
> 127.0.0.1:45499 (CLOSE_WAIT)
> java 8713 elyograg 87u IPv6 6445101 0t0 TCP 127.0.0.1:52766->
> 127.0.0.1:45499 (CLOSE_WAIT)
> java 8713 elyograg 113u IPv6 6443962 0t0 TCP 127.0.0.1:52844->
> 127.0.0.1:45499 (ESTABLISHED)
> java 8713 elyograg 119u IPv6 6444645 0t0 TCP 127.0.0.1:45499->
> 127.0.0.1:52844 (ESTABLISHED)
> java 8713 elyograg 200u IPv6 6441819 0t0 TCP 127.0.0.1:52656->
> 127.0.0.1:45499 (CLOSE_WAIT)
>
> The -Pn parameters instruct lsof to not translate port numbers or IP
> addresses to names. I do this to make the lsof program run faster.
>
> Thanks,
> Shawn
>
>
|