gaddygaddy 0.1.80 → 0.1.82

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: 767f0e97ad96d8461a9a3f521774e19399bf8cf5
4
- data.tar.gz: 618ff2754c92de61e653faec2c3157ad206d4579
3
+ metadata.gz: 367a647eaed629131dad0763d0c8381fb689cd7a
4
+ data.tar.gz: b2337553aeb12cf5d6d8d7413667dbcfba5257b3
5
5
  SHA512:
6
- metadata.gz: 20e9baef73bd6cbcf45342c41e475885c1e64486f367a7678ab9cba646673aca1ba3162336b1392cbc78cfdbafd4bd78e0eb936c74a09eb68a9b22d21328ce82
7
- data.tar.gz: 109f8adc5b2ba370b44820720dafcbff1f229d0d2789ac8824bcaa2c90cd3274344df07b6178c4b266bb66cccd533ab4b520925ebc34356f445f0392bd2007c8
6
+ metadata.gz: a415556bd5d6cf6d29f6e7e38573c134807733c4e09fcd064e03e6d889c6029d5b0a5e8fc345f604bc8467f67af9ae48fc76bb0e2b0617dcfbef6f79018f0d83
7
+ data.tar.gz: faa5106548067148b5efe4aaa7380b8bcb15b1f54f6d7570d603c55fd9d5c96d64695b27a1de5a84a84824cfad440a378c35e4b456cefc5163648b8dade1356a
@@ -0,0 +1,61 @@
1
+ #
2
+ # Name:
3
+ # diagnose_data.rb
4
+ #
5
+ # Created by: mansson
6
+ #
7
+ # Description:
8
+ #
9
+ #
10
+ #
11
+ # Copyright (c) 2013 Recorded Future
12
+ #
13
+ # Licensed under the Apache License, Version 2.0 (the "License");
14
+ # you may not use this file except in compliance with the License.
15
+ # You may obtain a copy of the License at
16
+ #
17
+ # http://www.apache.org/licenses/LICENSE-2.0
18
+ #
19
+ # Unless required by applicable law or agreed to in writing, software
20
+ # distributed under the License is distributed on an "AS IS" BASIS,
21
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ # See the License for the specific language governing permissions and
23
+ # limitations under the License.
24
+
25
+ require 'mixlib/shellout'
26
+
27
+ class DiagnoseData
28
+
29
+ def self.get_all_diag_info
30
+ diagnose_data ={}
31
+ diagnose_data['resolvconf'] = get_file_data('/etc/resolv.conf')
32
+ diagnose_data['ifconfig'] = get_cmd_output('ifconfig')
33
+ diagnose_data
34
+ end
35
+
36
+ def self.get_file_data(file_name)
37
+ begin
38
+ file_data = {:file_name => file_name}
39
+ data_file = File.open(file_name,'r')
40
+ file_data[:file_content => data_file.read]
41
+ data_file.close
42
+ file_data[:file_time_stamp] = File.mtime(file_name)
43
+ rescue Exception => e
44
+ file_data['error'] = e.inspect
45
+ end
46
+ file_data
47
+ end
48
+
49
+ def self.get_cmd_output(cmd)
50
+ cmd_data = {:cmd => cmd}
51
+ cmd = Mixlib::ShellOut.new(cmd)
52
+ cmd.run_command
53
+ if cmd.error?
54
+ cmd_data[:error] = cmd.stderr
55
+ else
56
+ cmd_data[:result] = cmd.stdout
57
+ end
58
+ cmd_data
59
+ end
60
+
61
+ end
@@ -13,6 +13,8 @@
13
13
  # All rights reserved.
14
14
  #
15
15
 
16
+ VALID_FILE_NAMES = ['log','resolv']
17
+
16
18
  class LogData
17
19
 
18
20
  #
@@ -24,6 +26,7 @@ class LogData
24
26
  log_file_name = "/opt/log/#{log_file_name[0..-5]}/#{log_file_name}"
