ZooKeeper Commands: The Four Letter Words 獲取監控狀態

ZooKeeper responds to a small set of commands. Each command is composed of four letters. You issue the commands to ZooKeeper via telnet or nc, at the client port.

Three of the more interesting commands: "stat" gives some general information about the server and connected clients, while "srvr" and "cons" give extended details on server and connections respectively.

conf
New in 3.3.0: Print details about serving configuration.

cons
New in 3.3.0: List full connection/session details for all clients connected to this server. Includes information on numbers of packets received/sent, session id, operation latencies, last operation performed, etc...

crst
New in 3.3.0: Reset connection/session statistics for all connections.

dump
Lists the outstanding sessions and ephemeral nodes. This only works on the leader.

envi
Print details about serving environment

ruok
Tests if server is running in a non-error state. The server will respond with imok if it is running. Otherwise it will not respond at all.

A response of "imok" does not necessarily indicate that the server has joined the quorum, just that the server process is active and bound to the specified client port. Use "stat" for details on state wrt quorum and client connection information.

srst
Reset server statistics.

srvr
New in 3.3.0: Lists full details for the server.

stat
Lists brief details for the server and connected clients.

wchs
New in 3.3.0: Lists brief information on watches for the server.

wchc
New in 3.3.0: Lists detailed information on watches for the server, by session. This outputs a list of sessions(connections) with associated watches (paths). Note, depending on the number of watches this operation may be expensive (ie impact server performance), use it carefully.

wchp
New in 3.3.0: Lists detailed information on watches for the server, by path. This outputs a list of paths (znodes) with associated sessions. Note, depending on the number of watches this operation may be expensive (ie impact server performance), use it carefully.

mntr
New in 3.4.0: Outputs a list of variables that could be used for monitoring the health of the cluster.

$ echo mntr | nc localhost 2185

zk_version  3.4.0
zk_avg_latency  0
zk_max_latency  0
zk_min_latency  0
zk_packets_received 70
zk_packets_sent 69
zk_outstanding_requests 0
zk_server_state leader
zk_znode_count   4
zk_watch_count  0
zk_ephemerals_count 0
zk_approximate_data_size    27
zk_followers    4                   - only exposed by the Leader
zk_synced_followers 4               - only exposed by the Leader
zk_pending_syncs    0               - only exposed by the Leader
zk_open_file_descriptor_count 23    - only available on Unix platforms
zk_max_file_descriptor_count 1024   - only available on Unix platforms
The output is compatible with java properties format and the content may change over time (new keys added). Your scripts should expect changes.

ATTENTION: Some of the keys are platform specific and some of the keys are only exported by the Leader.

The output contains multiple lines with the following format:

key \t value
Here's an example of the ruok command:

$ echo ruok | nc 127.0.0.1 5111
imok

官網zookeeper參考手冊:http://zookeeper.apache.org/doc/r3.4.10/zookeeperAdmin.html#sc_minimumConfiguration

conf:
clientPort:客戶端端口號 
dataDir:數據文件目錄
dataLogDir:日誌文件目錄  
tickTime:間隔單位時間
maxClientCnxns:最大連接數  
minSessionTimeout:最小session超時
maxSessionTimeout:最大session超時  
serverId:id  
initLimit:初始化時間  
syncLimit:心跳時間間隔  
electionAlg:選舉算法 默認3  
electionPort:選舉端口  
quorumPort:法人端口  
peerType:未確認

cons:
ip=ip
port=端口
queued=所在隊列
received=收包數
sent=發包數
sid=session id
lop=最後操作
est=連接時間戳
to=超時時間
lcxid=最後id(未確認具體id)
lzxid=最後id(狀態變更id)
lresp=最後響應時間戳
llat=最後/最新 延時
minlat=最小延時
maxlat=最大延時
avglat=平均延時

crst:
重置所有連接

dump:
session id : znode path  (1對多   ,  處於隊列中排隊的session和臨時節點)

envi:
zookeeper.version=版本
host.name=host信息
java.version=java版本
java.vendor=供應商
java.home=jdk目錄
java.class.path=classpath
java.library.path=lib path
java.io.tmpdir=temp目錄
java.compiler=<NA>
os.name=Linux
os.arch=amd64
os.version=2.6.32-358.el6.x86_64
user.name=hhz
user.home=/home/hhz
user.dir=/export/servers/zookeeper-3.4.6

ruok:
查看server是否正常
imok=正常

srst:
重置server狀態

srvr:
Zookeeper version:版本
Latency min/avg/max: 延時
Received: 收包
Sent: 發包
Connections: 連接數
Outstanding: 堆積數
Zxid: 操作id
Mode: leader/follower
Node count: 節點數

stat:
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
 /192.168.147.102:56168[1](queued=0,recved=41,sent=41)
 /192.168.144.102:34378[1](queued=0,recved=54,sent=54)
 /192.168.162.16:43108[1](queued=0,recved=40,sent=40)
 /192.168.144.107:39948[1](queued=0,recved=1421,sent=1421)
 /192.168.162.16:43112[1](queued=0,recved=54,sent=54)
 /192.168.162.16:43107[1](queued=0,recved=54,sent=54)
 /192.168.162.16:43110[1](queued=0,recved=53,sent=53)
 /192.168.144.98:34702[1](queued=0,recved=41,sent=41)
 /192.168.144.98:34135[1](queued=0,recved=61,sent=65)
 /192.168.162.16:43109[1](queued=0,recved=54,sent=54)
 /192.168.147.102:56038[1](queued=0,recved=165313,sent=165314)
 /192.168.147.102:56039[1](queued=0,recved=165526,sent=165527)
 /192.168.147.101:44124[1](queued=0,recved=162811,sent=162812)
 /192.168.147.102:39271[1](queued=0,recved=41,sent=41)
 /192.168.144.107:45476[1](queued=0,recved=166422,sent=166423)
 /192.168.144.103:45100[1](queued=0,recved=54,sent=54)
 /192.168.162.16:43133[0](queued=0,recved=1,sent=0)
 /192.168.144.107:39945[1](queued=0,recved=1825,sent=1825)
 /192.168.144.107:39919[1](queued=0,recved=325,sent=325)
 /192.168.144.106:47163[1](queued=0,recved=17891,sent=17891)
 /192.168.144.107:45488[1](queued=0,recved=166554,sent=166555)
 /172.17.36.11:32728[1](queued=0,recved=54,sent=54)
 /192.168.162.16:43115[1](queued=0,recved=54,sent=54)

Latency min/avg/max: 0/0/599
Received: 224869
Sent: 224817
Connections: 23
Outstanding: 0
Zxid: 0x68000af707
Mode: follower
Node count: 101081

(同上面的命令整合的信息)

wchs:
connectsions=連接數
watch-paths=watch節點數
watchers=watcher數量

wchc:
session id 對應 path

wchp:
path 對應 session id

mntr:
zk_version=版本
zk_avg_latency=平均延時
zk_max_latency=最大延時
zk_min_latency=最小延時
zk_packets_received=收包數  
zk_packets_sent=發包數
zk_num_alive_connections=連接數
zk_outstanding_requests=堆積請求數
zk_server_state=leader/follower 狀態
zk_znode_count=znode數量
zk_watch_count=watch數量
zk_ephemerals_count=臨時節點(znode)
zk_approximate_data_size=數據大小
zk_open_file_descriptor_count=打開的文件描述符數量
zk_max_file_descriptor_count=最大文件描述符數量
zk_followers=follower數量
zk_synced_followers=同步的follower數量
zk_pending_syncs=準備同步數
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章