usagewatch_ext 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbf9aef5b40a6c623b53b1a14d3648b48d1b0f9d
4
+ data.tar.gz: 413209ed1d837e88a12f19726cf7f219a41c3b99
5
+ SHA512:
6
+ metadata.gz: b1cea11f648eaf45dece3519a32713d6ef02034ac7961455741321200cf110bf9079a3c7a496060c2303d9cd836d63308b466482bf1f3491779e700b4414be63
7
+ data.tar.gz: 915a5e4a891fcc9d1b27b7687d35d556adc7845d498a9229711d78616b35c22e73a43d9c3c0886b443fcb73d4ce1c32b5d95e35fca19e38d1a712603ea1af51e
data/README.md CHANGED
@@ -84,12 +84,17 @@ Top Ten Processes By CPU Consumption: [["PluginProcess", "9.0"], ["WindowServer"
84
84
  Top Ten Processes By Memory Consumption: [["WebProcess", "8.3"], ["rubymine", "6.4"], ["Safari", "2.0"], ["iPhoto", "1.8"], ["Mail", "1.7"], ["mds", "1.6"], ["ruby", "1.5"], ["WindowServer", "1.3"], ["PluginProcess", "1.2"], ["GitHub", "1.1"]]
85
85
  ```
86
86
 
87
+ Simple sinatra app for monitoring your server
88
+ https://github.com/rderoldan1/ServerMonit
87
89
 
88
90
  ## Methods available
89
91
 
90
92
  ##### Linux
91
93
  uw_diskused
94
+ uw_diskused_on(location)
92
95
  uw_diskused_perc
96
+ uw_diskavailable
97
+ uw_diskavailable_on(location)
93
98
  uw_cpuused
94
99
  uw_tcpused
95
100
  uw_udpused
@@ -105,7 +110,10 @@ Top Ten Processes By Memory Consumption: [["WebProcess", "8.3"], ["rubymine", "6
105
110
 
106
111
  ##### Mac
107
112
  uw_diskused
113
+ uw_diskused_on(location)
108
114
  uw_diskused_perc
115
+ uw_diskavailable
116
+ uw_diskavailable_on(location)
109
117
  uw_cputop
110
118
  uw_memtop
111
119
  uw_load
@@ -122,6 +130,12 @@ Top Ten Processes By Memory Consumption: [["WebProcess", "8.3"], ["rubymine", "6
122
130
 
123
131
  * Disk Used Percentage is a total percentage of all disk partitions used
124
132
 
133
+ * Disk Used On is disk space used on the location passed calculated in Gigabytes, returns "location invalid" if invalid location passed
134
+
135
+ * Disk Available is a sum of all partitions calculated in Gigabytes
136
+
137
+ * Disk Available On is disk space available on the location passed calculated in Gigabytes, returns "location invalid" if invalid location passed
138
+
125
139
  * CPU Used is a percentage of current CPU being used
126
140
 
127
141
  * TCP/UDP Connections Used is a total count of each respectively
@@ -13,6 +13,44 @@ module Usagewatch
13
13
  sum.round(2)
14
14
  end
15
15
 
16
+ # Show disk space used on location(partition) in GB
17
+ def self.uw_diskused_on(location)
18
+ df = `df`
19
+ df.split("\n")[1..-1].each do |line|
20
+ parts = line.split(" ")
21
+ if parts.last == location
22
+ diskusedon = ((parts[2].to_i.round(2)/1024)/1024).round(2)
23
+ break
24
+ end
25
+ end
26
+ diskusedon ? diskusedon : "location invalid"
27
+ end
28
+
29
+ # Show disk space available in GB
30
+ def self.uw_diskavailable
31
+ df = `df`
32
+ parts = df.split(" ").map { |s| s.to_i }
33
+ sum = 0
34
+ for i in (9..parts.size - 1).step(6) do
35
+ sum += parts[i+1]
36
+ end
37
+ round = sum.round(2)
38
+ totaldiskavailable = ((round/1024)/1024).round(2)
39
+ end
40
+
41
+ # Show disk space available on location(partition) in GB
42
+ def self.uw_diskavailable_on(location)
43
+ df = `df`
44
+ df.split("\n")[1..-1].each do |line|
45
+ parts = line.split(" ")
46
+ if parts.last == location
47
+ diskavailableon = ((parts[3].to_i.round(2)/1024)/1024).round(2)
48
+ break
49
+ end
50
+ end
51
+ diskavailableon ? diskavailableon : "location invalid"
52
+ end
53
+
16
54
  # Show the percentage of disk used.
17
55
  def self.uw_diskused_perc
18
56
  df, total, used = `df -kl`, 0.0, 0.0
@@ -117,4 +155,4 @@ module Usagewatch
117
155
  def self.to_gb(bytes)
118
156
  (bytes/1024)/1024
119
157
  end
120
- end
158
+ end
@@ -1,4 +1,4 @@
1
1
  module UsagewatchExt
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  OS = RUBY_PLATFORM
4
4
  end
data/spec/general_spec.rb CHANGED
@@ -17,6 +17,32 @@ describe 'DiskUsage' do
17
17
  end
18
18
  end
19
19
 
20
+ describe 'DiskUsage_on' do
21
+ it "should be the GB of disk used on root partition" do
22
+ a = Usagewatch.uw_diskused_on("/")
23
+ a.class.should be(Float)
24
+ a.should_not be_nil
25
+ a.should be >= 0
26
+ end
27
+ end
28
+
29
+ describe 'DiskAvailable' do
30
+ it "should be the GB of disk available" do
31
+ a = Usagewatch.uw_diskavailable
32
+ a.class.should be(Float)
33
+ a.should_not be_nil
34
+ end
35
+ end
36
+
37
+ describe 'DiskAvailable_on' do
38
+ it "should be the GB of disk used on root partition" do
39
+ a = Usagewatch.uw_diskavailable_on("/")
40
+ a.class.should be(Float)
41
+ a.should_not be_nil
42
+ end
43
+ end
44
+
45
+
20
46
  describe 'CPUUsage' do
21
47
  it "should be the percentage of cpu used" do
22
48
  a = Usagewatch.uw_cpuused
@@ -76,5 +102,3 @@ describe 'HTTPConns' do
76
102
  a.should be >= 0
77
103
  end
78
104
  end
79
-
80
-
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usagewatch_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ruben Espinosa, Phil Chen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2014-01-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: usagewatch
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,33 +41,29 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: A Ruby Gem with methods to find usage statistics such as CPU, Disk, TCP/UDP
@@ -105,39 +96,31 @@ files:
105
96
  homepage: https://github.com/rderoldan1/usagewatch_ext
106
97
  licenses:
107
98
  - MIT
108
- post_install_message: ! '* Usagewatch Gem for linux are covered for our test.
109
-
99
+ metadata: {}
100
+ post_install_message: |-
101
+ * Usagewatch Gem for linux are covered for our test.
110
102
  * Mac OS version is in development
111
-
112
- Thanks for installing!'
103
+ Thanks for installing!
113
104
  rdoc_options:
114
105
  - --main
115
106
  - README
116
107
  require_paths:
117
108
  - lib
118
109
  required_ruby_version: !ruby/object:Gem::Requirement
119
- none: false
120
110
  requirements:
121
- - - ! '>='
111
+ - - '>='
122
112
  - !ruby/object:Gem::Version
123
113
  version: '0'
124
- segments:
125
- - 0
126
- hash: 379101011193989804
127
114
  required_rubygems_version: !ruby/object:Gem::Requirement
128
- none: false
129
115
  requirements:
130
- - - ! '>='
116
+ - - '>='
131
117
  - !ruby/object:Gem::Version
132
118
  version: '0'
133
- segments:
134
- - 0
135
- hash: 379101011193989804
136
119
  requirements: []
137
120
  rubyforge_project:
138
- rubygems_version: 1.8.25
121
+ rubygems_version: 2.0.14
139
122
  signing_key:
140
- specification_version: 3
123
+ specification_version: 4
141
124
  summary: Extended version of usagewatch
142
125
  test_files:
143
126
  - spec/general_spec.rb