Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
695adba8
Commit
695adba8
authored
Apr 29, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a simple script to parse zLOG output from ZEO.
parent
7a857bcf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
0 deletions
+111
-0
src/scripts/parsezeolog.py
src/scripts/parsezeolog.py
+111
-0
No files found.
src/scripts/parsezeolog.py
0 → 100644
View file @
695adba8
"""Parse the BLATHER logging generated by ZEO.
An example of the log format is:
2002-04-15T13:05:29 BLATHER(-100) ZEO Server storea(3235680, [714], 235339406490168806) ('10.0.26.30', 45514)
"""
import
operator
import
re
import
time
rx_time
=
re
.
compile
(
'(
\
d
\
d
\
d
\
d-
\
d
\
d-
\
d
\
d)T(
\
d
\
d:
\
d
\
d:
\
d
\
d)'
)
def
parse_time
(
line
):
"""Return the time portion of a zLOG line in seconds or None."""
mo
=
rx_time
.
match
(
line
)
if
mo
is
None
:
return
None
date
,
time_
=
mo
.
group
(
1
,
2
)
date_l
=
[
int
(
elt
)
for
elt
in
date
.
split
(
'-'
)]
time_l
=
[
int
(
elt
)
for
elt
in
time_
.
split
(
':'
)]
return
int
(
time
.
mktime
(
date_l
+
time_l
+
[
0
,
0
,
0
]))
rx_meth
=
re
.
compile
(
"ZEO Server (
\
w+)
\
((.*)
\
)
\
('(.*)', (
\
d+)
"
)
def parse_method(line):
pass
def parse_line(line):
"""Parse a log entry and return time, method info, and client."""
t = parse_time(line)
if t is None:
return None, None, None
mo = rx_meth.search(line)
if mo is None:
return None, None, None
meth_name = mo.group(1)
meth_args = mo.group(2)
meth_args = [s.strip() for s in meth_args.split("
,
")]
m = meth_name, tuple(meth_args)
c = mo.group(3), mo.group(4)
return t, m, c
class TStats:
pass
class TransactionParser:
def __init__(self):
self.transactions = []
self.cur_t = {}
self.skipped = 0
def parse(self, line):
t, m, c = parse_line(line)
if t is None:
return
name = m[0]
meth = getattr(self, name, None)
if meth is not None:
meth(t, m[1], c)
def tpc_begin(self, time, args, client):
t = TStats()
t.begin = time
t.url = args[2]
t.objects = []
self.cur_t[client] = t
def tpc_finish(self, time, args, client):
t = self.cur_t.get(client, None)
if t is None:
self.skipped += 1
return
t.finish = time
## self.transactions.append(t)
self.report(t)
self.cur_t[client] = None
def storea(self, time, args, client):
t = self.cur_t.get(client, None)
if t is None:
self.skipped += 1
return
# append the oid and the length of the object
# parse the length as [NNN]
info = int(args[0]), int(args[1][1:-1])
t.objects.append(info)
def report(self, t):
"""Print a report about the transaction"""
if t.objects:
bytes = reduce(operator.add, [size for oid, size in t.objects])
else:
bytes = 0
print "
%
s
%
2
d
%
4
d
%
10
d
%
s
" % (t.begin, t.finish - t.begin,
len(t.objects), bytes,
time.ctime(t.begin)), t.url
if __name__ == "
__main__
":
import fileinput
p = TransactionParser()
i = 0
for line in fileinput.input():
i += 1
try:
p.parse(line)
except:
print "
line
", i
raise
print len(p.transactions)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment