Skip to main content
Build Status Coverage Status PyPI version Requirements Status Python Versions Code Climate

Table of Contents

tl;dr

A powerful & scriptable shell for Apache ZooKeeper

Installing

As Dockerfile:

::

$ docker build . -f Dockerfile -t zk-shell:1.3.3

From PyPI:

$ pip install zk-shell

Or running from the source:

# Kazoo is needed
$ pip install kazoo

$ git clone https://github.com/rgs1/zk_shell.git
$ cd zk_shell
$ export ZKSHELL_SRC=1; bin/zk-shell
Welcome to zk-shell (0.99.04)
(DISCONNECTED) />

You can also build a self-contained PEX file:

$ pip install pex

$ pex -v -e zk_shell.cli -o zk-shell.pex .

More info about PEX here.

Usage

Docker Version

$ docker run -it zk-shell:1.3.3

and use the connect command to connect to your zookeeper instance

$ zk-shell localhost:2181
(CONNECTED) /> ls
zookeeper
(CONNECTED) /> create foo 'bar'
(CONNECTED) /> get foo
bar
(CONNECTED) /> cd foo
(CONNECTED) /foo> create ish 'barish'
(CONNECTED) /foo> cd ..
(CONNECTED) /> ls foo
ish
(CONNECTED) /> create temp- 'temp' true true
(CONNECTED) /> ls
zookeeper foo temp-0000000001
(CONNECTED) /> rmr foo
(CONNECTED) />
(CONNECTED) /> tree
.
├── zookeeper
│   ├── config
│   ├── quota

Line editing and command history is supported via readline (if readline is available). There’s also autocomplete for most commands and their parameters.

Individual files can be copied between the local filesystem and ZooKeeper. Recursively copying from the filesystem to ZooKeeper is supported as well, but not the other way around since znodes can have content and children.

(CONNECTED) /> cp file:///etc/passwd zk://localhost:2181/passwd
(CONNECTED) /> get passwd
(...)
unbound:x:992:991:Unbound DNS resolver:/etc/unbound:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin

Copying between one ZooKeeper cluster to another is supported, too:

(CONNECTED) /> cp zk://localhost:2181/passwd zk://othercluster:2183/mypasswd

Copying between a ZooKeeper cluster and JSON files is supported as well:

(CONNECTED) /> cp zk://localhost:2181/something json://!tmp!backup.json/ true true

Mirroring paths to between clusters or JSON files is also supported. Mirroring replaces the destination path with the content and structure of the source path.

(CONNECTED) /> create /source/znode1/znode11 'Hello' false false true
(CONNECTED) /> create /source/znode2 'Hello' false false true
(CONNECTED) /> create /target/znode1/znode12 'Hello' false false true
(CONNECTED) /> create /target/znode3 'Hello' false false true
(CONNECTED) /> tree
.
├── target
│   ├── znode3
│   ├── znode1
│   │   ├── znode12
├── source
│   ├── znode2
│   ├── znode1
│   │   ├── znode11
├── zookeeper
│   ├── config
│   ├── quota
(CONNECTED) /> mirror /source /target
Are you sure you want to replace /target with /source? [y/n]:
y
Mirroring took 0.04 secs
(CONNECTED) /> tree
.
├── target
│   ├── znode2
│   ├── znode1
│   │   ├── znode11
├── source
│   ├── znode2
│   ├── znode1
│   │   ├── znode11
├── zookeeper
│   ├── config
│   ├── quota
(CONNECTED) /> create /target/znode4 'Hello' false false true
(CONNECTED) /> mirror /source /target false false true
Mirroring took 0.03 secs
(CONNECTED) />

Debugging watches can be done with the watch command. It allows monitoring all the child watches that, recursively, fire under :

(CONNECTED) /> watch start /
(CONNECTED) /> create /foo 'test'
(CONNECTED) /> create /bar/foo 'test'
(CONNECTED) /> rm /bar/foo
(CONNECTED) /> watch stats /

Watches Stats

/foo: 1
/bar: 2
/: 1
(CONNECTED) /> watch stop /

Searching for paths or znodes which match a given text can be done via find:

