-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathydbstat.py
executable file
·288 lines (281 loc) · 15 KB
/
ydbstat.py
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#!/usr/bin/python
import subprocess
import time
import http.client
import glob
import os
from prometheus_client.core import GaugeMetricFamily, REGISTRY, CounterMetricFamily
from prometheus_client import start_http_server, Info
class CustomCollector(object):
def __init__(self):
pass
def collect(self):
path = "*JOBEXAM*"
for filename in glob.glob(path):
with open(filename, 'r') as f:
for lne in f:
dat=lne.split("=")
if dat[0]=="$JOB":
job=dat[1]
job=int(job)
job="job_" + str(job)
if dat[0]=="ROUT":
rout=str(dat[1])
rout=rout.replace('"','')
rout=rout.replace("\n","")
routdet=rout.split("^")
linlab=routdet[0]
routdet1=routdet[1].split("(")
routn=routdet1[0]
rout="routine_" + routn + "_" + "linelabel_" + linlab
filbits=filename.split("_")
if filbits[3] == "BASELINE":
job=job + "_" + rout + "_baseline"
else:
job=job + "_" + rout
stats=lne.split(",")
for i in stats:
stats1=i.split(":")
if stats1[0] == "GLD":
title=stats1[1]
elif stats1[0] == "DRD":
a = GaugeMetricFamily("DRD","Disk Reads from the database file", labels=[job])
a.add_metric([title], stats1[1])
yield a
elif stats1[0] == "BTD":
b = GaugeMetricFamily("BTD","Number of database block transitions to dirty", labels=[job])
b.add_metric([title], stats1[1])
yield b
elif stats1[0] == "CAT":
c = GaugeMetricFamily("CAT","Critical session Acquisitions successes", labels=[job])
c.add_metric([title], stats1[1])
yield c
elif stats1[0] == "CFE":
d = GaugeMetricFamily("CFE","Critical section Failed (blocked) acquisition total caused by Epochs", labels=[job])
d.add_metric([title], stats1[1])
yield d
elif stats1[0] == "CFS":
e = GaugeMetricFamily("CFS","Critical section Failed (blocked) acquisition sum of Squares", labels=[job])
e.add_metric([title], stats1[1])
yield e
elif stats1[0] == "CFT":
g = GaugeMetricFamily("CFT","Critical section Failed (blocked) acquisition Total", labels=[job])
g.add_metric([title], stats1[1])
yield g
elif stats1[0] == "CQS":
f = GaugeMetricFamily("CQS","Critical section acquisition Queued sleeps sum of Squares", labels=[job])
f.add_metric([title], stats1[1])
yield f
elif stats1[0] == "CQT":
g = GaugeMetricFamily("CQT","Critical section acquisition Queued sleeps Total", labels=[job])
g.add_metric([title], stats1[1])
yield g
elif stats1[0] == "CTN":
h = GaugeMetricFamily("CTN","Current Transaction Number of the database for the last committed read-write transaction (TP and non-TP)", labels=[job])
h.add_metric([title], stats1[1])
yield h
elif stats1[0] == "CYS":
i = GaugeMetricFamily("CYS","Critical section acquisition processor Yields sum of Squares", labels=[job])
i.add_metric([title], stats1[1])
yield i
elif stats1[0] == "CYT":
j = GaugeMetricFamily("CYT","Critical section acquisition processor Yields Total", labels=[job])
j.add_metric([title], stats1[1])
yield j
elif stats1[0] == "DEX":
k = GaugeMetricFamily("DEX","Number of Database file Extentions", labels=[job])
k.add_metric([title], stats1[1])
yield k
elif stats1[0] == "DFL":
l = GaugeMetricFamily("DFL","Number of Database Flushes of the entire set of dirty global buffers in shared memory to disk", labels=[job])
l.add_metric([title], stats1[1])
yield l
elif stats1[0] == "DFS":
m = GaugeMetricFamily("DFS","Number of times a process does an fsync of the database file", labels=[job])
m.add_metric([title], stats1[1])
yield m
elif stats1[0] == "DTA":
n = GaugeMetricFamily("DTA","Number of data operations (TP and non-TP)", labels=[job])
n.add_metric([title], stats1[1])
yield n
elif stats1[0] == "DWT":
o = GaugeMetricFamily("DWT","Number of Disk Writes to the database file (TP and non-TP, committed and rolled-back)", labels=[job])
o.add_metric([title], stats1[1])
yield o
elif stats1[0] == "GET":
p = GaugeMetricFamily("GET","Number of GET operations (TP and non-TP)", labels=[job])
p.add_metric([title], stats1[1])
yield p
elif stats1[0] == "JBB":
q = GaugeMetricFamily("JBB","Number of Journal Buffer Bytes updated in shared memory", labels=[job])
q.add_metric([title], stats1[1])
yield q
elif stats1[0] == "JEX":
r = GaugeMetricFamily("JEX","Number of Journal file Extentions", labels=[job])
r.add_metric([title], stats1[1])
yield r
elif stats1[0] == "JFB":
s = GaugeMetricFamily("JFB","Number of Journal File Bytes written to the journal file on disk", labels=[job])
s.add_metric([title], stats1[1])
yield s
elif stats1[0] == "JFL":
t = GaugeMetricFamily("JFL","Number of Journal Flushes of all dirty journal buffers in shared memory to disk", labels=[job])
t.add_metric([title], stats1[1])
yield t
elif stats1[0] == "JFS":
u = GaugeMetricFamily("JFS","Number of Journal FSync operations on the journal file", labels=[job])
u.add_metric([title], stats1[1])
yield u
elif stats1[0] == "JFW":
v = GaugeMetricFamily("JFW","Number of Journal File Write system calls", labels=[job])
v.add_metric([title], stats1[1])
yield v
elif stats1[0] == "JRE":
w = GaugeMetricFamily("JRE","Number of Journal Regular Epoch records written to the journal file", labels=[job])
w.add_metric([title], stats1[1])
yield w
elif stats1[0] == "JRI":
x = GaugeMetricFamily("JRI","Number of Journal Idle epoch journal records written to the journal file", labels=[job])
x.add_metric([title], stats1[1])
yield x
elif stats1[0] == "JRL":
y = GaugeMetricFamily("JRL","Number of Journal Records with a Logical record type (e.g. SET, KILL etc.) written to the journal file", labels=[job])
y.add_metric([title], stats1[1])
yield y
elif stats1[0] == "JRO":
z = GaugeMetricFamily("JRO","Number of Journal Records with a type Other than logical written to the journal file (e.g. AIMG, EPOCH, PBLK, PFIN, PINI, and so on)", labels=[job])
z.add_metric([title], stats1[1])
yield z
elif stats1[0] == "JRP":
aa = GaugeMetricFamily("JRP","Number of Journal Records with a Physical record type (i.e. PBLK, AIMG) written to the journal file", labels=[job])
aa.add_metric([title], stats1[1])
yield aa
elif stats1[0] == "KIL":
ab = GaugeMetricFamily("KIL","Number of KILl operations (kill as well as zwithdraw, TP and non-TP)", labels=[job])
ab.add_metric([title], stats1[1])
yield ab
elif stats1[0] == "LKF":
ac = GaugeMetricFamily("LKF","Number of LocK calls (mapped to this db) that Failed", labels=[job])
ac.add_metric([title], stats1[1])
yield ac
elif stats1[0] == "LKS":
ad = GaugeMetricFamily("LKS","Number of LocK calls (mapped to this db) that Succeeded", labels=[job])
ad.add_metric([title], stats1[1])
yield ad
elif stats1[0] == "NBR":
ae = GaugeMetricFamily("NBR","Number of Non-tp committed transaction induced Block Reads on this database", labels=[job])
ae.add_metric([title], stats1[1])
yield ae
elif stats1[0] == "NBW":
af = GaugeMetricFamily("NBR","Number of Non-tp committed transaction induced Block Writes on this database", labels=[job])
af.add_metric([title], stats1[1])
yield af
elif stats1[0] == "NB0":
ag = GaugeMetricFamily("NB0","Number of Non-tp transaction Restarts at try 0", labels=[job])
ag.add_metric([title], stats1[1])
yield ag
elif stats1[0] == "NB1":
ah = GaugeMetricFamily("NB1","Number of Non-tp transaction Restarts at try 1", labels=[job])
ah.add_metric([title], stats1[1])
yield ah
elif stats1[0] == "NB2":
ai = GaugeMetricFamily("NB2","Number of Non-tp transaction Restarts at try 2", labels=[job])
ai.add_metric([title], stats1[1])
yield ai
elif stats1[0] == "NB3":
aj = GaugeMetricFamily("NB3","Number of Non-tp transaction Restarts at try 3", labels=[job])
aj.add_metric([title], stats1[1])
yield aj
elif stats1[0] == "NTR":
ak = GaugeMetricFamily("NTR","Number of Non-tp committed Transactions that were Read-only on this database", labels=[job])
ak.add_metric([title], stats1[1])
yield ak
elif stats1[0] == "NTW":
al = GaugeMetricFamily("NTW","Number of Non-tp committed Transactions that were read-Write on this database", labels=[job])
al.add_metric([title], stats1[1])
yield al
elif stats1[0] == "ORD":
am = GaugeMetricFamily("ORD","Number of $ORDer(,1) (forward) operations (TP and non-TP); the count of $Order(,-1) operations are reported under ZPR.", labels=[job])
am.add_metric([title], stats1[1])
yield am
elif stats1[0] == "QRY":
an = GaugeMetricFamily("QRY","Number of $QueRY() operations (TP and non-TP)", labels=[job])
an.add_metric([title], stats1[1])
yield an
elif stats1[0] == "SET":
ao = GaugeMetricFamily("SET","Number of SET operations (TP and non-TP)", labels=[job])
ao.add_metric([title], stats1[1])
yield ao
elif stats1[0] == "TBR":
ap = GaugeMetricFamily("TBR","Number of Tp transaction induced Block Reads on this database", labels=[job])
ap.add_metric([title], stats1[1])
yield ap
elif stats1[0] == "TBW":
aq = GaugeMetricFamily("TBW","Number of Tp transaction induced Block Writes on this database", labels=[job])
aq.add_metric([title], stats1[1])
yield aq
elif stats1[0] == "TC0":
ar = GaugeMetricFamily("TC0","Number of Tp transaction Conflicts at try 0 (counted only for that region which caused the TP transaction restart)", labels=[job])
ar.add_metric([title], stats1[1])
yield ar
elif stats1[0] == "TC1":
as1 = GaugeMetricFamily("TC1","Number of Tp transaction Conflicts at try 1 (counted only for that region which caused the TP transaction restart)", labels=[job])
as1.add_metric([title], stats1[1])
yield as1
elif stats1[0] == "TC2":
at = GaugeMetricFamily("TC2","Number of Tp transaction Conflicts at try 2 (counted only for that region which caused the TP transaction restart)", labels=[job])
at.add_metric([title], stats1[1])
yield at
elif stats1[0] == "TC3":
au = GaugeMetricFamily("TC3","Number of Tp transaction Conflicts at try 3 (counted only for that region which caused the TP transaction restart)", labels=[job])
au.add_metric([title], stats1[1])
yield au
elif stats1[0] == "TC4":
av = GaugeMetricFamily("TC4","Number of Tp transaction Conflicts at try 4 (counted only for that region which caused the TP transaction restart)", labels=[job])
av.add_metric([title], stats1[1])
yield av
elif stats1[0] == "TR0":
aw = GaugeMetricFamily("TR0","Number of Tp transaction Restarts at try 0 (counted for all regions participating in restarting TP transaction)", labels=[job])
aw.add_metric([title], stats1[1])
yield aw
elif stats1[0] == "TR1":
ax = GaugeMetricFamily("TR1","Number of Tp transaction Restarts at try 1 (counted for all regions participating in restarting TP transaction)", labels=[job])
ax.add_metric([title], stats1[1])
yield ax
elif stats1[0] == "TR2":
ay = GaugeMetricFamily("TR2","Number of Tp transaction Restarts at try 2 (counted for all regions participating in restarting TP transaction)", labels=[job])
ay.add_metric([title], stats1[1])
yield ay
elif stats1[0] == "TR3":
az = GaugeMetricFamily("TR3","Number of Tp transaction Restarts at try 3 (counted for all regions participating in restarting TP transaction)", labels=[job])
az.add_metric([title], stats1[1])
yield az
elif stats1[0] == "TR4":
aaa = GaugeMetricFamily("TR4","Number of Tp transaction Restarts at try 4 (counted for all regions participating in restarting TP transaction)", labels=[job])
aaa.add_metric([title], stats1[1])
yield aaa
elif stats1[0] == "TRB":
aab = GaugeMetricFamily("TRB","Number of Tp read-only or read-write transactions Rolled Back (excluding incremental rollbacks)", labels=[job])
aab.add_metric([title], stats1[1])
yield aab
elif stats1[0] == "TTR":
aac = GaugeMetricFamily("TTR","Number of Tp committed Transactions that were Read-only on this database", labels=[job])
aac.add_metric([title], stats1[1])
yield aac
elif stats1[0] == "TTW":
aad = GaugeMetricFamily("TTW","Number of Tp committed Transactions that were read-Write on this database", labels=[job])
aad.add_metric([title], stats1[1])
yield aad
elif stats1[0] == "ZPR":
aae = GaugeMetricFamily("ZPR","Number of $order(,-1) or $ZPRevious() (reverse order) operations (TP and non-TP). The count of $Order(,1) operations are reported under ORD", labels=[job])
aae.add_metric([title], stats1[1])
yield aae
elif stats1[0] == "ZTR":
aaf = GaugeMetricFamily("ZTR","Number of ZTRigger command operations", labels=[job])
aaf.add_metric([title], stats1[1])
yield aaf
if __name__ == '__main__':
start_http_server(int(os.environ.get('YOTTA_PROM_PORT')))
REGISTRY.register(CustomCollector())
while True:
time.sleep(10)