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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a01bd265984e129de028843fa35ad7fe0a607c32
4
- data.tar.gz: 27ac05e727bba69af04dce0ed9d9757aeb492fc3
3
+ metadata.gz: 056e39e90d51c69d39bc51f8d67299bb4b4bf29e
4
+ data.tar.gz: 8d4afc75d072cfb204fafc2213c067ec5a8e2b39
5
5
  SHA512:
6
- metadata.gz: 51bde6dc82474cc8fff9e2afdab7f97268736f8cb60f9aa17d87a90b8e1bff7fec6e987626065009f42901868e36520a1b7aa85a57b3f7766ad812d509a474cf
7
- data.tar.gz: ff410708d63d2e7306593878625ad4c1b3c6735e2ff6e437734babbeda2003a7a9a2bbc3de69a94b7d927516e7e0ba55f12a884595684042ecac2df397a1f3cc
6
+ metadata.gz: 23ae494808a76d61a3edb4fbe6c9d48344d8677ce07719d9bee8549600b3b80fb380f35272c50e7e5922a3ca8fd647d7076fd2390141d3583603dd6ba22d6331
7
+ data.tar.gz: 20fab1f17879ac8dd4f28c33d31e8b40613fb0d7e40fb3a202b6d529970bd7ff2ddc293bf54917c49f02090e4e4fc0d88d42678bc92e0fd6ae8cbe2354579b3d
@@ -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
- collector = GenesisCollector::Collector.new
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
@@ -1,3 +1,3 @@
1
1
  module GenesisCollector
2
- VERSION = '0.1.13'
2
+ VERSION = '0.1.14'
3
3
  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.13
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-09 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler