-
Notifications
You must be signed in to change notification settings - Fork 4
/
emon.rb
executable file
·118 lines (101 loc) · 2.56 KB
/
emon.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
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
#!/usr/bin/ruby
require_relative 'utility'
class Emon
def initialize
set_emon_install("/opt/intel/sep")
set_output_dir(File.join(Dir.pwd, Time.now.strftime("emon-%F.%T")))
@event_file = ""
end
def set_emon_install(emon_install)
@emon_install = emon_install
@emon_bin = File.join(@emon_install, "bin64", "emon")
@emon_ko_dir = File.join(@emon_install, "sepdk", "src")
end
def set_output_dir(output_dir)
@output_dir = output_dir
@log_file = File.join(@output_dir, "log")
end
def set_event_file(event_file)
@event_file = event_file
end
def output_file(file)
File.join(@output_dir, file)
end
def load_kernel_module()
cmds = [
{
:cmd => File.join(@emon_ko_dir, "rmmod-sep"),
:out => output_file("rmmod-sep.dat"),
:err => output_file("rmmod-sep.err"),
:wait => true,
:pid => nil,
},
{
:cmd => File.join(@emon_ko_dir, "insmod-sep"),
:out => output_file("insmod-sep.dat"),
:err => output_file("insmod-sep.err"),
:wait => true,
:pid => nil,
}
]
cmds.each do |cmd| new_proc(cmd) end
end
def start()
cmds = [
{
:cmd => @emon_bin + " -v",
:out => output_file("emon-v.dat"),
:err => output_file("emon-v.err"),
:wait => true,
:pid => nil,
},
{
:cmd => @emon_bin + " -M",
:out => output_file("emon-m.dat"),
:err => output_file("emon-m.err"),
:wait => true,
:pid => nil,
},
{
:cmd => @emon_bin + " -i " + "\"" + @event_file + "\"",
:out => output_file("emon.dat"),
:err => output_file("emon.err"),
:wait => false,
:pid => nil,
}
]
system("mkdir", "-p", @output_dir)
# change to manually
# load_kernel_module
cmds.each do |cmd| new_proc(cmd) end
end
def stop()
sleep 5
cmd = {
:cmd => @emon_bin + " -stop",
:out => output_file("emon-stop.out"),
:err => output_file("emon-stop.err"),
:wait => true,
:pid => nil,
}
new_proc(cmd)
end
end
if __FILE__ == $0
if ARGV.size < 3
puts "Usage:"
puts "Arg 0: install path of sep"
puts "Arg 1: the Architecture Specific txt file path"
puts "Arg 2: collection duration, in seconds"
puts "Example:"
puts "#{$0} /opt/intel/sep /opt/intel/edp/as/CascadeLake/CLX-2S/clx-2s-events.txt 10"
return -1
end
emon = Emon.new
emon.set_emon_install(ARGV[0])
emon.set_event_file(ARGV[1])
emon.start
sleep ARGV[2].to_i
emon.stop
return 0
end