vmstat 2.2.1 → 2.3.0

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: 4d77a479676667732658bffbc383e7f08126194e
4
- data.tar.gz: 2e9ba271cb534a4e28c8c0ddee82f924f239b192
3
+ metadata.gz: 270d5935651f3bf75549887dee9708dc5c8bdf28
4
+ data.tar.gz: 1491b07f6a67857fd7e4f005e59cd52c68000ef9
5
5
  SHA512:
6
- metadata.gz: 5b246e0c49c11135483838d95efcd40eeb35336ab22c8df356921d233dadf2b6063746648e2d201a08d732fe860b3a77707913f76ab6348c92b3d3f859d759cf
7
- data.tar.gz: 2e17039e4ca2b48f4f5668251c1b2a29389d96a68e9ef73c0961d12c9bd7ac3daab8521935a5e1bddb2f90f5f0d4bca7b9158e58b3f6b1ed36e7e89a59c1b294
6
+ metadata.gz: be3f4ddbb591d02330d44aa3e85b88b782321ebf48a2d853e5563a8c25c9589a8f3303cac7df976082faef794d813c999ef73ec8d1c7694118dcaa13caf5681b
7
+ data.tar.gz: 86e091e9993b4293d1f88bee7f15445b99009064482b0b5b031f0e13e5236dd0d9c8a01f08434c291c313358835824bfb84cdf0859fc9d1e26f114c006b29053
data/.gitignore CHANGED
@@ -4,7 +4,6 @@
4
4
  .config
5
5
  .yardoc
6
6
  .DS_Store
7
- Gemfile.lock
8
7
  InstalledFiles
9
8
  _yardoc
10
9
  coverage
@@ -1 +1 @@
1
- 2.2.4
1
+ 2.2.6
@@ -2,7 +2,7 @@ language: ruby
2
2
  os:
3
3
  - linux
4
4
  rvm:
5
- - ruby-2.2.5
5
+ - ruby-2.2.6
6
6
  - ruby-head
7
7
  env:
8
8
  - TRAVIS=true
@@ -0,0 +1,73 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vmstat (2.3.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.1)
10
+ diff-lcs (1.2.5)
11
+ ffi (1.9.14)
12
+ formatador (0.2.5)
13
+ guard (2.14.0)
14
+ formatador (>= 0.2.4)
15
+ listen (>= 2.7, < 4.0)
16
+ lumberjack (~> 1.0)
17
+ nenv (~> 0.1)
18
+ notiffany (~> 0.0)
19
+ pry (>= 0.9.12)
20
+ shellany (~> 0.0)
21
+ thor (>= 0.18.1)
22
+ guard-compat (1.2.1)
23
+ guard-rspec (4.7.3)
24
+ guard (~> 2.1)
25
+ guard-compat (~> 1.1)
26
+ rspec (>= 2.99.0, < 4.0)
27
+ listen (3.1.5)
28
+ rb-fsevent (~> 0.9, >= 0.9.4)
29
+ rb-inotify (~> 0.9, >= 0.9.7)
30
+ ruby_dep (~> 1.2)
31
+ lumberjack (1.0.10)
32
+ method_source (0.8.2)
33
+ nenv (0.3.0)
34
+ notiffany (0.1.1)
35
+ nenv (~> 0.1)
36
+ shellany (~> 0.0)
37
+ pry (0.10.4)
38
+ coderay (~> 1.1.0)
39
+ method_source (~> 0.8.1)
40
+ slop (~> 3.4)
41
+ rake (11.3.0)
42
+ rake-compiler (1.0.3)
43
+ rake
44
+ rb-fsevent (0.9.8)
45
+ rb-inotify (0.9.7)
46
+ ffi (>= 0.5.0)
47
+ rspec (2.99.0)
48
+ rspec-core (~> 2.99.0)
49
+ rspec-expectations (~> 2.99.0)
50
+ rspec-mocks (~> 2.99.0)
51
+ rspec-core (2.99.2)
52
+ rspec-expectations (2.99.2)
53
+ diff-lcs (>= 1.1.3, < 2.0)
54
+ rspec-mocks (2.99.4)
55
+ ruby_dep (1.5.0)
56
+ shellany (0.0.1)
57
+ slop (3.6.0)
58
+ thor (0.19.4)
59
+ timecop (0.8.1)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ guard-rspec
66
+ rake (~> 11.3)
67
+ rake-compiler
68
+ rspec (~> 2.9)
69
+ timecop
70
+ vmstat!
71
+
72
+ BUNDLED WITH
73
+ 1.13.6
@@ -15,6 +15,7 @@ module Vmstat
15
15
  autoload :Disk, "vmstat/disk"
16
16
  autoload :LinuxDisk, "vmstat/linux_disk"
