perfmonger 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS +9 -0
- data/bin/perfmonger +1 -1
- data/core/perfmonger-recorder.go +4 -2
- data/lib/exec/perfmonger-recorder_darwin_amd64 +0 -0
- data/lib/exec/perfmonger-recorder_linux_386 +0 -0
- data/lib/exec/perfmonger-recorder_linux_amd64 +0 -0
- data/lib/perfmonger/command/record.rb +72 -5
- data/lib/perfmonger/command/record_option.rb +5 -0
- data/lib/perfmonger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2473ae93c9047e6068b972263656d9565cdc0d01
|
4
|
+
data.tar.gz: 834719a3b8b0b1a063b8e278b9743337de831ca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c164cd5d9d02768c1d64272340994977d44992d60dcf6e00c080b2dac5f638f2a1ce11d7bc4e00d745c1018e4312e23812c4b2b352cea9c6a87d77d0928c6faf
|
7
|
+
data.tar.gz: 3d44cf43be8f8e963f4531e992ff1abd996235c0c0fc9cfe46ae1d3127aa55fed869efcfaf6c8c12fb27ee2877961044d5c3b422f54ab154163e3efaae55307e
|
data/NEWS
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
## XXXX-XX-XX: PerfMonger 0.9.0
|
2
2
|
* ...
|
3
3
|
|
4
|
+
## 2016-11-22: PerfMonger 0.8.1
|
5
|
+
* New features
|
6
|
+
* [record] subcommand:
|
7
|
+
* Add --status to check currently running session
|
8
|
+
* Bug fixes
|
9
|
+
* [record] subcommand:
|
10
|
+
* Open correct lock file for session management
|
11
|
+
* Error handling in --kill processing (no session, already dead session PID)
|
12
|
+
|
4
13
|
## 2016-11-22: PerfMonger 0.8.0
|
5
14
|
* New features
|
6
15
|
* [record] subcommand:
|
data/bin/perfmonger
CHANGED
data/core/perfmonger-recorder.go
CHANGED
@@ -132,8 +132,7 @@ func main() {
|
|
132
132
|
if _, err := os.Stat(lockfile); err != nil {
|
133
133
|
ioutil.WriteFile(lockfile, []byte(""), 0644)
|
134
134
|
}
|
135
|
-
fd, _ := syscall.Open(
|
136
|
-
defer syscall.Close(fd)
|
135
|
+
fd, _ := syscall.Open(lockfile, syscall.O_RDONLY, 0000)
|
137
136
|
syscall.Flock(fd, syscall.LOCK_EX)
|
138
137
|
|
139
138
|
if _, err := os.Stat(session_file); err == nil {
|
@@ -143,6 +142,7 @@ func main() {
|
|
143
142
|
goto MakeNewSession
|
144
143
|
}
|
145
144
|
|
145
|
+
// check if PID in session file is valid
|
146
146
|
proc, err := os.FindProcess(pid)
|
147
147
|
err = proc.Signal(syscall.Signal(0))
|
148
148
|
|
@@ -156,9 +156,11 @@ MakeNewSession:
|
|
156
156
|
if err != nil {
|
157
157
|
panic(err)
|
158
158
|
}
|
159
|
+
defer os.Remove(session_file)
|
159
160
|
|
160
161
|
Unlock:
|
161
162
|
syscall.Flock(fd, syscall.LOCK_UN)
|
163
|
+
syscall.Close(fd)
|
162
164
|
|
163
165
|
if session_exists {
|
164
166
|
fmt.Fprintf(os.Stderr, "[ERROR] another perfmonger is already running.\n")
|
Binary file
|
Binary file
|
Binary file
|
@@ -8,6 +8,8 @@ module PerfMonger
|
|
8
8
|
module Command
|
9
9
|
|
10
10
|
class RecordCommand < BaseCommand
|
11
|
+
LOCKFILE = File.expand_path(".perfmonger.lock", Dir.tmpdir())
|
12
|
+
|
11
13
|
register_command 'record', 'Record system performance information'
|
12
14
|
|
13
15
|
def initialize
|
@@ -17,13 +19,78 @@ class RecordCommand < BaseCommand
|
|
17
19
|
def run(argv)
|
18
20
|
@argv, @option = PerfMonger::Command::RecordOption.parse(argv)
|
19
21
|
|
22
|
+
session_file = File.expand_path(sprintf("perfmonger-%s-session.pid", Etc.getlogin),
|
23
|
+
Dir.tmpdir)
|
24
|
+
begin
|
25
|
+
session_pid = File.read(session_file).to_i
|
26
|
+
rescue Errno::ENOENT
|
27
|
+
# No session file
|
28
|
+
session_pid = nil
|
29
|
+
end
|
30
|
+
|
20
31
|
if @option.kill
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
32
|
+
unless session_pid
|
33
|
+
# There is nothing to be killed
|
34
|
+
return true
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
Process.kill(:INT, session_pid)
|
39
|
+
rescue Errno::ESRCH
|
40
|
+
# Session file has invalid (already dead) PID
|
41
|
+
File.open(LOCKFILE, "w") do |f|
|
42
|
+
f.flock(File::LOCK_EX)
|
43
|
+
FileUtils.rm(session_file)
|
44
|
+
f.flock(File::LOCK_UN)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
return true
|
26
48
|
end
|
49
|
+
|
50
|
+
if @option.status
|
51
|
+
unless session_pid
|
52
|
+
puts "[ERROR] No perfmonger-recorder is running."
|
53
|
+
return false
|
54
|
+
end
|
55
|
+
|
56
|
+
begin
|
57
|
+
# check if session_pid is valid
|
58
|
+
gid = Process.getpgid(session_pid)
|
59
|
+
|
60
|
+
cmdline = File.read("/proc/#{session_pid}/cmdline").split("\0")
|
61
|
+
exe = cmdline.shift
|
62
|
+
args = cmdline
|
63
|
+
start_time = File::Stat.new("/proc/#{session_pid}").mtime
|
64
|
+
elapsed_time = Time.now - start_time
|
65
|
+
|
66
|
+
puts <<EOS
|
67
|
+
==== perfmonger record is running (PID: #{session_pid}) ====
|
68
|
+
|
69
|
+
* Running executable: #{exe}
|
70
|
+
* Arguments: #{args.join(" ")}
|
71
|
+
* Started at #{start_time} (running #{elapsed_time.to_i} sec)
|
72
|
+
|
73
|
+
EOS
|
74
|
+
rescue Errno::ESRCH
|
75
|
+
puts "[ERROR] No perfmonger-recorder is running."
|
76
|
+
end
|
77
|
+
|
78
|
+
return true
|
79
|
+
end
|
80
|
+
|
81
|
+
# run perfmonger-recorder (normal path)
|
82
|
+
begin
|
83
|
+
if session_pid && Process.getpgid(session_pid)
|
84
|
+
$stderr.puts("[ERROR] another perfmonger is already running.")
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
rescue Errno::ESRCH
|
88
|
+
# Actually there is no perfmonger running. go through.
|
89
|
+
end
|
90
|
+
|
91
|
+
exec_record_cmd()
|
92
|
+
|
93
|
+
true
|
27
94
|
end
|
28
95
|
|
29
96
|
private
|
@@ -11,6 +11,7 @@ class RecordOption
|
|
11
11
|
attr_reader :logfile
|
12
12
|
attr_reader :background
|
13
13
|
attr_reader :kill
|
14
|
+
attr_reader :status
|
14
15
|
|
15
16
|
attr_reader :parser
|
16
17
|
attr_accessor :record_bin
|
@@ -132,6 +133,10 @@ class RecordOption
|
|
132
133
|
@kill = true
|
133
134
|
end
|
134
135
|
|
136
|
+
@parser.on('--status', 'Show currently running perfmonger-record status') do
|
137
|
+
@status = true
|
138
|
+
end
|
139
|
+
|
135
140
|
@parser.on('-v', '--verbose') do
|
136
141
|
@verbose = true
|
137
142
|
end
|
data/lib/perfmonger/version.rb
CHANGED