perfmonger 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +6 -0
  3. data/.tachikoma.yml +1 -0
  4. data/.travis.yml +18 -6
  5. data/Gemfile +1 -3
  6. data/Guardfile +26 -0
  7. data/NEWS +21 -0
  8. data/README.md +8 -9
  9. data/Rakefile +33 -1
  10. data/core/Makefile +23 -0
  11. data/core/build.sh +48 -0
  12. data/core/perfmonger-player.go +165 -0
  13. data/core/perfmonger-recorder.go +296 -0
  14. data/core/perfmonger-summarizer.go +207 -0
  15. data/core/subsystem/Makefile +3 -0
  16. data/core/subsystem/perfmonger.go +60 -0
  17. data/core/subsystem/perfmonger_darwin.go +22 -0
  18. data/core/subsystem/perfmonger_linux.go +292 -0
  19. data/core/subsystem/perfmonger_linux_test.go +73 -0
  20. data/core/subsystem/stat.go +214 -0
  21. data/core/subsystem/stat_test.go +281 -0
  22. data/core/subsystem/usage.go +410 -0
  23. data/core/subsystem/usage_test.go +496 -0
  24. data/lib/exec/operationBinding.rb.svn-base +59 -0
  25. data/lib/exec/perfmonger-player_darwin_amd64 +0 -0
  26. data/lib/exec/perfmonger-player_linux_386 +0 -0
  27. data/lib/exec/perfmonger-player_linux_amd64 +0 -0
  28. data/lib/exec/perfmonger-recorder_darwin_amd64 +0 -0
  29. data/lib/exec/perfmonger-recorder_linux_386 +0 -0
  30. data/lib/exec/perfmonger-recorder_linux_amd64 +0 -0
  31. data/lib/exec/perfmonger-summarizer_darwin_amd64 +0 -0
  32. data/lib/exec/perfmonger-summarizer_linux_386 +0 -0
  33. data/lib/exec/perfmonger-summarizer_linux_amd64 +0 -0
  34. data/lib/exec/perfmonger-summary_linux_386 +0 -0
  35. data/lib/exec/perfmonger-summary_linux_amd64 +0 -0
  36. data/lib/perfmonger/cli.rb +8 -3
  37. data/lib/perfmonger/command/core.rb +62 -0
  38. data/lib/perfmonger/command/live.rb +39 -0
  39. data/lib/perfmonger/command/play.rb +56 -0
  40. data/lib/perfmonger/command/plot.rb +30 -22
  41. data/lib/perfmonger/command/record.rb +3 -2
  42. data/lib/perfmonger/command/record_option.rb +40 -59
  43. data/lib/perfmonger/command/server.rb +7 -2
  44. data/lib/perfmonger/command/stat.rb +2 -2
  45. data/lib/perfmonger/command/stat_option.rb +1 -1
  46. data/lib/perfmonger/command/summary.rb +11 -326
  47. data/lib/perfmonger/version.rb +1 -3
  48. data/lib/perfmonger.rb +3 -0
  49. data/misc/_perfmonger +128 -0
  50. data/misc/perfmonger-completion.bash +49 -0
  51. data/perfmonger.gemspec +6 -5
  52. data/spec/data/busy100.pgr +0 -0
  53. data/spec/fingerprint_spec.rb +35 -0
  54. data/spec/live_spec.rb +25 -0
  55. data/spec/perfmonger_spec.rb +37 -0
  56. data/spec/play_spec.rb +21 -0
  57. data/spec/plot_spec.rb +42 -0
  58. data/spec/record_spec.rb +15 -0
  59. data/spec/spec_helper.rb +33 -0
  60. data/spec/stat_spec.rb +15 -0
  61. data/spec/summary_spec.rb +51 -0
  62. data/spec/support/aruba.rb +11 -0
  63. data/wercker.yml +59 -0
  64. metadata +117 -45
  65. data/ext/perfmonger/extconf.rb +0 -19
  66. data/ext/perfmonger/perfmonger.h +0 -58
  67. data/ext/perfmonger/perfmonger_record.c +0 -754
  68. data/ext/perfmonger/sysstat/common.c +0 -627
  69. data/ext/perfmonger/sysstat/common.h +0 -207
  70. data/ext/perfmonger/sysstat/ioconf.c +0 -515
  71. data/ext/perfmonger/sysstat/ioconf.h +0 -84
  72. data/ext/perfmonger/sysstat/iostat.c +0 -1100
  73. data/ext/perfmonger/sysstat/iostat.h +0 -121
  74. data/ext/perfmonger/sysstat/libsysstat.h +0 -19
  75. data/ext/perfmonger/sysstat/mpstat.c +0 -953
  76. data/ext/perfmonger/sysstat/mpstat.h +0 -79
  77. data/ext/perfmonger/sysstat/rd_stats.c +0 -2388
  78. data/ext/perfmonger/sysstat/rd_stats.h +0 -651
  79. data/ext/perfmonger/sysstat/sysconfig.h +0 -13
  80. data/test/run-test.sh +0 -39
  81. data/test/spec/bin_spec.rb +0 -37
  82. data/test/spec/data/2devices.expected +0 -42
  83. data/test/spec/data/2devices.output +0 -42
  84. data/test/spec/spec_helper.rb +0 -20
  85. data/test/spec/summary_spec.rb +0 -193
  86. data/test/test-perfmonger.c +0 -145
  87. data/test/test.h +0 -9
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjYxZGNiY2FkYjQ5NGQ4ZjMxNmI4YmM4NDU4NTNhMTA4NzU1NmU4Zg==
5
- data.tar.gz: !binary |-
6
- ZGJlMDQyNzEyZWEzNWNiNGRjNGVmZjAzNzdlOGRkYTcwZjBlODllZg==
2
+ SHA1:
3
+ metadata.gz: 10a0e056a4c32cbdcd8fda187002844cd405f5cb
4
+ data.tar.gz: 6e06674d6d084318310627d557d7ae44255ef75e
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YjhlNDk4OTc0NjkwOGEzODU2MDU5MTQ4ZDE3OTkzYjY4OTZjZjAyNmU1YTk3
10
- MzI4Zjk1NjY1ZDcxMjQ0NTUxMTVmMDg5NjcwNmY4ODM5ZWJkZGIxZjhiNTg2
11
- ZDk4YTFhNzlkNTk2NGJkNjU4ZWUzNDU2MDY4M2NkOTAxMWYzY2Y=
12
- data.tar.gz: !binary |-
13
- NGU2YTBmNTY2NTdjODQ2ZjkxMWExYTJkNDBjYjhhNGQxYWNjYzMzODQ4M2M3
14
- YWZhYmY4NmI3YTUzMGY4N2NkMDM4YWMyM2VkYzg3ZTBkYWI2YmU2MWJhYzMw
15
- NjA5MDBiMjE2NzJlODMwYTU2ZDM5MWEyZDhmYTMxMTI3YTZlM2U=
6
+ metadata.gz: 096dc5864583310417f8c2906305f2806bf1a104b4ea7b5c942b61c271c9c0b997338eb8fc2bbd2de8458fe027cb6856a8034d7f5c030c9a97892db3b5741143
7
+ data.tar.gz: 6e01993d4c7bab480c0161f23d415dc608d5ce0409a5670193e8fa11b39b9c13359805ed7eac72410a37b2966125599a990865bcd4be24e16835548e64b86d3b
data/.gitignore CHANGED
@@ -2,3 +2,9 @@
2
2
  /perfmonger-*.gem