17
17
  autoload :Memory, "vmstat/memory"
18
+ autoload :LinuxMemory, "vmstat/linux_memory"
18
19
  autoload :Task, "vmstat/task"
19
20
  autoload :LoadAverage, "vmstat/load_average"
20
21
  autoload :ProcFS, "vmstat/procfs"
@@ -0,0 +1,13 @@
1
+ # @attr [Fixnum] available
2
+ # The estimated available memory (linux)
3
+ # See: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
4
+ class Vmstat::LinuxMemory < Vmstat::Memory
5
+ attr_accessor :available
6
+
7
+ # Calculate the available bytes based of the active pages.
8
+ # @return [Fixnum] active bytes
9
+ def available_bytes
10
+ available * pagesize
11
+ end
12
+ end
13
+
@@ -19,7 +19,7 @@ module Vmstat
19
19
  # Calculate the wired bytes based of the wired pages.
20
20
  # @return [Fixnum] wired bytes
21
21
  def wired_bytes
22
- wired * pagesize
22
+ wired * pagesize
23
23
  end
24
24
 
25
25
  # Calculate the active bytes based of the active pages.
@@ -43,7 +43,20 @@ module Vmstat
43
43
  # Calculate the total bytes based of all pages
44
44
  # @return [Fixnum] total bytes
45
45
  def total_bytes
46
- (wired + active + inactive + free) * pagesize
46
+ (wired + active + inactive + free) * pagesize
47
+ end
48
+ end
49
+
50
+ # @attr [Fixnum] available
51
+ # The estimated available memory (linux)
52
+ # See: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
53
+ class LinuxMemory < Memory
54
+ attr_accessor :available
55
+
56
+ # Calculate the available bytes based of the active pages.
57
+ # @return [Fixnum] active bytes
58
+ def available_bytes
59
+ available * pagesize
47
60
  end
48
61
  end
49
62
  end
@@ -45,17 +45,21 @@ module Vmstat
45
45
  # Vmstat.memory # => #<struct Vmstat::Memory ...>
46
46
  def memory
47
47
  @pagesize ||= Vmstat.pagesize
48
+ has_available = false
48
49
 
49
- total = free = active = inactive = pageins = pageouts = 0
50
+ total = free = active = inactive = pageins = pageouts = available = 0
50
51
  procfs_file("meminfo") do |file|
51
52
  content = file.read(2048) # the requested information is in the first bytes
52
53
 
53
- content.scan(/(\w+):\s+(\d+) kB/) do |name, kbytes|
54
+ content.scan(/(\w+):\s+(\d+) kB/) do |name, kbytes|
54
55
  pages = (kbytes.to_i * 1024) / @pagesize
55
56
 
56
57
  case name
57
58
  when "MemTotal" then total = pages
58
59
  when "MemFree" then free = pages
60
+ when "MemAvailable"
61
+ available = pages
62
+ has_available = true
59
63
  when "Active" then active = pages
60
64
  when "Inactive" then inactive = pages
61
65
  end
@@ -74,8 +78,11 @@ module Vmstat
74
78
  end
75
79
  end
76
80
 
77
- Memory.new @pagesize, total-free-active-inactive, active, inactive, free,
78
- pageins, pageouts
81
+ mem_klass = has_available ? LinuxMemory : Memory
82
+ mem_klass.new(@pagesize, total-free-active-inactive, active,
83
+ inactive, free, pageins, pageouts).tap do |mem|
84
+ mem.available = available if has_available
85
+ end
79
86
  end
80
87
 
81
88
  # Fetches the information for all available network devices.
@@ -91,8 +98,8 @@ module Vmstat
91
98
  when /^lo/ then NetworkInterface::LOOPBACK_TYPE
92
99
  end
93
100
 
