vmstat 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c680412d4bf38d53b7b34a35b40708520fcaa521
4
- data.tar.gz: e3e5033a0556c82cfbf7f0d23e876a96c55d7065
3
+ metadata.gz: 9755d74fe2f9659eb01e1cb582a44cce556bda4a
4
+ data.tar.gz: 0d846e1cd3eb12d3fafbc1dd93f1472ffc6ab2bc
5
5
  SHA512:
6
- metadata.gz: 6070e29648a1274fe62a498f2ef4972d8f4e1fb3898e4226277eca39a82131771ac4fa21810accb082686b01f44847571409f285a95996d59cfe807a9bd73b64
7
- data.tar.gz: 4d725d090de11fbf164203d6b787f6f357dbdf8973c79633db2a4d0125b8c91946444d28eea410caf3b03a51d7051c272c87dd89d9e0456f7c06b1a75fa09281
6
+ metadata.gz: 4629bcb7856759da7f79684f50eeb5bff64e76ed1962b7b2cc91dd3203bf58eacee6608beadca990e8359f402aed0168530c9f4d345722dc688b0b6df193f63a
7
+ data.tar.gz: bfc607c69789a069fdf9c370af456f8d89b6d8adc1465ab7d8df424b8263324af818d81623860e732ac8cd7c49ceabc70cf9316c843a2d584b215c2ce81b6761
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.2.3
@@ -1,4 +1,8 @@
1
1
  language: ruby
2
+ os:
3
+ - linux
4
+ - osx
2
5
  rvm:
3
- - 1.9.3
4
- - 2.0.0
6
+ - 2.2.3
7
+ env:
8
+ - TRAVIS=true
data/README.md CHANGED
@@ -18,9 +18,12 @@ This is a focused and fast library to get system information like:
18
18
 
19
19
  *It might support (but not tested):*
20
20
 
21
+ * Older versions of linux
22
+
23
+ *It doesn't support:*
24
+
21
25
  * OpenBSD
22
26
  * NetBSD
23
- * Older versions of linux
24
27
 
25
28
  ## Installation
26
29
 
@@ -136,6 +139,7 @@ Just require the library and make a snapshot or use the distinct methods to just
136
139
  * Swap information
137
140
  * Support more platforms (hp ux, aix, solaris, ...)
138
141
  * Server performance/system information (open file handles, cache sizes, number of inodes ...)