25
27
  end
26
28
  raise "File #{log_file_name} does not exist" unless File.exist?(log_file_name)
29
+ raise "File name must have log" if VALID_FILE_NAMES.select{|f| log_file_name.index f}.empty?
27
30
  cmd = "tail -n #{lines} #{log_file_name}"
28
31
  exit_code, stdout = systemu cmd
29
32
  if exit_code.success?
@@ -23,6 +23,7 @@ require 'utils/hash_monkeypatch'
23
23
  require 'json'
24
24
  require 'subcommand'
25
25
  require 'gaddygaddy-client/chef_files'
26
+ require 'gaddygaddy-client/diagnose_data'
26
27
  require 'gaddygaddy-client/notification'
27
28
  require 'gaddygaddy-client/log_data'
28
29
  require 'logging/logging'
@@ -145,9 +146,14 @@ class GaddyGaddy_Client
145
146
  opts.description = "Will send information about the gaddy to gaddygaddy.com"
146
147
  end
147
148
 
149
+ command :upload_diagnose_data do |opts|
150
+ opts.banner = "Usage: upload_diagnose_data[options]"
151
+ opts.description = "Will upload diagnose data"
152
+ end
153
+
148
154
  command :upload_log_file do |opts|
149
- opts.banner = "Usage: verify_installation[options]"
150
- opts.description = "Will verify the installation and check for gaddy file and network configuration"
155
+ opts.banner = "Usage: upload_log_file[options]"
156
+ opts.description = "Will upload log files"
151
157
  @options[:lines] = 100
152
158
  opts.on("-i", "--lines lines", "Number of lines to upload, count from end of file") do |lines|
153
159
  @options[:lines] = lines
@@ -277,6 +283,17 @@ class GaddyGaddy_Client
277
283
  @device_info.post
278
284
  end
279
285
 
286
+ def upload_diagnose_data
287
+ url = Request.get_base_url(get_host) + "/device/upload_diagnose_data/1/#{gg_config.user_id_salt}/#{gg_config.device_id}/#{gg_config.token}"
288
+ diagnose_data = DiagnoseData.get_all_diag_info
289
+ params = {:diagnose_data => diagnose_data,
290
+ :diagnose_time_stamp => Time.now
291
+ }
292
+ response = Request.client_service_post url, params
293
+ logger.debug "The response for the request is #{response} #{response.class}"
294
+ raise JCouldNotPostClientDataException.new({:message=> "Could not post data to the gaddygaddy service, error code is #{response.body}"}) unless response[:status].to_i == 0
295
+ end
296
+
280
297
  def upload_log_file
281
298
  raise "Missing option upload_log_file" unless @options[:upload_log_file]
282
299
  log_file_name = @options[:upload_log_file].split('/').last
@@ -379,6 +396,8 @@ class GaddyGaddy_Client
379
396
  notification = Notification::Send.new(:speech_enabled => settings['speech_enabled'])
380
397
  notification.event = @options[:event]
381
398
  notification.notify gg_config.device_id
399
+ when 'upload_diagnose_data'
400
+ upload_diagnose_data
382
401
  when 'upload_log_file'
383
402
  upload_log_file
384
403
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gaddygaddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.80
4
+ version: 0.1.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - GaddyGaddy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-13 00:00:00.000000000 Z
11
+ date: 2014-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -115,6 +115,7 @@ files:
115
115
  - lib/gaddygaddy-client.rb~
116
116
  - lib/gaddygaddy-client/chef_files.rb
117
117
  - lib/gaddygaddy-client/device_config.rb
118
+ - lib/gaddygaddy-client/diagnose_data.rb
118
119
  - lib/gaddygaddy-client/espeak.rb
119
120
  - lib/gaddygaddy-client/log_data.rb
120
121
  - lib/gaddygaddy-client/notification.rb