genesis_collector 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/genesis_collector +32 -1
- data/lib/genesis_collector/collector.rb +1 -1
- data/lib/genesis_collector/disks.rb +5 -0
- data/lib/genesis_collector/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 056e39e90d51c69d39bc51f8d67299bb4b4bf29e
|
4
|
+
data.tar.gz: 8d4afc75d072cfb204fafc2213c067ec5a8e2b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ae494808a76d61a3edb4fbe6c9d48344d8677ce07719d9bee8549600b3b80fb380f35272c50e7e5922a3ca8fd647d7076fd2390141d3583603dd6ba22d6331
|
7
|
+
data.tar.gz: 20fab1f17879ac8dd4f28c33d31e8b40613fb0d7e40fb3a202b6d529970bd7ff2ddc293bf54917c49f02090e4e4fc0d88d42678bc92e0fd6ae8cbe2354579b3d
|
data/exe/genesis_collector
CHANGED
@@ -3,8 +3,39 @@
|
|
3
3
|
require 'bundler/setup'
|
4
4
|
require 'genesis_collector'
|
5
5
|
require 'pp'
|
6
|
+
require 'optparse'
|
7
|
+
require 'json'
|
6
8
|
|
7
|
-
|
9
|
+
options = {
|
10
|
+
submit: false
|
11
|
+
}
|
12
|
+
config = {}
|
13
|
+
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.banner = "Usage: genesis_collector [options]"
|
16
|
+
opts.on('--submit', 'Submit data to Genesis server') do
|
17
|
+
options[:submit] = true
|
18
|
+
end
|
19
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
20
|
+
puts opts
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
opts.on_tail('--version', 'Show version') do
|
24
|
+
puts "geensis_collector #{GenesisCollector::VERSION}"
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end.parse!
|
28
|
+
|
29
|
+
if true == options[:submit]
|
30
|
+
raise ArgumentError, 'Missing config file: ~/.genesis' unless File.exist?("#{ENV['HOME']}/.genesis")
|
31
|
+
raw_config = JSON.parse(File.read("#{ENV['HOME']}/.genesis"))
|
32
|
+
config[:endpoint] = config['endpoint']
|
33
|
+
config[:api_token] = config['api_token']
|
34
|
+
end
|
35
|
+
|
36
|
+
collector = GenesisCollector::Collector.new(config)
|
8
37
|
collector.collect!
|
9
38
|
|
10
39
|
pp collector.payload
|
40
|
+
|
41
|
+
collector.submit! if true == options[:submit]
|
@@ -159,7 +159,7 @@ module GenesisCollector
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def read_dmi(key)
|
162
|
-
value = shellout_with_timeout("dmidecode -s #{key}").gsub(/\s+|\./, '')
|
162
|
+
value = shellout_with_timeout("dmidecode -s #{key}").gsub(/^#.+$/, '').gsub(/\s+|\./, '')
|
163
163
|
value.empty? ? nil : value
|
164
164
|
end
|
165
165
|
end
|
@@ -10,6 +10,7 @@ module GenesisCollector
|
|
10
10
|
d[:product] = info.match(/^(?:Device Model|Product):\s+(.*)$/)[1]
|
11
11
|
d[:serial_number] = info.match(/^Serial (?:n|N)umber:\s+(.*)$/)[1]
|
12
12
|
d[:size] = info.match(/^User Capacity:\s+(.*)$/)[1].split('bytes')[0].strip.gsub(',', '')
|
13
|
+
d[:slot] = get_scsi_slot(d[:dev]) if d[:dev] =~ /^\/dev\/sd/
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -31,5 +32,9 @@ module GenesisCollector
|
|
31
32
|
shellout_with_timeout("smartctl -i #{cmd_params}", 5)
|
32
33
|
end
|
33
34
|
|
35
|
+
# FIXME - we might want to handle raid devices differently by parsing megacli
|
36
|
+
def get_scsi_slot(device)
|
37
|
+
File.basename(File.readlink("/sys/class/block/#{File.basename(device)}/device"))
|
38
|
+
end
|
34
39
|
end
|
35
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genesis_collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Radcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|