94
- netifcs << NetworkInterface.new(columns[0].to_sym, columns[1].to_i,
95
- columns[3].to_i, columns[4].to_i,
101
+ netifcs << NetworkInterface.new(columns[0].to_sym, columns[1].to_i,
102
+ columns[3].to_i, columns[4].to_i,
96
103
  columns[9].to_i, columns[11].to_i,
97
104
  type)
98
105
  end
@@ -107,7 +114,7 @@ module Vmstat
107
114
 
108
115
  procfs_file("self", "stat") do |file|
109
116
  data = file.read.split(/ /)
110
- Task.new(data[22].to_i / @pagesize, data[23].to_i,
117
+ Task.new(data[22].to_i / @pagesize, data[23].to_i,
111
118
  data[13].to_i * 1000, data[14].to_i * 1000)
112
119
  end
113
120
  end
@@ -1,3 +1,3 @@
1
1
  module Vmstat
2
- VERSION = "2.2.1"
2
+ VERSION = "2.3.0"
3
3
  end
@@ -0,0 +1,43 @@
1
+ MemTotal: 1884428 kB
2
+ MemFree: 252452 kB
3
+ MemAvailable: 458368 kB
4
+ Buffers: 76 kB
5
+ Cached: 321752 kB
6
+ SwapCached: 4 kB
7
+ Active: 1307912 kB
8
+ Inactive: 177976 kB
9
+ Active(anon): 1074332 kB
10
+ Inactive(anon): 106548 kB
11
+ Active(file): 233580 kB
12
+ Inactive(file): 71428 kB
13
+ Unevictable: 21100 kB
14
+ Mlocked: 21100 kB
15
+ SwapTotal: 2097148 kB
16
+ SwapFree: 2097140 kB
17
+ Dirty: 60 kB
18
+ Writeback: 0 kB
19
+ AnonPages: 1185204 kB
20
+ Mapped: 101384 kB
21
+ Shmem: 8760 kB
22
+ Slab: 59380 kB
23
+ SReclaimable: 27064 kB
24
+ SUnreclaim: 32316 kB
25
+ KernelStack: 4528 kB
26
+ PageTables: 21592 kB
27
+ NFS_Unstable: 0 kB
28
+ Bounce: 0 kB
29
+ WritebackTmp: 0 kB
30
+ CommitLimit: 3039360 kB
31
+ Committed_AS: 2906080 kB
32
+ VmallocTotal: 34359738367 kB
33
+ VmallocUsed: 269704 kB
34
+ VmallocChunk: 34359466492 kB
35
+ HardwareCorrupted: 0 kB
36
+ AnonHugePages: 659456 kB
37
+ HugePages_Total: 0
38
+ HugePages_Free: 0
39
+ HugePages_Rsvd: 0
40
+ HugePages_Surp: 0
41
+ Hugepagesize: 2048 kB
42
+ DirectMap4k: 26624 kB
43
+ DirectMap2M: 2070528 kB
@@ -0,0 +1,89 @@
1
+ nr_free_pages 107062
2
+ nr_inactive_anon 60
3
+ nr_active_anon 1557
4
+ nr_inactive_file 8341
5
+ nr_active_file 4939
6
+ nr_unevictable 0
7
+ nr_mlock 0
8
+ nr_anon_pages 1579
9
+ nr_mapped 1461
10
+ nr_file_pages 13346
11
+ nr_dirty 1
12
+ nr_writeback 0
13
+ nr_slab_reclaimable 1628
14
+ nr_slab_unreclaimable 1885
15
+ nr_page_table_pages 101
16
+ nr_kernel_stack 88
17
+ nr_unstable 0
18
+ nr_bounce 0
19
+ nr_vmscan_write 0
20
+ nr_vmscan_immediate_reclaim 0
21
+ nr_writeback_temp 0
22
+ nr_isolated_anon 0
23
+ nr_isolated_file 0
24
+ nr_shmem 67
25
+ nr_dirtied 185
26
+ nr_written 182
27
+ nr_anon_transparent_hugepages 0
28
+ nr_dirty_threshold 24392
29
+ nr_dirty_background_threshold 12196
30
+ pgpgin 64599
31
+ pgpgout 1104
32
+ pswpin 0
33
+ pswpout 0
34
+ pgalloc_dma 2
35
+ pgalloc_normal 190973
36
+ pgalloc_high 0
37
+ pgalloc_movable 0
38
+ pgfree 298439
39
+ pgactivate 5802
40
+ pgdeactivate 0
41
+ pgfault 581461
42
+ pgmajfault 42
43
+ pgrefill_dma 0
44
+ pgrefill_normal 0
45
+ pgrefill_high 0
46
+ pgrefill_movable 0
47
+ pgsteal_dma 0
48
+ pgsteal_normal 0
49
+ pgsteal_high 0
50
+ pgsteal_movable 0
51
+ pgscan_kswapd_dma 0
52
+ pgscan_kswapd_normal 0
53
+ pgscan_kswapd_high 0
54
+ pgscan_kswapd_movable 0
55
+ pgscan_direct_dma 0
56
+ pgscan_direct_normal 0
57
+ pgscan_direct_high 0
58
+ pgscan_direct_movable 0
59
+ pginodesteal 0
60
+ slabs_scanned 0
61
+ kswapd_steal 0
62
+ kswapd_inodesteal 0
63
+ kswapd_low_wmark_hit_quickly 0
64
+ kswapd_high_wmark_hit_quickly 0
65
+ kswapd_skip_congestion_wait 0
66
+ pageoutrun 1
67
+ allocstall 0
68
+ pgrotated 0
69
+ compact_blocks_moved 0
70
+ compact_pages_moved 0
71
+ compact_pagemigrate_failed 0
72
+ compact_stall 0
73
+ compact_fail 0
74
+ compact_success 0
75
+ htlb_buddy_alloc_success 0
76
+ htlb_buddy_alloc_fail 0
77
+ unevictable_pgs_culled 0
78
+ unevictable_pgs_scanned 0
79
+ unevictable_pgs_rescued 0
80
+ unevictable_pgs_mlocked 0
81
+ unevictable_pgs_munlocked 0
82
+ unevictable_pgs_cleared 0
83
+ unevictable_pgs_stranded 0
84
+ unevictable_pgs_mlockfreed 0
85
+ thp_fault_alloc 0
86
+ thp_fault_fallback 0
87
+ thp_collapse_alloc 0
88
+ thp_collapse_alloc_failed 0
89
+ thp_split 0
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vmstat::LinuxMemory do
4
+ let(:procfs) do
5
+ Class.new do
6
+ extend Vmstat::ProcFS
7
+
8
+ def self.procfs_path
9
+ File.expand_path("../../memavail_procfs", __FILE__)
10
+ end
11
+ end
12
+ end
13
+
14
+ context "#memory" do
15
+ subject { procfs.memory }
16
+
17
+ it { should be_a(Vmstat::LinuxMemory) }
18
+ if `getconf PAGESIZE`.chomp.to_i == 4096
19
+ it do
20
+ should == Vmstat::LinuxMemory.new(4096, 36522, 326978,
21
+ 44494, 63113, 64599, 1104)
22
+ end
23
+
24
+ it "should have the right total" do
25
+ (subject.wired_bytes + subject.active_bytes +
26
+ subject.inactive_bytes + subject.free_bytes).should == 1929654272
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -21,8 +21,8 @@ Gem::Specification.new do |gem|
21
21
  gem.require_paths = ["lib"]
22
22
  gem.extensions = ["ext/vmstat/extconf.rb"]
23
23
 
24
- gem.add_development_dependency('rake')
25
- gem.add_development_dependency('rspec', "~> 2.9")
24
+ gem.add_development_dependency('rake', '~> 11.3')
25
+ gem.add_development_dependency('rspec', '~> 2.9')
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,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmstat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Landgraf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-20 00:00:00.000000000 Z
11
+ date: 2016-12-26 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
- version: '0'
19
+ version: '11.3'
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
- version: '0'
26
+ version: '11.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +95,7 @@ files:
95
95
  - ".ruby-version"
96
96
  - ".travis.yml"
97
97
  - Gemfile
98
+ - Gemfile.lock
98
99
  - Guardfile
99
100
  - LICENSE.txt
100
101
  - README.md
@@ -112,6 +113,7 @@ files:
112
113
  - lib/vmstat/cpu.rb
113
114
  - lib/vmstat/disk.rb
114
115
  - lib/vmstat/linux_disk.rb
116
+ - lib/vmstat/linux_memory.rb
115
117
  - lib/vmstat/load_average.rb
116
118
  - lib/vmstat/memory.rb
117
119
  - lib/vmstat/netopenbsd.rb
@@ -122,6 +124,8 @@ files:
122
124
  - lib/vmstat/stub.rb
123
125
  - lib/vmstat/task.rb
124
126
  - lib/vmstat/version.rb
127
+ - spec/memavail_procfs/meminfo
128
+ - spec/memavail_procfs/vmstat
125
129
  - spec/procfs/loadavg
126
130
  - spec/procfs/meminfo
127
131
  - spec/procfs/net/dev
@@ -133,6 +137,7 @@ files:
133
137
  - spec/vmstat/cpu_spec.rb
134
138
  - spec/vmstat/disk_spec.rb
135
139
  - spec/vmstat/load_average_spec.rb
140
+ - spec/vmstat/memavail_spec.rb
136
141
  - spec/vmstat/memory_spec.rb
137
142
  - spec/vmstat/network_spec.rb
138
143
  - spec/vmstat/procfs_spec.rb
@@ -165,6 +170,8 @@ signing_key:
165
170
  specification_version: 4
166
171
  summary: A focused and fast library to gather system information
167
172
  test_files:
173
+ - spec/memavail_procfs/meminfo
174
+ - spec/memavail_procfs/vmstat
168
175
  - spec/procfs/loadavg
169
176
  - spec/procfs/meminfo
170
177
  - spec/procfs/net/dev
@@ -176,6 +183,7 @@ test_files:
176
183
  - spec/vmstat/cpu_spec.rb
177
184
  - spec/vmstat/disk_spec.rb
178
185
  - spec/vmstat/load_average_spec.rb
186
+ - spec/vmstat/memavail_spec.rb
179
187
  - spec/vmstat/memory_spec.rb
180
188
  - spec/vmstat/network_spec.rb
181
189
  - spec/vmstat/procfs_spec.rb