3
3
  /pkg
4
4
  /tmp
5
+ /Gemfile.lock
6
+ /core/perfmonger-player
7
+ /core/perfmonger-recorder
8
+ /lib/exec/
9
+ /ext/perfmonger/Makefile
10
+ /core/perfmonger-summarizer
data/.tachikoma.yml ADDED
@@ -0,0 +1 @@
1
+ strategy: 'bundler'
data/.travis.yml CHANGED
@@ -1,12 +1,24 @@
1
1
 
2
2
  language: ruby
3
3
  install:
4
- - sudo apt-get install libglib2.0-dev autotools-dev
4
+ - sudo apt-get update
5
+ - sudo apt-get install gnuplot
6
+ - gnuplot -e "set terminal" < /dev/null 2>&1
5
7
  - bundle install
6
- before_script:
7
- - ./autogen.sh
8
- - ./configure
9
- - make
8
+ - go_version="1.4.2"
9
+ - wget http://golang.org/dl/go${go_version}.linux-amd64.tar.gz
10
+ - sudo tar -C /usr/local -xzf go${go_version}.linux-amd64.tar.gz
11
+ - export PATH=$PATH:/usr/local/go/bin
12
+ - export GOPATH="$HOME/go"
13
+ - export PATH="$PATH:$GOPATH/bin"
14
+ - mkdir -p "$HOME/go/{src,pkg,bin}"
15
+ - go get -u golang.org/x/crypto/ssh/terminal
16
+ - go get -u github.com/hayamiz/perfmonger/core/subsystem
10
17
  rvm:
