gaddygaddy 0.1.80 → 0.1.82
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/lib/gaddygaddy-client/diagnose_data.rb +61 -0
- data/lib/gaddygaddy-client/log_data.rb +3 -0
- data/lib/gaddygaddy-client.rb +21 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 367a647eaed629131dad0763d0c8381fb689cd7a
|
4
|
+
data.tar.gz: b2337553aeb12cf5d6d8d7413667dbcfba5257b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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?
|
data/lib/gaddygaddy-client.rb
CHANGED
@@ -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:
|
150
|
-
opts.description = "Will
|
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.
|
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-
|
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
|