LinuxSystemInfo 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/README.md +32 -14
- data/lib/LinuxSystemInfo.rb +11 -1
- data/lib/LinuxSystemInfo/version.rb +1 -1
- data/spec/info_spec.rb +25 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e33c3ed0e35d27ae01f96229e1f6c08d74606214
|
4
|
+
data.tar.gz: 9635ae1c6fb8f7411fce08b9c9b51487da177400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3c41525f626445a289e1c7e47fa180469df32bf7c99107e1cf1fb667e43014c43808e3b3f97c04a0df00557cf1c9b169ebfa6d3d1902e26096540ba781c9db4
|
7
|
+
data.tar.gz: 7487e9c0f78c2a5431a46fbac8868eb197b69a35d318cbed1d128f911cb898db930828422bd1da1175f544d4dea817c06f55fa2f23695b3fab8d1c78c655e4e1
|
data/README.md
CHANGED
@@ -41,11 +41,23 @@ Or install it yourself as:
|
|
41
41
|
|
42
42
|
## Usage
|
43
43
|
|
44
|
+
#### Info
|
45
|
+
|
46
|
+
LinuxSystemInfo.info
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
{
|
50
|
+
:os=>"Linux version 3.13.0-45-generic (buildd@phianna) ...",
|
51
|
+
:uptime=>"up 5 hours, 57 minutes",
|
52
|
+
:users=>"8"
|
53
|
+
}
|
54
|
+
```
|
55
|
+
|
44
56
|
#### CPU
|
45
57
|
|
46
58
|
LinuxSystemInfo.cpu
|
47
59
|
|
48
|
-
```
|
60
|
+
```ruby
|
49
61
|
{
|
50
62
|
:model=>
|
51
63
|
{
|
@@ -73,7 +85,7 @@ LinuxSystemInfo.cpu
|
|
73
85
|
|
74
86
|
LinuxSystemInfo.memory
|
75
87
|
|
76
|
-
```
|
88
|
+
```ruby
|
77
89
|
{
|
78
90
|
:unit => "Megabyte",
|
79
91
|
:total => "7431",
|
@@ -89,7 +101,7 @@ LinuxSystemInfo.memory
|
|
89
101
|
|
90
102
|
LinuxSystemInfo.storage
|
91
103
|
|
92
|
-
```
|
104
|
+
```ruby
|
93
105
|
{
|
94
106
|
"/dev/sda1" =>
|
95
107
|
{
|
@@ -130,7 +142,7 @@ LinuxSystemInfo.storage
|
|
130
142
|
|
131
143
|
LinuxSystemInfo.connection
|
132
144
|
|
133
|
-
```
|
145
|
+
```ruby
|
134
146
|
{
|
135
147
|
"eth0" =>
|
136
148
|
{
|
@@ -155,7 +167,7 @@ LinuxSystemInfo.video
|
|
155
167
|
|
156
168
|
LinuxSystemInfo.audio
|
157
169
|
|
158
|
-
```
|
170
|
+
```ruby
|
159
171
|
[
|
160
172
|
"Intel Corporation Haswell-ULT HD Audio Controller (rev 09)",
|
161
173
|
"Intel Corporation Lynx Point-LP HD Audio Controller (rev 04)"
|
@@ -166,7 +178,7 @@ LinuxSystemInfo.audio
|
|
166
178
|
|
167
179
|
LinuxSystemInfo.usb
|
168
180
|
|
169
|
-
```
|
181
|
+
```ruby
|
170
182
|
[
|
171
183
|
"Intel Corporation Lynx Point-LP USB xHCI HC (rev 04)",
|
172
184
|
"Intel Corporation Lynx Point-LP USB EHCI #1 (rev 04)"
|
@@ -177,7 +189,7 @@ LinuxSystemInfo.usb
|
|
177
189
|
|
178
190
|
LinuxSystemInfo.network
|
179
191
|
|
180
|
-
```
|
192
|
+
```ruby
|
181
193
|
[
|
182
194
|
"Intel Corporation Ethernet Connection I218-V (rev 04)",
|
183
195
|
"Intel Corporation Wireless 7260 (rev 73)"
|
@@ -196,12 +208,18 @@ LinuxSystemInfo.hostname
|
|
196
208
|
|
197
209
|
LinuxSystemInfo.to_hash
|
198
210
|
|
199
|
-
```
|
211
|
+
```ruby
|
200
212
|
{
|
213
|
+
:info =>
|
214
|
+
{
|
215
|
+
:os => "Linux version 3.13.0-45-generic (buildd@phianna) ...",
|
216
|
+
:uptime => "up 5 hours, 57 minutes",
|
217
|
+
:users => "8"
|
218
|
+
},
|
201
219
|
:hostname => "example.com",
|
202
|
-
:cpu=>
|
220
|
+
:cpu =>
|
203
221
|
{
|
204
|
-
:model=>
|
222
|
+
:model =>
|
205
223
|
{
|
206
224
|
:name => "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz",
|
207
225
|
:number => "69"
|
@@ -221,7 +239,7 @@ LinuxSystemInfo.to_hash
|
|
221
239
|
:L2 => "256K",
|
222
240
|
:L3 => "3072K"
|
223
241
|
},
|
224
|
-
:ram=>
|
242
|
+
:ram =>
|
225
243
|
{
|
226
244
|
:unit => "Megabyte",
|
227
245
|
:total => "15001",
|
@@ -231,7 +249,7 @@ LinuxSystemInfo.to_hash
|
|
231
249
|
:buffers => "231",
|
232
250
|
:cached => "1836"
|
233
251
|
},
|
234
|
-
:storage=>
|
252
|
+
:storage =>
|
235
253
|
{
|
236
254
|
"/dev/sda1" =>
|
237
255
|
{
|
@@ -266,12 +284,12 @@ LinuxSystemInfo.to_hash
|
|
266
284
|
:mount => "/virtualbox"
|
267
285
|
}
|
268
286
|
},
|
269
|
-
:network=>
|
287
|
+
:network =>
|
270
288
|
[
|
271
289
|
"Intel Corporation Ethernet Connection I218-V (rev 04)",
|
272
290
|
"Intel Corporation Wireless 7260 (rev 73)"
|
273
291
|
],
|
274
|
-
:connection=>
|
292
|
+
:connection =>
|
275
293
|
{
|
276
294
|
"eth0" =>
|
277
295
|
{
|
data/lib/LinuxSystemInfo.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
require 'LinuxSystemInfo/version'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module LinuxSystemInfo
|
4
5
|
class << self
|
6
|
+
def info
|
7
|
+
{
|
8
|
+
os: `cat /proc/version`.strip,
|
9
|
+
uptime: `uptime -p`.strip,
|
10
|
+
users: `users | wc -w`.strip
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
5
14
|
def connection
|
6
15
|
output = Hash.new
|
7
16
|
network = `ifconfig`
|
@@ -132,6 +141,7 @@ module LinuxSystemInfo
|
|
132
141
|
|
133
142
|
def to_hash
|
134
143
|
{
|
144
|
+
:info => info,
|
135
145
|
:hostname => hostname,
|
136
146
|
:cpu => cpu,
|
137
147
|
:ram => memory,
|
@@ -145,7 +155,7 @@ module LinuxSystemInfo
|
|
145
155
|
end
|
146
156
|
|
147
157
|
def to_s
|
148
|
-
JSON.pretty_generate
|
158
|
+
JSON.pretty_generate(to_hash)
|
149
159
|
end
|
150
160
|
end
|
151
161
|
end
|
data/spec/info_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'With info' do
|
4
|
+
before(:all) do
|
5
|
+
@os = LinuxSystemInfo.info
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'the returned value' do
|
9
|
+
it 'will have valid list' do
|
10
|
+
expect(@os.length).to be == 3
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'will have os' do
|
14
|
+
expect(@os.first).to_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'will have valid uptime' do
|
18
|
+
expect(@os[:uptime]).to match /up \d+ [a-z]+, \d+ [a-z]+/
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'will have valid users count' do
|
22
|
+
expect(@os[:users].to_i).to be > 0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: LinuxSystemInfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saimon Lovell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/LinuxSystemInfo/version.rb
|
87
87
|
- spec/connection_spec.rb
|
88
88
|
- spec/cpu_spec.rb
|
89
|
+
- spec/info_spec.rb
|
89
90
|
- spec/network_spec.rb
|
90
91
|
- spec/ram_spec.rb
|
91
92
|
- spec/spec_helper.rb
|
@@ -119,6 +120,7 @@ summary: Get local linux hardware information.
|
|
119
120
|
test_files:
|
120
121
|
- spec/connection_spec.rb
|
121
122
|
- spec/cpu_spec.rb
|
123
|
+
- spec/info_spec.rb
|
122
124
|
- spec/network_spec.rb
|
123
125
|
- spec/ram_spec.rb
|
124
126
|
- spec/spec_helper.rb
|