11
- - 1.8.7
12
18
  - 1.9.3
19
+ - 2.0.0
20
+ - 2.1.5
21
+ - 2.2.0
22
+ script:
23
+ - rake spec
24
+ - rake test_core
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rake'
4
- gem 'rspec'
5
- gem 'rake-compiler'
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,26 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ guard :rspec, cmd: "bundle exec rspec" do
11
+ require "guard/rspec/dsl"
12
+ dsl = Guard::RSpec::Dsl.new(self)
13
+
14
+ # Feel free to open issues for suggestions and improvements
15
+
16
+ # RSpec files
17
+ rspec = dsl.rspec
18
+ watch(rspec.spec_helper) { rspec.spec_dir }
19
+ watch(rspec.spec_support) { rspec.spec_dir }
20
+ watch(rspec.spec_files)
21
+
22
+ # Ruby files
23
+ ruby = dsl.ruby
24
+ dsl.watch_spec_files_for(ruby.lib_files)
25
+ watch(%r{^lib/(.+)\.rb$}) { "spec" }
26
+ end
data/NEWS CHANGED
@@ -1,3 +1,24 @@
1
+ ## 2015-03-08: PerfMonger 0.7.0 released
2
+
3
+ * New features
4
+ * Bash completion support
5
+ * Zsh completion support
6
+ * [live] subcommand:
7
+ * Record and play perfmonger log in JSON
8
+ * [record] subcommand:
9
+ * Add Network device usage
10
+ * [play] subcommand:
11
+ * Play a perfmonger log and print in JSON
12
+ * Changes
13
+ * [record] subcommand:
14
+ * Its core was completely rewritten in Go and records data in encoding/gob format
15
+ * Carve out JSON output function to [play] subcommand
16
+ * Bug fixes
17
+ * [plot] subcommand:
18
+ * Correctly find supported terminal
19
+ * [server] subcommand:
20
+ * Disambiguate command line options
21
+
1
22
  ## 2015-01-18: PerfMonger 0.6.0 released
2
23
 
3
24
  * New features
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  PerfMonger
2
2
  ============
3
3
 