142
+ * Add support for (Open|Net)BSD using UVM (http://cvsweb.netbsd.org/bsdweb.cgi/src/external/bsd/top/dist/machine/) and remove sysctlbyname references where possible to make it compatible
139
143
 
140
144
  ## Contributing
141
145
 
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'vmstat'
5
+
6
+ last = Vmstat.snapshot
7
+
8
+ system 'clear'
9
+ WIDTH = 60
10
+
11
+ class String
12
+ def black; "\033[30m#{self}\033[0m" end
13
+ def red; "\033[31m#{self}\033[0m" end
14
+ def green; "\033[32m#{self}\033[0m" end
15
+ def brown; "\033[33m#{self}\033[0m" end
16
+ def blue; "\033[34m#{self}\033[0m" end
17
+ def magenta; "\033[35m#{self}\033[0m" end
18
+ def cyan; "\033[36m#{self}\033[0m" end
19
+ def gray; "\033[37m#{self}\033[0m" end
20
+ def bg_black; "\033[40m#{self}\033[0m" end
21
+ def bg_red; "\033[41m#{self}\033[0m" end
22
+ def bg_green; "\033[42m#{self}\033[0m" end
23
+ def bg_brown; "\033[43m#{self}\033[0m" end
24
+ def bg_blue; "\033[44m#{self}\033[0m" end
25
+ def bg_magenta; "\033[45m#{self}\033[0m" end
26
+ def bg_cyan; "\033[46m#{self}\033[0m" end
27
+ def bg_gray; "\033[47m#{self}\033[0m" end
28
+ def bold; "\033[1m#{self}\033[22m" end
29
+ def reverse_color; "\033[7m#{self}\033[27m" end
30
+ end
31
+
32
+ MB = 1024 ** 2
33
+
34
+ loop do
35
+ current = Vmstat.snapshot
36
+ memory = current.memory
37
+ free = (memory.free_bytes + memory.inactive_bytes) / MB
38
+ used = (memory.active_bytes + memory.wired_bytes) / MB
39
+
40
+ print "\033[0;0H"
41
+ print "Memory Free: #{free.to_s.bg_gray.black} MB"
42
+ print "\tUsed: #{used.to_s.bg_gray.black} MB"
43
+ print "\tWired: #{(memory.wired_bytes / MB).to_s.bg_gray.black} MB"
44
+ puts "\tTotal: #{(memory.total_bytes / MB).to_s.bg_gray.black} MB"
45
+ current.cpus.each_with_index do |cpu, i|
46
+ user = cpu.user - last.cpus[i].user
47
+ system = cpu.system - last.cpus[i].system
48
+ idle = cpu.idle - last.cpus[i].idle
49
+
50
+ print "CPU #{i + 1} "
51
+ print " ".bg_red * (system.to_f / 100.0 * WIDTH)
52
+ print " ".bg_green * (user.to_f / 100.0 * WIDTH)
53
+ print " " * (idle.to_f / 100.0 * WIDTH)
54
+ puts
55
+ end
56
+ last = current
57
+ sleep 1
58
+ end
@@ -6,7 +6,7 @@
6
6
 
7
7
  // helper methods
8
8
  int system_int(const char *);
9
- unsigned long long system_ull(const char *);
9
+ unsigned int system_uint(const char *);
10
10
 
11
11
  typedef struct {
12
12
  long user;
@@ -56,18 +56,18 @@ int system_int(const char * name) {
56
56
  #define VMSTAT_MEMORY
57
57
  VALUE vmstat_memory(VALUE self) {
58
58
  VALUE memory = rb_funcall(rb_path2class("Vmstat::Memory"),
59
- rb_intern("new"), 7, ULL2NUM(system_ull("vm.stats.vm.v_page_size")),
60
- ULL2NUM(system_ull("vm.stats.vm.v_active_count")),
61
- ULL2NUM(system_ull("vm.stats.vm.v_wire_count")),
62
- ULL2NUM(system_ull("vm.stats.vm.v_inactive_count")),
63
- ULL2NUM(system_ull("vm.stats.vm.v_free_count")),
64
- ULL2NUM(system_ull("vm.stats.vm.v_vnodepgsin")),
65
- ULL2NUM(system_ull("vm.stats.vm.v_vnodepgsout")));
59
+ rb_intern("new"), 7, ULL2NUM(system_uint("vm.stats.vm.v_page_size")),
60
+ ULL2NUM(system_uint("vm.stats.vm.v_active_count")),
61
+ ULL2NUM(system_uint("vm.stats.vm.v_wire_count")),
62
+ ULL2NUM(system_uint("vm.stats.vm.v_inactive_count")),
63
+ ULL2NUM(system_uint("vm.stats.vm.v_free_count")),
64
+ ULL2NUM(system_uint("vm.stats.vm.v_vnodepgsin")),
65
+ ULL2NUM(system_uint("vm.stats.vm.v_vnodepgsout")));
66
66
  return memory;
67
67
  }
68
68
 
69
- unsigned long long system_ull(const char * name) {
70
- long number;
69
+ unsigned int system_uint(const char * name) {
70
+ unsigned int number;
71
71
  size_t number_size = sizeof(number);
72
72
  if (sysctlbyname(name, &number, &number_size, NULL, 0) == -1) {
73
73
  perror("sysctlbyname");
@@ -1,3 +1,3 @@
1
1
  module Vmstat
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -9,6 +9,10 @@ require 'vmstat'
9
9
  require 'ostruct'
10
10
  require 'timecop'
11
11
 
12
+ def travis?
13
+ ENV['TRAVIS'] == 'true'
14
+ end
15
+
12
16
  RSpec.configure do |config|
13
17
  config.treat_symbols_as_metadata_keys_with_true_values = true
14
18
  config.run_all_when_everything_filtered = true
@@ -14,8 +14,10 @@ describe Vmstat do
14
14
  end
15
15
 
16
16
  context "Vmstat#filter_devices" do
17
- it "should filter ethernet devices" do
18
- Vmstat.ethernet_devices.size.should >= 1
17
+ unless travis? # no external ethernet devices on travis ci
18
+ it "should filter ethernet devices" do
19
+ Vmstat.ethernet_devices.size.should >= 1
20
+ end
19
21
  end
20
22
 
21
23
  it "should filter loopback devices" do
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
22
22
  gem.extensions = ["ext/vmstat/extconf.rb"]
23
23
 
24
24
  gem.add_development_dependency('rake')
25
- gem.add_development_dependency('rspec')
25
+ gem.add_development_dependency('rspec', "~> 2.9.0")
26
26
  gem.add_development_dependency('rake-compiler')
27
27
  gem.add_development_dependency('guard-rspec')
28
28
  gem.add_development_dependency('timecop')
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmstat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Landgraf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-05 00:00:00.000000000 Z
11
+ date: 2016-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.9.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.9.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake-compiler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: timecop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: "\n A focused and fast library to gather memory, \n cpu, network,
@@ -89,16 +89,17 @@ extensions:
89
89
  - ext/vmstat/extconf.rb
90
90
  extra_rdoc_files: []
91
91
  files:
92
- - .gitignore
93
- - .rspec
94
- - .ruby-gemset
95
- - .ruby-version
96
- - .travis.yml
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".ruby-gemset"
95
+ - ".ruby-version"
96
+ - ".travis.yml"
97
97
  - Gemfile
98
98
  - Guardfile
99
99
  - LICENSE.txt
100
100
  - README.md
101
101
  - Rakefile
102
+ - examples/rtop
102
103
  - ext/vmstat/extconf.rb
103
104
  - ext/vmstat/hw/bsd.h
104
105
  - ext/vmstat/hw/mach.h
@@ -146,17 +147,17 @@ require_paths:
146
147
  - lib
147
148
  required_ruby_version: !ruby/object:Gem::Requirement
148
149
  requirements:
149
- - - '>='
150
+ - - ">="
150
151
  - !ruby/object:Gem::Version
151
152
  version: '0'
152
153
  required_rubygems_version: !ruby/object:Gem::Requirement
153
154
  requirements:
154
- - - '>='
155
+ - - ">="
155
156
  - !ruby/object:Gem::Version
156
157
  version: '0'
157
158
  requirements: []
158
159
  rubyforge_project:
159
- rubygems_version: 2.0.3
160
+ rubygems_version: 2.4.5.1
160
161
  signing_key:
161
162
  specification_version: 4
162
163
  summary: A focused and fast library to gather system information