mem_info 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +33 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/mem_info.rb +10 -3
- data/mem_info.gemspec +20 -27
- metadata +33 -19
- data/.gitignore +0 -21
- data/README.rdoc +0 -26
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# mem_info
|
2
|
+
|
3
|
+
This is a lightweight library that wraps access to the data in /proc/meminfo found in many linux variants, which contains live memory usage information about a machine.
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
Install the gem:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem install mem_info
|
11
|
+
```
|
12
|
+
|
13
|
+
Require the library like you would expect:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'mem_info'
|
17
|
+
```
|
18
|
+
|
19
|
+
Then create a new MemInfo object:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
m = MemInfo.new
|
23
|
+
m.memtotal => 70000
|
24
|
+
m.memfree => 54300
|
25
|
+
m.memused => 15700
|
26
|
+
m.free_buffers => 75000
|
27
|
+
```
|
28
|
+
|
29
|
+
Take a look in `lib/mem_info.rb` for all fields that are available.
|
30
|
+
|
31
|
+
## Copyright
|
32
|
+
|
33
|
+
Copyright (c) 2012 Joel Watson. See LICENSE for details.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/mem_info.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class MemInfo
|
2
|
+
class NoProcData < Exception; end
|
3
|
+
|
2
4
|
attr_accessor :memtotal, :memfree, :buffers, :cached, :swapcached, :active, :inactive,
|
3
5
|
:active_anon, :inactive_anon, :active_file, :inactive_file, :unevictable,
|
4
6
|
:mlocked, :swaptotal, :swapfree, :dirty, :writeback, :anonpages, :mapped,
|
@@ -9,7 +11,8 @@ class MemInfo
|
|
9
11
|
@@attributes = {
|
10
12
|
:memtotal => "MemTotal",
|
11
13
|
:memfree => "MemFree",
|
12
|
-
:buffers => "
|
14
|
+
:buffers => "Buffers",
|
15
|
+
:cached => "Cached",
|
13
16
|
:swapcached => "SwapCached",
|
14
17
|
:active => "Active",
|
15
18
|
:inactive => "Inactive",
|
@@ -51,17 +54,21 @@ class MemInfo
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
else
|
54
|
-
raise "This system doesn't have /proc/meminfo data."
|
57
|
+
raise NoProcData, "This system doesn't have /proc/meminfo data."
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
58
61
|
def memused
|
59
62
|
@memtotal - @memfree
|
60
63
|
end
|
64
|
+
|
65
|
+
def free_buffers
|
66
|
+
@memfree + @buffers + @cached
|
67
|
+
end
|
61
68
|
|
62
69
|
private
|
63
70
|
def regex_match(attribute, line)
|
64
71
|
regex = Regexp.new("#{@@attributes[attribute]}:\\s*(.*?)\\s")
|
65
72
|
regex.match(line)[1] if regex === line
|
66
73
|
end
|
67
|
-
end
|
74
|
+
end
|
data/mem_info.gemspec
CHANGED
@@ -1,49 +1,42 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.0.
|
7
|
+
s.name = "mem_info"
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["watsonian"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2012-09-04"
|
13
|
+
s.description = "Ruby wrapper for /proc/meminfo data"
|
14
|
+
s.email = "watsonian@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"mem_info.gemspec",
|
28
|
-
"spec/mem_info_spec.rb",
|
29
|
-
"spec/spec.opts",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/watsonian/mem_info}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.5}
|
36
|
-
s.summary = %q{Ruby wrapper for /proc/meminfo data}
|
37
|
-
s.test_files = [
|
21
|
+
"LICENSE",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/mem_info.rb",
|
26
|
+
"mem_info.gemspec",
|
38
27
|
"spec/mem_info_spec.rb",
|
39
|
-
|
28
|
+
"spec/spec.opts",
|
29
|
+
"spec/spec_helper.rb"
|
40
30
|
]
|
31
|
+
s.homepage = "http://github.com/watsonian/mem_info"
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = "1.8.24"
|
34
|
+
s.summary = "Ruby wrapper for /proc/meminfo data"
|
41
35
|
|
42
36
|
if s.respond_to? :specification_version then
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
37
|
s.specification_version = 3
|
45
38
|
|
46
|
-
if Gem::Version.new(Gem::
|
39
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
40
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
48
41
|
else
|
49
42
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mem_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- watsonian
|
@@ -9,19 +15,24 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
18
|
+
date: 2012-09-04 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 13
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 2
|
32
|
+
- 9
|
23
33
|
version: 1.2.9
|
24
|
-
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
25
36
|
description: Ruby wrapper for /proc/meminfo data
|
26
37
|
email: watsonian@gmail.com
|
27
38
|
executables: []
|
@@ -30,12 +41,11 @@ extensions: []
|
|
30
41
|
|
31
42
|
extra_rdoc_files:
|
32
43
|
- LICENSE
|
33
|
-
- README.
|
44
|
+
- README.md
|
34
45
|
files:
|
35
46
|
- .document
|
36
|
-
- .gitignore
|
37
47
|
- LICENSE
|
38
|
-
- README.
|
48
|
+
- README.md
|
39
49
|
- Rakefile
|
40
50
|
- VERSION
|
41
51
|
- lib/mem_info.rb
|
@@ -43,34 +53,38 @@ files:
|
|
43
53
|
- spec/mem_info_spec.rb
|
44
54
|
- spec/spec.opts
|
45
55
|
- spec/spec_helper.rb
|
46
|
-
has_rdoc: true
|
47
56
|
homepage: http://github.com/watsonian/mem_info
|
48
57
|
licenses: []
|
49
58
|
|
50
59
|
post_install_message:
|
51
|
-
rdoc_options:
|
52
|
-
|
60
|
+
rdoc_options: []
|
61
|
+
|
53
62
|
require_paths:
|
54
63
|
- lib
|
55
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
56
66
|
requirements:
|
57
67
|
- - ">="
|
58
68
|
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
59
72
|
version: "0"
|
60
|
-
version:
|
61
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
62
75
|
requirements:
|
63
76
|
- - ">="
|
64
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
65
81
|
version: "0"
|
66
|
-
version:
|
67
82
|
requirements: []
|
68
83
|
|
69
84
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
85
|
+
rubygems_version: 1.8.24
|
71
86
|
signing_key:
|
72
87
|
specification_version: 3
|
73
88
|
summary: Ruby wrapper for /proc/meminfo data
|
74
|
-
test_files:
|
75
|
-
|
76
|
-
- spec/spec_helper.rb
|
89
|
+
test_files: []
|
90
|
+
|
data/.gitignore
DELETED
data/README.rdoc
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
= mem_info
|
2
|
-
|
3
|
-
This is a lightweight library that wraps access to the data in /proc/meminfo found in many linux variants, which contains live memory usage information about a machine.
|
4
|
-
|
5
|
-
== Getting Started
|
6
|
-
|
7
|
-
Install the gem:
|
8
|
-
|
9
|
-
gem install mem_info
|
10
|
-
|
11
|
-
Require the library like you would expect:
|
12
|
-
|
13
|
-
require 'mem_info'
|
14
|
-
|
15
|
-
Then create a new MemInfo object:
|
16
|
-
|
17
|
-
m = MemInfo.new
|
18
|
-
m.memtotal => 70000
|
19
|
-
m.memfree => 54300
|
20
|
-
m.memused => 15700
|
21
|
-
|
22
|
-
Take a look in lib/mem_info.rb for all fields that are available.
|
23
|
-
|
24
|
-
== Copyright
|
25
|
-
|
26
|
-
Copyright (c) 2010 Joel Watson. See LICENSE for details.
|