vmstator 2.0.4 → 2.1.0
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/Gemfile.lock +2 -2
- data/README.md +5 -1
- data/examples/linux_example.rb +32 -0
- data/examples/macOS_example.rb +29 -0
- data/lib/vmstator.rb +58 -40
- data/lib/vmstator/{active.rb → linux/active.rb} +0 -0
- data/lib/vmstator/{average.rb → linux/average.rb} +0 -0
- data/lib/vmstator/{cache.rb → linux/cache.rb} +0 -0
- data/lib/vmstator/{disk.rb → linux/disk.rb} +0 -0
- data/lib/vmstator/{disk_statistics.rb → linux/disk_statistics.rb} +0 -0
- data/lib/vmstator/{disk_summary.rb → linux/disk_summary.rb} +0 -0
- data/lib/vmstator/{event_counter_statistics.rb → linux/event_counter_statistics.rb} +0 -0
- data/lib/vmstator/{memory.rb → linux/memory.rb} +0 -0
- data/lib/vmstator/{parser.rb → linux/parser.rb} +0 -0
- data/lib/vmstator/{slab_info.rb → linux/slab_info.rb} +0 -0
- data/lib/vmstator/macos/pages.rb +58 -0
- data/lib/vmstator/version.rb +1 -1
- data/pkg/vmstator-2.0.4.gem +0 -0
- data/pkg/vmstator-2.1.0.gem +0 -0
- metadata +17 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85df90cea71304f1d1425813adf72f828fda9ad
|
4
|
+
data.tar.gz: 1e3611b676d28290bc3adde06b0e05f66c4f5b7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 238ecaa11790d77c4c208a5b26b6ffefd3698903362c31c3a59ef66ae298e474999bd6970727beb50dfe8e48d5763a37a2244c4cfda1d4f06390b928399bf009
|
7
|
+
data.tar.gz: 8d5b8f87992b861901f1d1ca88476c5e03d531b8dbef238cb8191596ba8698720cb86a164ba75b8180abe025a79d4cdb61ba453563442d7f899f95e2596974e4
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,13 @@
|
|
2
2
|
|
3
3
|
Vmstator is a Ruby API for [vmstat](https://en.wikipedia.org/wiki/Vmstat). It provides an [OO](https://www.tutorialspoint.com/ruby/ruby_object_oriented.htm) interface to be able to parse the contents of the output of vmstat and access that infromation intuitively.
|
4
4
|
|
5
|
+
#### Supported Platforms
|
6
|
+
|
7
|
+
Currently working on / testing on Debian GNU/Linux 8
|
8
|
+
|
5
9
|
## Screen Shot
|
6
10
|
|
7
|
-

|
8
12
|
|
9
13
|
## Installation
|
10
14
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Path setting slight of hand:
|
2
|
+
$: << File.expand_path("../../lib", __FILE__)
|
3
|
+
require 'vmstator'
|
4
|
+
|
5
|
+
parser = Vmstator::Parser.new
|
6
|
+
|
7
|
+
parser.active
|
8
|
+
# => Vmstator::DiskSummary
|
9
|
+
|
10
|
+
parser.average
|
11
|
+
# => Vmstator::DiskSummary
|
12
|
+
|
13
|
+
parser.disk_statistics
|
14
|
+
# => Vmstator::DiskStatistics
|
15
|
+
|
16
|
+
parser.disk_summary
|
17
|
+
# => Vmstator::DiskSummary
|
18
|
+
|
19
|
+
parser.event_counter_statistics
|
20
|
+
# => Vmstator::EventCounterStatistics
|
21
|
+
|
22
|
+
parser.slab_info
|
23
|
+
# => Vmstator::SlabInfo
|
24
|
+
|
25
|
+
parser.forks
|
26
|
+
# => Integer
|
27
|
+
|
28
|
+
parser.parse("-a -S m")
|
29
|
+
# => Whatever the flags were will determine output.
|
30
|
+
|
31
|
+
parser.version
|
32
|
+
# => String containing vmstat's version number.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Path setting slight of hand:
|
2
|
+
$: << File.expand_path("../../lib", __FILE__)
|
3
|
+
require 'vmstator'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
parser = Vmstator::Parser.new
|
7
|
+
macos_pages = parser.parse
|
8
|
+
|
9
|
+
puts " Active: " + macos_pages.active.to_s
|
10
|
+
puts " Anonymous: " + macos_pages.anonymous.to_s
|
11
|
+
puts " Compressions: " + macos_pages.compressions.to_s
|
12
|
+
puts " Copy on Write: " + macos_pages.copy_on_write.to_s
|
13
|
+
puts " Decompressions: " + macos_pages.decompressions.to_s
|
14
|
+
puts " File Backed: " + macos_pages.file_backed.to_s
|
15
|
+
puts " Pages Free: " + macos_pages.free.to_s
|
16
|
+
puts " Inactive: " + macos_pages.inactive.to_s
|
17
|
+
puts " Ins: " + macos_pages.ins.to_s
|
18
|
+
puts "Occupied by Compressor: " + macos_pages.occupied_by_compressor.to_s
|
19
|
+
puts " Outs: " + macos_pages.outs.to_s
|
20
|
+
puts " Purgeable: " + macos_pages.purgeable.to_s
|
21
|
+
puts " Reactivated: " + macos_pages.reactivated.to_s
|
22
|
+
puts " Stored in Compressor: " + macos_pages.stored_in_compressor.to_s
|
23
|
+
puts " Swap Ins: " + macos_pages.swapins.to_s
|
24
|
+
puts " Swap Outs: " + macos_pages.swapouts.to_s
|
25
|
+
puts " Throttled: " + macos_pages.throttled.to_s
|
26
|
+
puts " Translation Faults: " + macos_pages.translation_faults.to_s
|
27
|
+
puts " Wired Down: " + macos_pages.wired_down.to_s
|
28
|
+
puts " Zero Filled: " + macos_pages.zero_filled.to_s
|
29
|
+
|
data/lib/vmstator.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
require "vmstator/errors"
|
2
2
|
require "vmstator/version"
|
3
3
|
require "vmstator/stats"
|
4
|
-
require "vmstator/
|
5
|
-
require "vmstator/
|
6
|
-
require "vmstator/
|
7
|
-
require "vmstator/
|
8
|
-
require "vmstator/
|
9
|
-
require "vmstator/
|
10
|
-
require "vmstator/
|
11
|
-
require "vmstator/
|
12
|
-
require "vmstator/event_counter_statistics"
|
13
|
-
require "vmstator/slab_info"
|
14
|
-
require "vmstator/version"
|
4
|
+
require "vmstator/macos/pages"
|
5
|
+
require "vmstator/linux/memory"
|
6
|
+
require "vmstator/linux/active"
|
7
|
+
require "vmstator/linux/average"
|
8
|
+
require "vmstator/linux/cache"
|
9
|
+
require "vmstator/linux/disk"
|
10
|
+
require "vmstator/linux/disk_statistics"
|
11
|
+
require "vmstator/linux/disk_summary"
|
12
|
+
require "vmstator/linux/event_counter_statistics"
|
13
|
+
require "vmstator/linux/slab_info"
|
15
14
|
|
16
15
|
module Vmstator
|
17
16
|
|
@@ -21,35 +20,54 @@ module Vmstator
|
|
21
20
|
# with optional vmstat command-line flags
|
22
21
|
# which is passed in as a string
|
23
22
|
def parse(flags=false)
|
24
|
-
if
|
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
|
-
|
23
|
+
if RUBY_PLATFORM =~ /darwin/i
|
24
|
+
return parse_macos
|
25
|
+
elsif RUBY_PLATFORM =~ /linux/i
|
26
|
+
return parse_linux(flags)
|
27
|
+
elsif RUBY_PLATFORM =~ /win32|win64|\.NET|windows|cygwin|mingw32/i
|
28
|
+
raise Vmstator::VmstatError.new("This platform is not supported. Yet!?")
|
29
|
+
else
|
30
|
+
raise Vmstator::VmstatError.new("Unable to parse vmstat on this platform!")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse_linux(flags=false)
|
35
|
+
if flags =~ /(-d|--disk)/
|
36
|
+
# parse instances of disk_statistics
|
37
|
+
return disk_statistics(flags)
|
38
|
+
elsif flags =~ /(-D|--disk-sum)/
|
39
|
+
# parse instances of disk summary
|
40
|
+
return disk_summary(flags)
|
41
|
+
elsif flags =~ /(-a|--active)/
|
42
|
+
# parse instances of active memory
|
43
|
+
return active(flags)
|
44
|
+
elsif flags =~ /(-m|--slabs)/
|
45
|
+
# parse instances of slab info
|
46
|
+
return slab_info(flags)
|
47
|
+
elsif flags =~ /(-f|--forks)/
|
48
|
+
# parse instances of forks
|
49
|
+
return forks
|
50
|
+
elsif flags =~ /(-s|--stats)/
|
51
|
+
# parse instances of event counter statistics
|
52
|
+
return event_counter_statistics(flags)
|
53
|
+
elsif flags =~ /(-V|--version)/
|
54
|
+
# parse instances of version
|
55
|
+
return version
|
50
56
|
else
|
51
|
-
|
57
|
+
flags ? average(flags) : average
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def parse_macos
|
62
|
+
output = `vm_stat`.split("\n")
|
63
|
+
output.shift
|
64
|
+
data = {}
|
65
|
+
output.each do |line|
|
66
|
+
key, value = line.split(':').map(&:strip)
|
67
|
+
key = key.downcase.gsub(" ", "_").gsub("-", "_").gsub('"', '').to_sym
|
68
|
+
data[key] = value.to_i
|
52
69
|
end
|
70
|
+
Vmstator::MacOSPages.new(data)
|
53
71
|
end
|
54
72
|
|
55
73
|
def version
|
@@ -94,7 +112,7 @@ module Vmstator
|
|
94
112
|
flags = "-D" unless flags
|
95
113
|
output = `vmstat #{flags}`
|
96
114
|
values = output.split(/[A-z]/).compact.join.split("\n").map(&:strip).map(&:to_i)
|
97
|
-
|
115
|
+
kecys = output.split(/\d/).compact.join.split("\n").map(&:strip)
|
98
116
|
keys = keys.map(&:downcase).map {|s| s.gsub(" ", "_")}.map(&:to_sym)
|
99
117
|
data = Hash[keys.zip values]
|
100
118
|
Vmstator::DiskSummary.new(data)
|
@@ -129,7 +147,7 @@ module Vmstator
|
|
129
147
|
|
130
148
|
# slab_info() will run the -m flag and return that data
|
131
149
|
def slab_info(flags=false)
|
132
|
-
raise VmstatError("This must be run with root privileges!") unless Process.uid == 0
|
150
|
+
raise Vmstator::VmstatError.new("This must be run with root privileges!") unless Process.uid == 0
|
133
151
|
flags = "-m" unless flags
|
134
152
|
slab_info = Vmstator::SlabInfo.new
|
135
153
|
`sudo vmstat #{flags}`.split("\n").each do |info|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Vmstator
|
2
|
+
|
3
|
+
class MacOSPages < Stats
|
4
|
+
attr_reader :free # total number of free pages in the system
|
5
|
+
attr_reader :active # total number of pages currently in use and pageable
|
6
|
+
attr_reader :inactive # total number of pages on the inactive list
|
7
|
+
attr_reader :speculative # total number of pages on the speculative list
|
8
|
+
attr_reader :throttled # total number of pages on the throttled list (not wired but not pageable)
|
9
|
+
attr_reader :wired_down # total number of pages wired down. that is, pages that cannot be paged out
|
10
|
+
attr_reader :purgeable # total number of purgeable pages
|
11
|
+
attr_reader :translation_faults # number of times the "vm_fault" routine has been called
|
12
|
+
attr_reader :copy_on_write # number of faults that caused a page to be copied (generally caused by copy-on-write faults)
|
13
|
+
attr_reader :zero_filled # total number of pages that have been zero-filled on demand
|
14
|
+
attr_reader :reactivated # total number of pages that have been moved from the inactive list to the active list (reactivated)
|
15
|
+
attr_reader :purged # total number of pages that have been purged
|
16
|
+
attr_reader :file_backed # total number of pages that are file-backed (non-swap)
|
17
|
+
attr_reader :anonymous # total number of pages that are anonymous
|
18
|
+
attr_reader :stored_in_compressor # total number of pages (uncompressed) held within the compressor
|
19
|
+
attr_reader :occupied_by_compressor # number of pages used to store compressed VM pages
|
20
|
+
attr_reader :decompressions # total number of pages that have been decompressed by the VM compressor
|
21
|
+
attr_reader :compressions # total number of pages that have been compressed by the VM compressor
|
22
|
+
attr_reader :ins # total number of requests for pages from a pager (such as the inode pager)
|
23
|
+
attr_reader :outs # total number of pages that have been paged out
|
24
|
+
attr_reader :swapins # total number of compressed pages that have been swapped out to disk
|
25
|
+
attr_reader :swapouts # total number of compressed pages that have been swapped back in from disk
|
26
|
+
|
27
|
+
def update(data)
|
28
|
+
if data
|
29
|
+
@free = data[:pages_free]
|
30
|
+
@active = data[:pages_active]
|
31
|
+
@inactive = data[:pages_inactive]
|
32
|
+
@speculative = data[:pages_speculative]
|
33
|
+
@throttled = data[:pages_throttled]
|
34
|
+
@wired_down = data[:pages_wired_down]
|
35
|
+
@purgeable = data[:pages_purgeable]
|
36
|
+
@translation_faults = data[:translation_faults]
|
37
|
+
@copy_on_write = data[:pages_copy_on_write]
|
38
|
+
@zero_filled = data[:pages_zero_filled]
|
39
|
+
@reactivated = data[:pages_reactivated]
|
40
|
+
@purged = data[:pages_purged]
|
41
|
+
@file_backed = data[:file_backed_pages]
|
42
|
+
@anonymous = data[:anonymous_pages]
|
43
|
+
@stored_in_compressor = data[:pages_stored_in_compressor]
|
44
|
+
@occupied_by_compressor = data[:pages_occupied_by_compressor]
|
45
|
+
@decompressions = data[:decompressions]
|
46
|
+
@compressions = data[:compressions]
|
47
|
+
@ins = data[:pageins]
|
48
|
+
@outs = data[:pageouts]
|
49
|
+
@swapins = data[:swapins]
|
50
|
+
@swapouts = data[:swapouts]
|
51
|
+
else
|
52
|
+
return false
|
53
|
+
end
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
data/lib/vmstator/version.rb
CHANGED
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmstator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kent 'picat' Gruber
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,18 +70,21 @@ files:
|
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
72
|
- examples/basic_example.rb
|
73
|
+
- examples/linux_example.rb
|
74
|
+
- examples/macOS_example.rb
|
73
75
|
- lib/vmstator.rb
|
74
|
-
- lib/vmstator/active.rb
|
75
|
-
- lib/vmstator/average.rb
|
76
|
-
- lib/vmstator/cache.rb
|
77
|
-
- lib/vmstator/disk.rb
|
78
|
-
- lib/vmstator/disk_statistics.rb
|
79
|
-
- lib/vmstator/disk_summary.rb
|
80
76
|
- lib/vmstator/errors.rb
|
81
|
-
- lib/vmstator/
|
82
|
-
- lib/vmstator/
|
83
|
-
- lib/vmstator/
|
84
|
-
- lib/vmstator/
|
77
|
+
- lib/vmstator/linux/active.rb
|
78
|
+
- lib/vmstator/linux/average.rb
|
79
|
+
- lib/vmstator/linux/cache.rb
|
80
|
+
- lib/vmstator/linux/disk.rb
|
81
|
+
- lib/vmstator/linux/disk_statistics.rb
|
82
|
+
- lib/vmstator/linux/disk_summary.rb
|
83
|
+
- lib/vmstator/linux/event_counter_statistics.rb
|
84
|
+
- lib/vmstator/linux/memory.rb
|
85
|
+
- lib/vmstator/linux/parser.rb
|
86
|
+
- lib/vmstator/linux/slab_info.rb
|
87
|
+
- lib/vmstator/macos/pages.rb
|
85
88
|
- lib/vmstator/stats.rb
|
86
89
|
- lib/vmstator/version.rb
|
87
90
|
- pkg/vmstator-0.1.0.gem
|
@@ -91,6 +94,8 @@ files:
|
|
91
94
|
- pkg/vmstator-2.0.1.gem
|
92
95
|
- pkg/vmstator-2.0.2.gem
|
93
96
|
- pkg/vmstator-2.0.3.gem
|
97
|
+
- pkg/vmstator-2.0.4.gem
|
98
|
+
- pkg/vmstator-2.1.0.gem
|
94
99
|
- vmstator.gemspec
|
95
100
|
homepage: https://github.com/picatz/Vmstator
|
96
101
|
licenses:
|