(CONNECTED) /> find / foo
/foo2
/fooish/wayland
/fooish/xorg
/copy/foo

Or a case-insensitive match using ifind:

(CONNECTED) /> ifind / foo
/foo2
/FOOish/wayland
/fooish/xorg
/copy/Foo

Grepping for content in znodes can be done via grep:

(CONNECTED) /> grep / unbound true
/passwd: unbound:x:992:991:Unbound DNS resolver:/etc/unbound:/sbin/nologin
/copy/passwd: unbound:x:992:991:Unbound DNS resolver:/etc/unbound:/sbin/nologin

Or via igrep for a case-insensitive version.

Non-interactive mode can be used passing commands via --run-once:

$ zk-shell --run-once "create /foo 'bar'" localhost
$ zk-shell --run-once "get /foo" localhost
bar

Or piping commands through stdin:

$ echo "get /foo" | zk-shell --run-from-stdin localhost
bar

It’s also possible to connect using an SSH tunnel, by specifying a host to use:

$ zk-shell --tunnel ssh-host zk-host

Dependencies

  • Python 2.7, 3.3, 3.4, 3.5 or 3.6

  • Kazoo >= 2.2

Testing and Development

Please see CONTRIBUTING.rst.

Metadata

Release files for zk-shell 1.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zk-shell 1.3.4
File Size Uploaded
zk_shell-1.3.4.tar.gz 58.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zk-shell 1.3.4
File Interpreter ABI Platform
zk_shell-1.3.4-py2-none-any.whl Python 2 none any Details

Total release size: 123.1 kB

Release files / zk_shell-1.3.4.tar.gz

Download URL zk_shell-1.3.4.tar.gz
Size 58.1 kB
Tags Source
SHA-256 checksum
How to use checksums
05828f0335d539f190c8981170487638b9e38b535121b66074a49c2d70a25ce6
BLAKE2b-256 checksum
How to use checksums
1adf1f8b94b590a578e8e696c48d96f7d29575a98bb3110325f8a22507ef5c6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.17

Release files / zk_shell-1.3.4-py2-none-any.whl

Download URL zk_shell-1.3.4-py2-none-any.whl
Size 65.0 kB
Tags Python 2
SHA-256 checksum
How to use checksums
d0198339dae0bf6909a697158e17f31176c631eff59713279c1c957a4cdfb13c
BLAKE2b-256 checksum
How to use checksums
77756099e891dfbc72d6332e1b4427dbd8fad7c88880de62f1eb6e7f511196c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.17

Release history Release notifications | RSS feed

This release

1.3.4 This release

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.9

1 release file

1.1.8

1 release file

1.1.7

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.08

1 release file

1.0.7

1 release file

1.0.06

1 release file

1.0.05

1 release file

1.0.04

1 release file

1.0.03

1 release file

1.0.02

1 release file

1.0.01

1 release file

1.0.0

1 release file

0.99.04

1 release file

0.99.03

1 release file

0.99.02

1 release file

0.99.01

1 release file

0.99.0

1 release file

0.98.1

1 release file

0.98.0

1 release file

0.97.7

1 release file

0.97.5

1 release file

0.97.4

1 release file

0.97.3

1 release file

0.97.2

1 release file

0.97.1

1 release file

0.97.0

1 release file

0.95.4

1 release file

0.95.3

1 release file

0.95.2

1 release file

0.95.1

1 release file

0.95.0

1 release file

0.94.6

1 release file

0.94.5

1 release file

0.94.4

1 release file

0.94.3

1 release file

0.94.2

1 release file

0.94.1

1 release file

0.94.0

1 release file

0.93.3

1 release file

0.93.2

1 release file

0.93.1

1 release file

0.93.0

1 release file

0.92.8

1 release file

0.92.7

1 release file

0.92.6

1 release file

0.92.5

1 release file

0.92.4

1 release file

0.92.3

1 release file

0.92.2

1 release file

0.92.1

1 release file

0.92

1 release file

0.9.11

1 release file

0.9.10

1 release file

0.9.9

1 release file

0.9.8

1 release file

0.9.7

1 release file

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page