-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseops.rb
executable file
·52 lines (46 loc) · 1.39 KB
/
parseops.rb
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
#!/usr/bin/ruby -I ./lib
require 'ldapreplay/parsers/openldap'
require 'ldapreplay/ldapoperation'
require 'pp'
require 'yaml'
parser = LdapReplay::Parsers::OpenLDAP.new( *ARGV )
conn_hsh = {}
conn_ary = []
parser.emit { |args|
begin
op_time, op_conn, op_id, op_type, op_args = *args
# puts "args: #{args.join(' ')}"
unless op_type == 'RESULT'
if conn_hsh.has_key?(op_conn)
connection = conn_hsh[op_conn]
if connection.has_key?(op_id)
connection[op_id].add_args(op_args)
else
connection[op_id]=LdapReplay::LdapOperation.new(*args)
end
else
conn_hsh[op_conn] = {op_id => LdapReplay::LdapOperation.new(*args)}
end
if op_type == 'closed'
conn_ary.push conn_hsh.delete op_conn
# puts "--------------------"
# puts "conn_hsh: %s" % conn_hsh.pretty_inspect
# puts "===================="
# puts "conn_ary: %s" % conn_ary.pretty_inspect
# # puts "conn_ary: #{conn_ary}"
# puts "^^^^^^^^^^^^^^^^^^^^"
end
end
rescue Errno::EPIPE
break
end
}
ckeys = conn_hsh.keys
ckeys.each {|kk| conn_ary.push conn_hsh.delete kk}
# puts "--------------------"
# puts "conn_hsh: %s" % conn_hsh.pretty_inspect
# puts "===================="
# puts "conn_ary: %s" % conn_ary.pretty_inspect
# # puts "conn_ary: #{conn_ary}"
# puts "^^^^^^^^^^^^^^^^^^^^"
puts YAML.dump conn_ary