cpu-memory-stats 0.0.1 → 0.0.2
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.
- data/VERSION +1 -1
- data/cpu-memory-stats.gemspec +55 -0
- data/lib/modules/bsd.rb +11 -1
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "cpu-memory-stats"
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ondrej Bartas"]
|
12
|
+
s.date = "2012-08-03"
|
13
|
+
s.description = "Simple gem for getting information about cpu and memory usage (Mac OS X, BSD)"
|
14
|
+
s.email = "ondrej@bartas.cz"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"cpu-memory-stats.gemspec",
|
27
|
+
"lib/cpu-memory-stats.rb",
|
28
|
+
"lib/modules/bsd.rb",
|
29
|
+
"lib/modules/mac.rb",
|
30
|
+
"lib/os_detection.rb",
|
31
|
+
"test/helper.rb",
|
32
|
+
"test/test_cpu-memory-stats.rb"
|
33
|
+
]
|
34
|
+
s.homepage = "http://github.com/ondrejbartas/cpu-memory-stats"
|
35
|
+
s.licenses = ["MIT"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = "1.8.24"
|
38
|
+
s.summary = "Get system CPU and Memory usage"
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.1.5"])
|
45
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<bundler>, ["~> 1.1.5"])
|
48
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
49
|
+
end
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<bundler>, ["~> 1.1.5"])
|
52
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
data/lib/modules/bsd.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
# Module for geting informations from BSD
|
3
|
+
# author: Ondrej Bartas
|
4
|
+
|
2
5
|
module CpuMemoryStats
|
3
6
|
|
4
7
|
class Bsd
|
@@ -9,7 +12,14 @@ module CpuMemoryStats
|
|
9
12
|
output[:load_avg] = `sysctl -n vm.loadavg`.gsub(/\{|\}/,"").strip.split(" ").collect{|i| i.strip.to_f.round(2)}
|
10
13
|
|
11
14
|
cpu = `sysctl -n kern.cp_time`.strip.split(" ").collect{|i| i.strip.to_i}
|
12
|
-
|
15
|
+
cpu_start = Hash[[:user, :nice, :system, :interupt, :idle].zip(cpu)]
|
16
|
+
sleep(1)
|
17
|
+
cpu = `sysctl -n kern.cp_time`.strip.split(" ").collect{|i| i.strip.to_i}
|
18
|
+
cpu_end = Hash[[:user, :nice, :system, :interupt, :idle].zip(cpu)]
|
19
|
+
|
20
|
+
cpu_end.each do |key, value|
|
21
|
+
output[:cpu][key] = value - cpu_start[key]
|
22
|
+
end
|
13
23
|
|
14
24
|
output[:memory] = {
|
15
25
|
:wired => `sysctl -n vm.stats.vm.v_wire_count`.to_i,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpu-memory-stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- README.markdown
|
59
59
|
- Rakefile
|
60
60
|
- VERSION
|
61
|
+
- cpu-memory-stats.gemspec
|
61
62
|
- lib/cpu-memory-stats.rb
|
62
63
|
- lib/modules/bsd.rb
|
63
64
|
- lib/modules/mac.rb
|
@@ -79,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
80
|
version: '0'
|
80
81
|
segments:
|
81
82
|
- 0
|
82
|
-
hash:
|
83
|
+
hash: -1704237501487931525
|
83
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
85
|
none: false
|
85
86
|
requirements:
|