Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ h1. ZooKeeper top
h2. Summary

"This project":http://github.com/phunt/zktop provides a unix "top" like utility for ZooKeeper. It is compatible with Python2.6, Python2.7 and Python3.
With Python2, "pathlib"https://pypi.python.org/pypi/pathlib/ is required to be installed.

h3. Example

Expand Down Expand Up @@ -62,8 +63,9 @@ Usage: zktop.py [options]

Options:
-h, --help show this help message and exit
--servers=SERVERS comma separated list of host:port (default
localhost:2181)
--servers=SERVERS comma separated list of host:port
(default “localhost:2181”, only used if the default
zookeeper configuration file (see --config) is not found)
-n, --names resolve session name from ip (default False)
--fix_330 workaround for a bug in ZK 3.3.0
-v VERBOSITY, --verbosity=VERBOSITY
Expand All @@ -72,7 +74,9 @@ Options:
directory in which to place log file, or empty for
none
-c CONFIGFILE, --config=CONFIGFILE
zookeeper configuration file to lookup servers from
zookeeper configuration file to lookup servers from,
ignored if --servers is explicitly specified
(default “/etc/zookeeper/conf/zoo.cfg”)
</pre>

--fix_330 works around a bug in ZooKeeper 3.3.0, it is only necessary if running the server against that version of ZooKeeper.
Expand Down
13 changes: 11 additions & 2 deletions zktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# limitations under the License.

from optparse import OptionParser # TODO use argparse instead
from pathlib import Path

import threading
import sys
Expand All @@ -41,11 +42,12 @@


ZK_DEFAULT_PORT = 2181
ZK_DEFAULT_CFG = "/etc/zookeeper/conf/zoo.cfg"

usage = "usage: %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option("", "--servers",
dest="servers", default="localhost:%s" % ZK_DEFAULT_PORT,
dest="servers", default=None,
help="comma separated list of host:port (default localhost:%d)" % ZK_DEFAULT_PORT)
parser.add_option("-n", "--names",
action="store_true", dest="names", default=False,
Expand All @@ -60,7 +62,7 @@
dest="logfile", default=None,
help="directory in which to place log file, or empty for none")
parser.add_option("-c", "--config",
dest="configfile", default=None,
dest="configfile", default="%s" % ZK_DEFAULT_CFG,
help="zookeeper configuration file to lookup servers from")
parser.add_option("-t", "--timeout",
dest="timeout", default=None,
Expand All @@ -73,6 +75,13 @@
else:
LOG.disable(LOG.CRITICAL)

if options.servers:
options.configfile=""
else:
if not Path(options.configfile).is_file():
options.servers="localhost:%s" % ZK_DEFAULT_PORT
options.configfile=""

resized_sig = False


Expand Down