mool 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -1
- data/lib/mool/system.rb +42 -0
- data/lib/mool/version.rb +1 -1
- data/lib/mool.rb +1 -2
- metadata +6 -5
data/README.md
CHANGED
@@ -40,11 +40,35 @@ It's posible get all cpu information:
|
|
40
40
|
>> MoolCpu.new(0) or MoolCpu.new("0")
|
41
41
|
#<MoolCpu:0x7f82959381a8 @nice=0.0, @gnice=0.0, @total=2.0, @irq=0.0, @usr=2.0, @guest=0.0, @iowait=0.0, @cores=2, @steal=0.0, @sys=0.0, @model_name="Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz", @idle=97.0, @cpu_name="cpu_3", @soft=0.0>
|
42
42
|
```
|
43
|
-
### Load-Average
|
43
|
+
### Load-Average (V. 1.0.1)
|
44
44
|
```ruby
|
45
45
|
>> MoolLoadAverage.new
|
46
46
|
#<MoolLoadAverage:0x7f8295931c90 @total_thread_entities=638, @current_loadavg=0.08, @thread_entities_exec=2, @last_15min_loadavg=0.13, @last_pid_process_created=6264, @last_5min_loadavg=0.07>
|
47
47
|
```
|
48
|
+
|
49
|
+
### System information (V. 2.0.0)
|
50
|
+
Load average:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
>> MoolSystem.new.load_average
|
54
|
+
{ :total_thread_entities => 638, :current_loadavg => 0.08, :thread_entities_exec => 2, :last_15min_loadavg => 0.13, :last_pid_process_created => 6264, :last_5min_loadavg => 0.07 }
|
55
|
+
```
|
56
|
+
|
57
|
+
uptime:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
>> MoolSystem.new.uptime
|
61
|
+
{ :uptime_day => 4, :uptime_hour => 3, :uptime_minute => 20, :uptime_second => 10 }
|
62
|
+
```
|
63
|
+
|
64
|
+
Kernel version:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
>> MoolSystem.new.kernel_version
|
68
|
+
"4.6.0-1-amd64"
|
69
|
+
```
|
70
|
+
|
71
|
+
|
48
72
|
### Memory
|
49
73
|
```ruby
|
50
74
|
>> MoolMemory.new
|
data/lib/mool/system.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
class MoolSystem
|
2
|
+
attr_reader :kernel, :current_loadavg, :last_5min_loadavg, :last_15min_loadavg, :thread_entities_exec, :total_thread_entities, :last_pid_process_created, :uptime_day, :uptime_hour, :uptime_minute, :uptime_second
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@kernel = `uname -r`.chomp
|
6
|
+
load_avg = File.read("/proc/loadavg").chomp.split(" ")
|
7
|
+
@current_loadavg = load_avg[0].to_f
|
8
|
+
@last_5min_loadavg = load_avg[1].to_f
|
9
|
+
@last_15min_loadavg = load_avg[2].to_f
|
10
|
+
@thread_entities_exec = load_avg[3].split("/").first.to_i # Currently executing kernel scheduling entities
|
11
|
+
@total_thread_entities = load_avg[3].split("/").last.to_i # Number of kernel scheduling entities that currently exist on the system
|
12
|
+
@last_pid_process_created = load_avg[4].to_i
|
13
|
+
time = `cat /proc/uptime`.split(" ").first.to_f
|
14
|
+
mm, ss = time.divmod(60)
|
15
|
+
hh, mm = mm.divmod(60)
|
16
|
+
dd, hh = hh.divmod(24)
|
17
|
+
@uptime_day = dd.to_i
|
18
|
+
@uptime_hour = hh.to_i
|
19
|
+
@uptime_minute = mm.to_i
|
20
|
+
@uptime_second = ss.to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
def load_average
|
24
|
+
{ :current_loadavg => @current_loadavg,
|
25
|
+
:last_5min_loadavg => @last_5min_loadavg,
|
26
|
+
:last_15min_loadavg => @last_15min_loadavg,
|
27
|
+
:thread_entities_exec => @thread_entities_exec,
|
28
|
+
:total_thread_entities => @total_thread_entities,
|
29
|
+
:last_pid_process_created => @last_pid_process_created }
|
30
|
+
end
|
31
|
+
|
32
|
+
def uptime
|
33
|
+
{ :day => @uptime_day,
|
34
|
+
:hour => @uptime_hour,
|
35
|
+
:minute => @uptime_minute,
|
36
|
+
:second => @uptime_second }
|
37
|
+
end
|
38
|
+
|
39
|
+
def kernel_version
|
40
|
+
@kernel
|
41
|
+
end
|
42
|
+
end
|
data/lib/mool/version.rb
CHANGED
data/lib/mool.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version:
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- g.edera
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2016-08-01 00:00:00 -03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- lib/mool/load_average.rb
|
44
44
|
- lib/mool/memory.rb
|
45
45
|
- lib/mool/service.rb
|
46
|
+
- lib/mool/system.rb
|
46
47
|
- lib/mool/version.rb
|
47
48
|
- mool.gemspec
|
48
49
|
has_rdoc: true
|