usagewatch_ext 0.0.3 → 0.0.4.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +1 -1
- data/README.md +22 -13
- data/examples/linux_example.rb +1 -0
- data/examples/mac_example.rb +1 -0
- data/lib/usagewatch_ext.rb +4 -4
- data/lib/usagewatch_ext/linux.rb +6 -0
- data/lib/usagewatch_ext/mac.rb +28 -21
- data/lib/usagewatch_ext/version.rb +2 -1
- data/spec/general_spec.rb +80 -0
- data/spec/linux_spec.rb +1 -69
- data/spec/spec_helper.rb +4 -3
- data/spec/version_spec.rb +18 -0
- data/usagewatch_ext.gemspec +2 -0
- metadata +12 -7
- data/spec/mac_spec.rb +0 -74
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2FkYjUyZGI1ZmE1NDJiNmI2MTk2NWM3MWM0YTI5YzRjNTdmZmNjYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2I3NDNkMzQ0YmYyNjA1NGI1ZjJkMDBjOTUyY2ZhMWI2ZDBhZWU4OQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2Q4MjNmMjJiNmUyMjYzODcxNzlkZTE0MmNiMjhlNjA3ODlkYmM3MmRhMzBj
|
10
|
+
MTU1ZTM1ZmU2MTU3Mzk3YjRlZjdhNWQ0ZjY0N2JiZGVhY2IxNGU0MWY2MDg0
|
11
|
+
MGViOWY0NjZjNjAxNjZjNGFhYTkxMWJiMTQyMjliODk1MDBlYTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTBkNzA0ZWY2NjIzYjJmMjFlZmUzOGRlYTliNDI5NDRlMThjYmYwNzM1ZmI1
|
14
|
+
ZTMzMzFhZWZkYTljMjIxZDk5MjA4MjMwMGIzZjgyNjcxZTNhOWQyYmE1MDg1
|
15
|
+
NGQ1ZmI2NTViMTYxNTE1Yzk4OGZmMzlmZjlhMTRkZjQyMTZmZjc=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
[![Coverage Status](https://coveralls.io/repos/rderoldan1/usagewatch_ext/badge.png)](https://coveralls.io/r/rderoldan1/usagewatch_ext)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/usagewatch_ext.png)](http://badge.fury.io/rb/usagewatch_ext)
|
3
3
|
[![Build Status](https://travis-ci.org/rderoldan1/usagewatch_ext.png?branch=master)](https://travis-ci.org/rderoldan1/usagewatch_ext)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/rderoldan1/usagewatch_ext.png)](https://codeclimate.com/github/rderoldan1/usagewatch_ext)
|
4
5
|
|
5
6
|
# usagewatch extended version
|
6
7
|
|
7
|
-
License: (MIT) Copyright (C) 2013
|
8
|
+
License: (MIT) Copyright (C) 2013 Authors Ruben Espinosa, Phil Chen.
|
8
9
|
|
9
10
|
## DESCRIPTION:
|
10
|
-
This project is based in [Usagewatch](https://github.com/rderoldan1/nethacker/usagewatch) gem written by Phil Chen, I try to expand the OS
|
11
|
+
This project is based in [Usagewatch](https://github.com/rderoldan1/nethacker/usagewatch) gem written by Phil Chen, I try to expand the OS support, first with mac OS,
|
11
12
|
in future versions Windows will be include.
|
12
13
|
|
14
|
+
Also I am writing a testing library for the original gem.
|
15
|
+
|
13
16
|
This is Ruby Gem with methods to find usage statistics on your system such as CPU, Disk, TCP/UDP Connections, Load,
|
14
17
|
Bandwidth, Disk I/O, and Memory, top processes by memory and cpu consumption
|
15
18
|
|
@@ -20,7 +23,7 @@ gem install usagewatch_ext
|
|
20
23
|
```ruby
|
21
24
|
require 'usagewatch_ext'
|
22
25
|
|
23
|
-
usw =
|
26
|
+
usw = Usagewatch
|
24
27
|
|
25
28
|
usw.uw_diskused
|
26
29
|
usw.uw_diskused_perc
|
@@ -35,6 +38,7 @@ usw.uw_diskioreads
|
|
35
38
|
usw.uw_diskiowrites
|
36
39
|
usw.uw_cputop
|
37
40
|
usw.uw_memtop
|
41
|
+
usw.uw_apacheconns
|
38
42
|
```
|
39
43
|
|
40
44
|
## Example
|
@@ -97,6 +101,7 @@ Top Ten Processes By Memory Consumption: [["WebProcess", "8.3"], ["rubymine", "6
|
|
97
101
|
uw_diskiowrites
|
98
102
|
uw_cputop
|
99
103
|
uw_memtop
|
104
|
+
uw_httpconns
|
100
105
|
|
101
106
|
##### Mac
|
102
107
|
uw_diskused
|
@@ -106,29 +111,33 @@ Top Ten Processes By Memory Consumption: [["WebProcess", "8.3"], ["rubymine", "6
|
|
106
111
|
uw_load
|
107
112
|
uw_cpuused
|
108
113
|
uw_memused
|
114
|
+
usw.uw_httpconns
|
109
115
|
|
110
116
|
|
111
117
|
## Notes
|
112
118
|
|
113
|
-
Disk Used is a sum of all partitions calculated in Gigabytes
|
119
|
+
* Disk Used is a sum of all partitions calculated in Gigabytes
|
120
|
+
|
121
|
+
* Disk Used Percentage is a total percentage of all disk partitions used
|
122
|
+
|
123
|
+
* CPU Used is a percentage of current CPU being used
|
114
124
|
|
115
|
-
|
125
|
+
* TCP/UDP Connections Used is a total count of each respectively
|
116
126
|
|
117
|
-
|
127
|
+
* Active Memory Used is a percentage of active system memory being used
|
118
128
|
|
119
|
-
|
129
|
+
* Load is the average load of the past minute
|
120
130
|
|
121
|
-
|
131
|
+
* Bandwidth is current received and transmitted in Megabits
|
122
132
|
|
123
|
-
|
133
|
+
* Disk IO is current disk reads and writes completed per second
|
124
134
|
|
125
|
-
|
135
|
+
* Top Ten Processes By CPU Consumption are based on percent CPU used
|
126
136
|
|
127
|
-
|
137
|
+
* Top Ten Processes By Memory Consumption are base on percent Memory used
|
128
138
|
|
129
|
-
|
139
|
+
* HTTP Conns is the number of connections on 80 port
|
130
140
|
|
131
|
-
Top Ten Processes By Memory Consumption are base on percent Memory used
|
132
141
|
|
133
142
|
## Tested Using
|
134
143
|
|
data/examples/linux_example.rb
CHANGED
@@ -19,3 +19,4 @@ puts "#{usw.uw_diskioreads}/s Current Disk Reads Completed"
|
|
19
19
|
puts "#{usw.uw_diskiowrites}/s Current Disk Writes Completed"
|
20
20
|
puts "Top Ten Processes By CPU Consumption: #{usw.uw_cputop}"
|
21
21
|
puts "Top Ten Processes By Memory Consumption: #{usw.uw_memtop}"
|
22
|
+
puts "#{usw.uw_httpconns} Connections in 80 Port"
|
data/examples/mac_example.rb
CHANGED
@@ -13,3 +13,4 @@ puts "#{usw.uw_cpuused}% CPU Used"
|
|
13
13
|
puts "#{usw.uw_load} Average System Load Of The Past Minute"
|
14
14
|
puts "Top Ten Processes By CPU Consumption: #{usw.uw_cputop}"
|
15
15
|
puts "Top Ten Processes By Memory Consumption: #{usw.uw_memtop}"
|
16
|
+
puts "#{usw.uw_httpconns} Connections in 80 Port"
|
data/lib/usagewatch_ext.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require "usagewatch_ext/version"
|
2
2
|
|
3
3
|
module UsagewatchExt
|
4
|
-
os = RUBY_PLATFORM
|
5
4
|
text = "OS is not supported in this version."
|
6
5
|
|
7
|
-
if
|
6
|
+
if OS.include? "darwin"
|
8
7
|
require "usagewatch_ext/mac"
|
9
8
|
puts "Mac version is under development"
|
10
|
-
elsif
|
9
|
+
elsif OS.include? "linux"
|
11
10
|
require "usagewatch/linux"
|
11
|
+
require "usagewatch_ext/linux"
|
12
12
|
UsagewatchExt = Usagewatch
|
13
|
-
elsif
|
13
|
+
elsif OS =~ /cygwin|mswin|mingw|bccwin|wince|emx/
|
14
14
|
puts "Windows" + text
|
15
15
|
else
|
16
16
|
puts "This" + text
|
data/lib/usagewatch_ext/mac.rb
CHANGED
@@ -15,15 +15,12 @@ module Usagewatch
|
|
15
15
|
|
16
16
|
# Show the percentage of disk used.
|
17
17
|
def self.uw_diskused_perc
|
18
|
-
df = `df -kl
|
19
|
-
total = 0.0
|
20
|
-
used = 0.0
|
18
|
+
df, total, used = `df -kl`, 0.0, 0.0
|
21
19
|
df.each_line.with_index do |line, line_index|
|
22
|
-
next if line_index.eql? 0
|
23
20
|
line = line.split(" ")
|
24
|
-
next if line[0] =~ /localhost/ #ignore backup filesystem
|
25
|
-
total +=
|
26
|
-
used +=
|
21
|
+
next if line_index.eql? 0 or line[0] =~ /localhost/ #ignore backup filesystem
|
22
|
+
total += to_gb line[3].to_f
|
23
|
+
used += to_gb line[2].to_f
|
27
24
|
end
|
28
25
|
((used/total) * 100).round(2)
|
29
26
|
end
|
@@ -38,13 +35,7 @@ module Usagewatch
|
|
38
35
|
# return hash of top ten proccesses by cpu consumption
|
39
36
|
# example [["apache2", 12.0], ["passenger", 13.2]]
|
40
37
|
def self.uw_cputop
|
41
|
-
|
42
|
-
array = []
|
43
|
-
ps.each_line do |line|
|
44
|
-
line = line.chomp.split(" ")
|
45
|
-
array << [line.first.gsub(/[\[\]]/, "").split("/").last, line.last]
|
46
|
-
end
|
47
|
-
array
|
38
|
+
top %w"$11 $3"
|
48
39
|
end
|
49
40
|
|
50
41
|
# todo
|
@@ -60,13 +51,7 @@ module Usagewatch
|
|
60
51
|
# return hash of top ten proccesses by mem consumption
|
61
52
|
# example [["apache2", 12.0], ["passenger", 13.2]]
|
62
53
|
def self.uw_memtop
|
63
|
-
|
64
|
-
array = []
|
65
|
-
ps.each_line do |line|
|
66
|
-
line = line.chomp.split(" ")
|
67
|
-
array << [line.first.gsub(/[\[\]]/, "").split("/").last, line.last]
|
68
|
-
end
|
69
|
-
array
|
54
|
+
top %w"$11 $4"
|
70
55
|
end
|
71
56
|
|
72
57
|
# Percentage of mem used
|
@@ -106,4 +91,26 @@ module Usagewatch
|
|
106
91
|
#def uw_diskiowrites
|
107
92
|
#
|
108
93
|
#end
|
94
|
+
|
95
|
+
# Show the current http connections on 80 port
|
96
|
+
def self.uw_httpconns
|
97
|
+
`netstat -an | grep :80 |wc -l`.to_i
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
|
103
|
+
def self.top(lines)
|
104
|
+
ps = `ps aux | awk '{print #{lines.join(", ")}}' | sort -k2nr | head -n 10`
|
105
|
+
array = []
|
106
|
+
ps.each_line do |line|
|
107
|
+
line = line.chomp.split(" ")
|
108
|
+
array << [line.first.gsub(/[\[\]]/, "").split("/").last, line.last]
|
109
|
+
end
|
110
|
+
array
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.to_gb(bytes)
|
114
|
+
(bytes/1024)/1024
|
115
|
+
end
|
109
116
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'IncludeLibrary' do
|
5
|
+
it 'should include the library' do
|
6
|
+
a = Usagewatch
|
7
|
+
a.should be Usagewatch
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'DiskUsage' do
|
12
|
+
it "should be the GB of disk used" do
|
13
|
+
a = Usagewatch.uw_diskused
|
14
|
+
a.class.should be(Float)
|
15
|
+
a.should_not be_nil
|
16
|
+
a.should be >= 0
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'CPUUsage' do
|
21
|
+
it "should be the percentage of cpu used" do
|
22
|
+
a = Usagewatch.uw_cpuused
|
23
|
+
a.class.should be(Float)
|
24
|
+
a.should_not be_nil
|
25
|
+
a.should be <= 100
|
26
|
+
a.should be >= 0
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'PercentageDiskUsage' do
|
31
|
+
it "should be the percentage of GB of disk used" do
|
32
|
+
a = Usagewatch.uw_diskused_perc
|
33
|
+
a.class.should be(Float)
|
34
|
+
a.should_not be_nil
|
35
|
+
a.should be <= 100
|
36
|
+
a.should be >= 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'LoadAverage' do
|
41
|
+
it "should be the average load of the past minute" do
|
42
|
+
a = Usagewatch.uw_load
|
43
|
+
a.class.should be(Float)
|
44
|
+
a.should_not be_nil
|
45
|
+
a.should be >= 0
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'TopCPUUsage' do
|
50
|
+
it "should be an array of top cpu consumption proccesses " do
|
51
|
+
a = Usagewatch.uw_cputop
|
52
|
+
a.class.should be(Array )
|
53
|
+
a.should_not be_nil
|
54
|
+
a[0][0].class.should be String
|
55
|
+
a[0][1].class.should be String
|
56
|
+
a.count.should be == 10
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'TopMEMUsage' do
|
61
|
+
it "should be an array of top mem consumption proccesses " do
|
62
|
+
a = Usagewatch.uw_cputop
|
63
|
+
a.class.should be(Array )
|
64
|
+
a.should_not be_nil
|
65
|
+
a[0][0].class.should be String
|
66
|
+
a[0][1].class.should be String
|
67
|
+
a.count.should be == 10
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'HTTPConns' do
|
72
|
+
it 'should be the number of current apache connections' do
|
73
|
+
a = Usagewatch.uw_httpconns
|
74
|
+
a.class.should be Fixnum
|
75
|
+
a.should_not be_nil
|
76
|
+
a.should be >= 0
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
data/spec/linux_spec.rb
CHANGED
@@ -1,75 +1,7 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
|
5
|
-
if os.include? "linux"
|
6
|
-
describe 'IncludeLibrary' do
|
7
|
-
it 'should include the library' do
|
8
|
-
a = Usagewatch
|
9
|
-
a.should be Usagewatch
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'DiskUsage' do
|
14
|
-
it "should be the GB of disk used" do
|
15
|
-
a = Usagewatch.uw_diskused
|
16
|
-
a.class.should be(Float)
|
17
|
-
a.should_not be_nil
|
18
|
-
a.should be >= 0
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'CPUUsage' do
|
23
|
-
it "should be the percentage of cpu used" do
|
24
|
-
a = Usagewatch.uw_cpuused
|
25
|
-
a.class.should be(Float)
|
26
|
-
a.should_not be_nil
|
27
|
-
a.should be <= 100
|
28
|
-
a.should be >= 0
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'PercentageDiskUsage' do
|
33
|
-
it "should be the percentage of GB of disk used" do
|
34
|
-
a = Usagewatch.uw_diskused_perc
|
35
|
-
a.class.should be(Float)
|
36
|
-
a.should_not be_nil
|
37
|
-
a.should be <= 100
|
38
|
-
a.should be >= 0
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe 'LoadAverage' do
|
43
|
-
it "should be the average load of the past minute" do
|
44
|
-
a = Usagewatch.uw_load
|
45
|
-
a.class.should be(Float)
|
46
|
-
a.should_not be_nil
|
47
|
-
a.should be >= 0
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'TopCPUUsage' do
|
52
|
-
it "should be an array of top cpu consumption proccesses " do
|
53
|
-
a = Usagewatch.uw_cputop
|
54
|
-
a.class.should be(Array )
|
55
|
-
a.should_not be_nil
|
56
|
-
a[0][0].class.should be String
|
57
|
-
a[0][1].class.should be String
|
58
|
-
a.count.should be == 10
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe 'TopMEMUsage' do
|
63
|
-
it "should be an array of top mem consumption proccesses " do
|
64
|
-
a = Usagewatch.uw_cputop
|
65
|
-
a.class.should be(Array )
|
66
|
-
a.should_not be_nil
|
67
|
-
a[0][0].class.should be String
|
68
|
-
a[0][1].class.should be String
|
69
|
-
a.count.should be == 10
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
4
|
+
if OS.include? "linux"
|
73
5
|
describe 'TCPConnectios' do
|
74
6
|
it 'should TCP Connections Used' do
|
75
7
|
a = Usagewatch.uw_tcpused
|
data/spec/spec_helper.rb
CHANGED
@@ -3,13 +3,14 @@ require 'bundler/setup'
|
|
3
3
|
require 'coveralls'
|
4
4
|
Coveralls.wear!
|
5
5
|
|
6
|
-
|
7
|
-
if
|
6
|
+
OS = RUBY_PLATFORM
|
7
|
+
if OS.include? "darwin"
|
8
8
|
require "usagewatch_ext"
|
9
9
|
puts "Testing Mac Version"
|
10
|
-
elsif
|
10
|
+
elsif OS.include? "linux"
|
11
11
|
require "usagewatch"
|
12
12
|
puts "Testing Linux Version"
|
13
|
+
puts `uname -a`
|
13
14
|
end
|
14
15
|
|
15
16
|
RSpec.configure do |config|
|
data/spec/version_spec.rb
CHANGED
@@ -7,4 +7,22 @@ describe 'Version' do
|
|
7
7
|
a.class.should be(String)
|
8
8
|
a.should_not be_nil
|
9
9
|
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'OSVersion' do
|
13
|
+
it 'should be the OS version' do
|
14
|
+
a = UsagewatchExt::OS
|
15
|
+
a.class.should be(String)
|
16
|
+
a.should_not be_nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if OS.include? "linux"
|
21
|
+
describe 'Version' do
|
22
|
+
it 'should be the version number of usagewatch' do
|
23
|
+
a = Usagewatch::VERSION
|
24
|
+
a.class.should be(String)
|
25
|
+
a.should_not be_nil
|
26
|
+
end
|
27
|
+
end
|
10
28
|
end
|
data/usagewatch_ext.gemspec
CHANGED
@@ -14,6 +14,8 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.rdoc_options << '--main' << 'README'
|
16
16
|
|
17
|
+
spec.post_install_message = "* Usagewatch Gem for linux are covered for our test.\n* Mac OS version is in development\nThanks for installing!"
|
18
|
+
|
17
19
|
spec.files = `git ls-files`.split($/)
|
18
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usagewatch_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruben Espinosa, Phil Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: usagewatch
|
@@ -84,10 +84,11 @@ files:
|
|
84
84
|
- examples/linux_example.rb
|
85
85
|
- examples/mac_example.rb
|
86
86
|
- lib/usagewatch_ext.rb
|
87
|
+
- lib/usagewatch_ext/linux.rb
|
87
88
|
- lib/usagewatch_ext/mac.rb
|
88
89
|
- lib/usagewatch_ext/version.rb
|
90
|
+
- spec/general_spec.rb
|
89
91
|
- spec/linux_spec.rb
|
90
|
-
- spec/mac_spec.rb
|
91
92
|
- spec/spec_helper.rb
|
92
93
|
- spec/version_spec.rb
|
93
94
|
- usagewatch_ext.gemspec
|
@@ -95,7 +96,11 @@ homepage: https://github.com/rderoldan1/usagewatch_ext
|
|
95
96
|
licenses:
|
96
97
|
- MIT
|
97
98
|
metadata: {}
|
98
|
-
post_install_message:
|
99
|
+
post_install_message: ! '* Usagewatch Gem for linux are covered for our test.
|
100
|
+
|
101
|
+
* Mac OS version is in development
|
102
|
+
|
103
|
+
Thanks for installing!'
|
99
104
|
rdoc_options:
|
100
105
|
- --main
|
101
106
|
- README
|
@@ -108,9 +113,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
113
|
version: '0'
|
109
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
115
|
requirements:
|
111
|
-
- - ! '
|
116
|
+
- - ! '>'
|
112
117
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
118
|
+
version: 1.3.1
|
114
119
|
requirements: []
|
115
120
|
rubyforge_project:
|
116
121
|
rubygems_version: 2.0.3
|
@@ -118,7 +123,7 @@ signing_key:
|
|
118
123
|
specification_version: 4
|
119
124
|
summary: Extended version of usagewatch
|
120
125
|
test_files:
|
126
|
+
- spec/general_spec.rb
|
121
127
|
- spec/linux_spec.rb
|
122
|
-
- spec/mac_spec.rb
|
123
128
|
- spec/spec_helper.rb
|
124
129
|
- spec/version_spec.rb
|
data/spec/mac_spec.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
os = RUBY_PLATFORM
|
5
|
-
if os.include? "darwin"
|
6
|
-
describe 'IncludeLibrary' do
|
7
|
-
it 'should include the library' do
|
8
|
-
a = Usagewatch
|
9
|
-
a.should be Usagewatch
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'DiskUsage' do
|
14
|
-
it "should be the GB of disk used" do
|
15
|
-
a = Usagewatch.uw_diskused
|
16
|
-
a.class.should be(Float)
|
17
|
-
a.should_not be_nil
|
18
|
-
a.should be >= 0
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'CPUUsage' do
|
23
|
-
it "should be the percentage of cpu used" do
|
24
|
-
a = Usagewatch.uw_cpuused
|
25
|
-
a.class.should be(Float)
|
26
|
-
a.should_not be_nil
|
27
|
-
a.should be <= 100
|
28
|
-
a.should be >= 0
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'PercentageDiskUsage' do
|
33
|
-
it "should be the percentage of GB of disk used" do
|
34
|
-
a = Usagewatch.uw_diskused_perc
|
35
|
-
a.class.should be(Float)
|
36
|
-
a.should_not be_nil
|
37
|
-
a.should be <= 100
|
38
|
-
a.should be >= 0
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe 'LoadAverage' do
|
43
|
-
it "should be the average load of the past minute" do
|
44
|
-
a = Usagewatch.uw_load
|
45
|
-
a.class.should be(Float)
|
46
|
-
a.should_not be_nil
|
47
|
-
a.should be >= 0
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'TopCPUUsage' do
|
52
|
-
it "should be an array of top cpu consumption proccesses " do
|
53
|
-
a = Usagewatch.uw_cputop
|
54
|
-
a.class.should be(Array )
|
55
|
-
a.should_not be_nil
|
56
|
-
a[0][0].class.should be String
|
57
|
-
a[0][1].class.should be String
|
58
|
-
a.count.should be == 10
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe 'TopMEMUsage' do
|
63
|
-
it "should be an array of top mem consumption proccesses " do
|
64
|
-
a = Usagewatch.uw_cputop
|
65
|
-
a.class.should be(Array )
|
66
|
-
a.should_not be_nil
|
67
|
-
a[0][0].class.should be String
|
68
|
-
a[0][1].class.should be String
|
69
|
-
a.count.should be == 10
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|