环境:zabbix3.0.4、python2.6.6(系统自带)、centos6.7、zookeeper3.4.6
1.zabbix服务端配置,编辑zabbix_server配置文件,添加一行自定义脚本路径:(默认在zabbix安装目录的 share/zabbix/externalscripts/) zabbix3]# vim /data/server/zabbix3/etc/zabbix_server.confExternalScripts=/data/server/zabbix3/etc/zabbix_server.conf.d
2.将脚本getZookeeperInfo.py放在自定义的外部脚本目录目录下,注意一定要配置好脚本执行权限: 脚本链接: zabbix_agentd.conf.d]# chmod +x getZookeeperInfo.pyzabbix_server.conf.d]# mv getZookeeperInfo.py /data/server/zabbix3/etc/zabbix_server.conf.d
3.重启zabbix_server,导入模版,在web页面上的被监控主机添加模版
导入模版:(模版下载:)
添加模版:
4.稍后便可在最新数据中看到数据了:
5.手动执行查看信息: 使用方法: 1
2
3
4
5
6
7
| Usage:
getZookeeperInfo.py -h 127.0.0.1 -p 2181 -c <zkCommand> -k <zkKey>"
getZookeeperInfo.py --host 127.0.0.1 --port 2181 --zkCommand <zkCommand> --zkKey <zkKey>
zkCommand:mntr, zkKey:['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', 'zk_znode_count', 'zk_watch_count', 'zk_ephemerals_count', 'zk_approximate_data_size', 'zk_open_file_descriptor_count', 'zk_max_file_descriptor_count', 'zk_followers', 'zk_synced_followers', 'zk_pending_syncs']
zkCommand:ruok, zkKey:['state']
zkCommand:conf, zkKey:['clientPort', 'dataDir', 'dataLogDir', 'tickTime', 'maxClientCnxns', 'minSessionTimeout', 'maxSessionTimeout', 'serverId', 'initLimit', 'syncLimit', 'electionAlg', 'electionPort', 'quorumPort', 'peerType']
|
<zkCommand>可选项--mntr/ruok/conf
<zkKey>可选项--如上后面的
例子: 1
| python getZookeeperInfo.py --host 127.0.0.1 --port 2181 --zkCommand mntr --zkKey zk_synced_followers
|
5.注意
zk_followers、zk_synced_followers、zk_pending_syncs三个选项是leader上才能监控到,flower上没有;
被监控端要对zabbix_server开放zookeeper端口;
6.备注:
--zookeeper监控指标:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
| 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=准备同步数
|
7.以上是zabbix_server端执行命令来获取被监控端信息,需要开放端口,若想执行脚本在agent
|