4
+ [![Build Status](https://travis-ci.org/hayamiz/perfmonger.svg?branch=master)](https://travis-ci.org/hayamiz/perfmonger)
5
+
6
+ [![wercker status](https://app.wercker.com/status/44c3ade6a2406d337df6d93097a52fdf/m "wercker status")](https://app.wercker.com/project/bykey/44c3ade6a2406d337df6d93097a52fdf)
7
+
4
8
  PerfMonger is an yet anothor performance measurement/monitoring tool
5
9
  speaking JSON.
6
10
 
@@ -12,23 +16,18 @@ speaking JSON.
12
16
 
13
17
  ## Prerequisites
14
18
 
15
- * Ruby 1.8.7 or later
16
- * Ruby 1.9.3 or later is recommended
17
- * gnuplot (optional)
19
+ * Ruby 1.9.3 or later
20
+ * gnuplot 4.6.0 or later (optional)
18
21
 
19
22
  Note: You need Cutter unit testing framework for building/running tests.
20
23
 
21
24
  ## How to install
22
25
 
23
- ### RHEL or CentOS
24
-
25
- rpm -Uvh http://package.hayamiz.com/hayamiz-repos-1.0.0-0.noarch.rpm
26
- yum install perfmonger
26
+ gem install perfmonger
27
27
 
28
28
  ### Build from source
29
29
 
30
- ./configure
31
- sudo make install
30
+ rake build
32
31
 
33
32
  ## How to use: case study
34
33
 
data/Rakefile CHANGED
@@ -2,7 +2,39 @@ require 'rubygems'
2
2
  require 'rspec/core/rake_task'
3
3
  require "bundler/gem_tasks"
4
4
 
5
- task :default => [:spec]
5
+ task :default => [:spec, :test_core]
6
6
 
7
7
  desc "Run all specs in spec directory"
8
8
  RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task :spec => [:self_build_core]
11
+
12
+ desc "Cross build core recorder/player"
13
+ task :cross_build_core do
14
+ puts "Buildling binaries for each platform"
15
+ Dir.chdir("./core") do
16
+ sh "./build.sh"
17
+ end
18
+ end
19
+
20
+ desc "Self build core recorder/player"
21
+ task :self_build_core do
22
+ Dir.chdir("./core") do
23
+ sh "./build.sh -"
24
+ end
25
+ end
26
+
27
+ task :build => :cross_build_core
28
+
29
+ desc "Run tests of core recorder/player"
30
+ task :test_core do
31
+ Dir.chdir("./core/subsystem") do
32
+ sh "go test -v -cover"
33
+ end
34
+ end
35
+
36
+ desc "Removed generated files"
37
+ task :clean do
38
+ sh "make -C core clean"
39
+ end
40
+
data/core/Makefile ADDED
@@ -0,0 +1,23 @@
1
+
2
+ GOSRC := \
3
+ subsystem/perfmonger.go \
4
+ subsystem/perfmonger_linux.go \
5
+ subsystem/stat.go \
6
+ subsystem/usage.go
7
+
8
+ .PHONY: all clean
9
+
10
+ all: perfmonger-recorder perfmonger-player perfmonger-summarizer
11
+
12
+ clean:
13
+ rm -f perfmonger-recorder perfmonger-player perfmonger-summarizer
14
+
15
+ perfmonger-recorder: perfmonger-recorder.go $(GOSRC)
16
+ go build $<
17
+
18
+ perfmonger-player: perfmonger-player.go $(GOSRC)
19
+ go build $<
20
+
21
+ perfmonger-summarizer: perfmonger-summarizer.go $(GOSRC)
22
+ go build $<
23
+
data/core/build.sh ADDED
@@ -0,0 +1,48 @@
1
+ #!/bin/bash
2
+
3
+ READLINK=$(type -p greadlink readlink | head -1)
4
+ cd $(dirname $($READLINK -f $0))
5
+
6
+ if [ $1 = "-" ]; then
7
+ # do self build
8
+ case `uname -s` in
9
+ (Linux)
10
+ os="linux"
11
+ ;;
12
+ (Darwin)
13
+ os="darwin"
14
+ ;;
15
+ (*)
16
+ os=""
17
+ ;;
18
+ esac
19
+ case `uname -m` in
20
+ (x86_64|amd64)
21
+ arch="amd64"
22
+ ;;
23
+ (*)
24
+ arch=""
25
+ ;;
26
+ esac
27
+
28
+ TARGET=("${os} ${arch}")
29
+ else
30
+ # cross build
31
+ TARGET=("linux 386" "linux amd64" "darwin amd64")
32
+ fi
33
+
34
+ set -xe
35
+
36
+ for idx in $(seq 0 $((${#TARGET[@]}-1))); do
37
+ set -- ${TARGET[$idx]}
38
+ export GOOS=$1
39
+ export GOARCH=$2
40
+
41
+ go build -o ../lib/exec/perfmonger-recorder_${GOOS}_${GOARCH} \
42
+ perfmonger-recorder.go
43
+ go build -o ../lib/exec/perfmonger-player_${GOOS}_${GOARCH} \
44
+ perfmonger-player.go
45
+ go build -o ../lib/exec/perfmonger-summarizer_${GOOS}_${GOARCH} \
46
+ perfmonger-summarizer.go
47
+ done
48
+
@@ -0,0 +1,165 @@
1
+ //usr/bin/env go run $0 $@ ; exit
2
+
3
+ package main
4
+
5
+ import (
6
+ "bufio"
7
+ "bytes"
8
+ "encoding/gob"
9
+ "fmt"
10
+ "io"
11
+ "os"
12
+
13
+ ss "github.com/hayamiz/perfmonger/core/subsystem"
14
+ )
15
+
16
+ func showCpuStat(buffer *bytes.Buffer, prev_rec *ss.StatRecord, cur_rec *ss.StatRecord) error {
17
+ cusage, err := ss.GetCpuUsage(prev_rec.Cpu, cur_rec.Cpu)
18
+ if err != nil {
19
+ return err
20
+ }
21
+ buffer.WriteString(`,"cpu":`)
22
+ cusage.WriteJsonTo(buffer)
23
+
24
+ return nil
25
+ }
26
+
27
+ func showDiskStat(buffer *bytes.Buffer, prev_rec *ss.StatRecord, cur_rec *ss.StatRecord) error {
28
+ dusage, err := ss.GetDiskUsage(
29
+ prev_rec.Time, prev_rec.Disk,
30
+ cur_rec.Time, cur_rec.Disk,
31
+ )
32
+ if err != nil {
33
+ return err
34
+ }
35
+
36
+ buffer.WriteString(`,"disk":`)
37
+ dusage.WriteJsonTo(buffer)
38
+
39
+ return nil
40
+ }
41
+
42
+ func showNetStat(buffer *bytes.Buffer, prev_rec *ss.StatRecord, cur_rec *ss.StatRecord) error {
43
+ dusage, err := ss.GetNetUsage(
44
+ prev_rec.Time, prev_rec.Net,
45
+ cur_rec.Time, cur_rec.Net,
46
+ )
47
+ if err != nil {
48
+ return err
49
+ }
50
+
51
+ buffer.WriteString(`,"net":`)
52
+ dusage.WriteJsonTo(buffer)
53
+
54
+ return nil
55
+ }
56
+
57
+ func showStat(buffer *bytes.Buffer, prev_rec *ss.StatRecord, cur_rec *ss.StatRecord) error {
58
+ buffer.WriteString(fmt.Sprintf(`{"time":%.3f`, float64(cur_rec.Time.UnixNano())/1e9))
59
+ if cur_rec.Cpu != nil {
60
+ err := showCpuStat(buffer, prev_rec, cur_rec)
61
+ if err != nil {
62
+ return err
63
+ }
64
+ }
65
+ if cur_rec.Disk != nil {
66
+ err := showDiskStat(buffer, prev_rec, cur_rec)
67
+ if err != nil {
68
+ return err
69
+ }
70
+ }
71
+ if cur_rec.Net != nil {
72
+ err := showNetStat(buffer, prev_rec, cur_rec)
73
+ if err != nil {
74
+ return err
75
+ }
76
+ }
77
+ buffer.WriteString("}\n")
78
+
79
+ return nil
80
+ }
81
+
82
+ func main() {
83
+ args := os.Args
84
+ var in *os.File
85
+ var out *bufio.Writer
86
+
87
+ if len(args) < 2 {
88
+ in = os.Stdin
89
+ } else {
90
+ f, err := os.Open(args[1])
91
+ if err != nil {
92
+ panic(err)
93
+ }
94
+ in = f
95
+ defer f.Close()
96
+ }
97
+
98
+ out = bufio.NewWriter(os.Stdout)
99
+
100
+ dec := gob.NewDecoder(in)
101
+
102
+ var cheader ss.CommonHeader
103
+ var pheader ss.PlatformHeader
104
+ var records = make([]ss.StatRecord, 2)
105
+ curr := 0
106
+
107
+ var err error
108
+
109
+ err = dec.Decode(&cheader)
110
+ if err == io.EOF {
111
+ return
112
+ }
113
+ if err != nil {
114
+ panic(err)
115
+ }
116
+ err = dec.Decode(&pheader)
117
+ if err == io.EOF {
118
+ return
119
+ }
120
+ if err != nil {
121
+ panic(err)
122
+ }
123
+
124
+ // read first record
125
+ err = dec.Decode(&records[curr])
126
+ if err == io.EOF {
127
+ return
128
+ } else if err != nil {
129
+ panic(err)
130
+ }
131
+ curr ^= 1
132
+
133
+ buffer := bytes.NewBuffer([]byte{})
134
+ for {
135
+ prev_rec := &records[curr^1]
136
+ cur_rec := &records[curr]
137
+
138
+ err = dec.Decode(cur_rec)
139
+ if err == io.EOF {
140
+ break
141
+ } else if err != nil {
142
+ panic(err)
143
+ }
144
+
145
+ err = showStat(buffer, prev_rec, cur_rec)
146
+ if err != nil {
147
+ buffer.Reset()
148
+ fmt.Fprintln(os.Stderr, "skip by err")
149
+ continue
150
+ }
151
+
152
+ _, err = out.WriteString(buffer.String())
153
+ err = out.Flush()
154
+ if err != nil {
155
+ // stdout is closed
156
+ break
157
+ }
158
+
159
+ buffer.Reset()
160
+
161
+ curr ^= 1
162
+ }
163
+
164
+ return
165
+ }