Search code examples
javaapachetelnetapache-zookeeperjconsole

Inspecting ZooKeeper's state as it is running


So far the only way I know how to inspect the state of my zookeeper instance is by running this code in my client:

for(String w: zk.getChildren("/workers", false))
{
    System.out.println("Worker:" + w);
}

Is there a way I can do this outside of my program at will? I would like to be able to see a complete listing or picture of my zookeeper state. The four letter word command dump does not list persistent nodes and when using jconsole, I can see my zookeeoer servers, but not the nodes. In my O'Reilly zookeeper book and online I cannot find a way to inspect zookeeper's state, let me know if you know how.


Solution

  • You can use the zkCli tool (zkCli.sh or zkCli.bat) to query Zookeeper from the command line. It is covered in the O'Reilly book - see the index.

    You can also use the ZooInspector tool that is in the Zookeeper contrib directory.