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=准备同步数

原文地址:http://blog.51cto.com/yanconggod/2058766

时间: 2024-12-11 00:41:45

ZooKeeper Commands: The Four Letter Words 获取监控状态的相关文章

zabbix企业应用之定时获取监控数据做报表

最近某项目突然提出一个新需求,需要每周五14点,获取他们监控项目每天20-24点监控平均数据,以小时为单位的,输出文件是excel的,要求以每天为单位单独一个sheet,汇总邮件转给业务. 他们主要是做业务使用量报表,每周周报使用,虽然需求困难,但作为运维也得解决,下面是邮件的效果图. 可以看到邮件标题是带有项目名称与时间,收集人是业务与我. 下面是excel的格式 每天一个sheet,获取这些项目自己每天20-24点的监控平均数据,以小时为单位. 主要是使用sql查看上面的监控数据,并通过py

StickyBroadcast在获取电池状态中的妙用

StickyBroadcast在获取电池状态中的妙用 今天在做开发的时候,突然遇到这样的一个问题,当你的设备电量低于15%的时候这个时候设备的闪光灯是无法打开的,但是我们平台的解决方案对这一块没有做出任何的提示,于是直接导致了用户认为他的闪光灯坏掉了,于是老大要求我们解决这个问题. 我们都知道电池的电量信息获取我们是通过广播来实现的. 标准做法如下: private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {

脚本自动部署构架集群和监控状态

脚本自动部署构架集群和监控状态 shell脚本编写自动部署.初始配置.并启动nginx反向代理服务 1 #!/bin/bash 2 systemctl disable firewalld 3 systemctl stop firewalld 4 setenforce 0 5 #### 6 yum install epel-release -y 7 yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel 8 yum

Android 通过广播获取网络状态

Android系统网络连接状态的改变会发一个广播,注册一个广播接收者,实时动态的检测网络状态,及时提醒用户,优化用户体验. 本文仅提供WIFI 状态的检测作为参考,其他网络连接方式请对比WIFI连接作出调整. 首先写一个WifiStateBroadcast类继承BroadcastReceiver,重写onRecevie方法,获取网络连接状态管理器,通过管理器拿到对应的网络信息,得到网络状态,判断网络状态,作出相应的业务逻辑. 1 public class WifiStateBroadCast e

iOS 获取网络状态

在iOS开发者,获取网络状态比较常用 -(NSString *)getNetWorkStates{ UIApplication *app = [UIApplication sharedApplication]; NSArray *children = [[[app valueForKeyPath:@"statusBar"]valueForKeyPath:@"foregroundView"]subviews]; NSString *state = nil; int n

android开发获取网络状态,wifi,wap,2g,3g.工具类(一)

android开发获取网络状态整理: 1 package com.gzcivil.utils; 2 3 import android.content.Context; 4 import android.net.ConnectivityManager; 5 import android.net.NetworkInfo; 6 import android.telephony.TelephonyManager; 7 import android.text.TextUtils; 8 9 public c

C# 获取时间差状态

/// <summary> /// 根据时间获取时间状态 /// </summary> /// <param name="dt"></param> /// <returns></returns> public string GetTimeInfo(DateTime dt) { TimeSpan span = DateTime.Now - dt; if (span.TotalDays > 60) { retur

获取网络状态,区分2G3G4GWIFI等,非reachability

+(NSString *)getNetWorkStates{ UIApplication *app = [UIApplication sharedApplication]; NSArray *children = [[[app valueForKeyPath:@"statusBar"]valueForKeyPath:@"foregroundView"]subviews];    NSString *state = [[NSString alloc]init];   

PS脚本获取网络适配器状态

1. Get-WmiObject -Class Win32_NetworkAdapterConfiguration ` -filter "IPEnabled = $true" 2. Get-WmiObject -Class Win32_NetworkAdapter | Format-Table -Property Name, NetConnectionStatus -AutoSize 3.netsh interface show interface PS脚本获取网络适配器状态