internet_box_logger 0.1.1

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.
@@ -0,0 +1,59 @@
1
+ module InternetBoxLogger
2
+ module Tasks
3
+ module Kibana
4
+
5
+ def kibana_reports_source
6
+ reports_source = "#{ibl_gem_path}/config/kibana_reports"
7
+ Dir.entries(reports_source).keep_if {|e| e =~ /_report\.json$/i }.map {|e| "#{reports_source}/#{e}"}
8
+ end
9
+
10
+ def kibana_dashboards_path
11
+ "#{kibana_path}/app/dashboards"
12
+ end
13
+
14
+ def kibana_path
15
+ EasyAppHelper.config[:kibana_path]
16
+ end
17
+
18
+ def kibana_symlink_path
19
+ "#{EasyAppHelper.config.root}/public/kibana"
20
+ end
21
+
22
+ def valid_kibana_path? path
23
+ File.exists? "#{path}/index.html"
24
+ end
25
+
26
+ def deploy_reports
27
+ kibana_reports_source.each do |report_file|
28
+ EasyAppHelper.puts_and_logs " - Installing '#{report_file}' to '#{kibana_dashboards_path}'"
29
+ options = {}
30
+ FileUtils.cp report_file, kibana_dashboards_path, options
31
+ end
32
+ end
33
+
34
+ def serve_ui(port=EasyAppHelper.config[:server_port])
35
+ require 'webrick'
36
+ port ||= EasyAppHelper.config[:server_port]
37
+ WEBrick::HTTPServer.new(:Port => port, :DocumentRoot => kibana_path).start
38
+ end
39
+
40
+ def kibana_info
41
+ if valid_kibana_path?(kibana_path)
42
+ EasyAppHelper.puts_and_logs "A valid Kibana install has been found in #{kibana_path}"
43
+ else
44
+ raise <<EOM
45
+ No Kibana installation found in '#{kibana_path}'.
46
+ You may want to update 'kibana_path' in your config to be able to use the 'deploy' target.
47
+
48
+ If Kibana is not on the machine this gem is installed you may have to manually copy files located in:
49
+ - #{ibl_gem_path}/config/kibana_reports
50
+ into your Kibana dashboards path:
51
+ - <place where your Kibana is installed>/app/dashboards
52
+
53
+ EOM
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe InternetBoxLogger::ElasticSearch do
4
+
5
+
6
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe InternetBoxLogger do
5
+
6
+ subject {InternetBoxLogger}
7
+
8
+ it 'should not accept invalid parsers' do
9
+ expect{ subject.get_box(:stupid)}.to raise_error
10
+ end
11
+
12
+ it 'should accept any valid parser' do
13
+ InternetBoxLogger::Parsers[].each do |parser|
14
+ expect{ subject.get_box(parser)}.not_to raise_error
15
+ end
16
+ end
17
+
18
+ it 'should use the default box type if not provided' do
19
+ expect{ subject.get_box}.not_to raise_error
20
+ end
21
+
22
+ it 'should include a parser of the box_type specified in the constructor' do
23
+ parser = InternetBoxLogger::Parsers::FreeboxV5Parser
24
+ box = subject.get_box(parser)
25
+ expect( box.respond_to? :get_box_data).to be_truthy
26
+ end
27
+
28
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe InternetBoxLogger::Parsers do
4
+
5
+ it 'should have 1 parser' do
6
+ expect(subject[].length == 1).to be_truthy
7
+ end
8
+
9
+
10
+ InternetBoxLogger::Parsers[].each do |current_parser|
11
+
12
+ context "when testing '#{current_parser}' parser" do
13
+
14
+ subject {
15
+ s = Object.new
16
+ s.extend current_parser
17
+ s
18
+ }
19
+
20
+ it 'should parse an url' do
21
+ expect{ subject.get_box_data}.not_to raise_error
22
+ end
23
+
24
+ it 'should feed attributes' do
25
+ subject.get_box_data
26
+ expect(subject.attributes.nil?).to be_falsey
27
+ expect(subject.attributes.empty?).to be_falsey
28
+ end
29
+
30
+ it 'should use all regexp during parsing' do
31
+ expect(subject.get_box_data).not_to be_nil
32
+ end
33
+
34
+ it 'should export data as an array' do
35
+ subject.get_box_data
36
+ expect(subject.as_es_documents is_a? Array).to be_truthy
37
+ end
38
+
39
+ it 'should have many up/down documents and one info' do
40
+ subject.get_box_data
41
+ docs = subject.as_es_documents
42
+ up, down, info, unknown = 0, 0, 0, 0
43
+ docs.each do |doc|
44
+ case doc[:type]
45
+ when 'up'
46
+ up += 1
47
+ when 'down'
48
+ down += 1
49
+ when :info
50
+ info += 1
51
+ else
52
+ unknown += 1
53
+ end
54
+ end
55
+ expect(up == down).to be_truthy
56
+ expect(info == 1).to be_truthy
57
+ expect(unknown == 0).to be_truthy
58
+ end
59
+
60
+
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,94 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+
17
+ require 'internet_box_logger'
18
+ EasyAppHelper.config.script_filename = File.expand_path '../../config/internet_box_logger.conf', __FILE__
19
+ EasyAppHelper.config[:freebox_alternate_url] = File.expand_path '../../test/freebox_page_example.txt', __FILE__
20
+
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ =begin
49
+ # These two settings work together to allow you to limit a spec run
50
+ # to individual examples or groups you care about by tagging them with
51
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
+ # get run.
53
+ config.filter_run :focus
54
+ config.run_all_when_everything_filtered = true
55
+
56
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
57
+ # For more details, see:
58
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
59
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
60
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
61
+ config.disable_monkey_patching!
62
+
63
+ # This setting enables warnings. It's recommended, but in some cases may
64
+ # be too noisy due to issues in dependencies.
65
+ config.warnings = true
66
+
67
+ # Many RSpec users commonly either run the entire suite or an individual
68
+ # file, and it's useful to allow more verbose output when running an
69
+ # individual spec file.
70
+ if config.files_to_run.one?
71
+ # Use the documentation formatter for detailed output,
72
+ # unless a formatter has already been configured
73
+ # (e.g. via a command-line flag).
74
+ config.default_formatter = 'doc'
75
+ end
76
+
77
+ # Print the 10 slowest examples and example groups at the
78
+ # end of the spec run, to help surface which specs are running
79
+ # particularly slow.
80
+ config.profile_examples = 10
81
+
82
+ # Run specs in random order to surface order dependencies. If you find an
83
+ # order dependency and want to debug it, you can fix the order by providing
84
+ # the seed, which is printed after each run.
85
+ # --seed 1234
86
+ config.order = :random
87
+
88
+ # Seed global randomization in this process using the `--seed` CLI option.
89
+ # Setting this allows you to use `--seed` to deterministically reproduce
90
+ # test failures related to randomization by passing the same `--seed` value
91
+ # as the one that triggered the failure.
92
+ Kernel.srand config.seed
93
+ =end
94
+ end
@@ -0,0 +1,103 @@
1
+ ______________________________________________________________________
2
+
3
+ Etat de la Freebox
4
+ ______________________________________________________________________
5
+
6
+
7
+ Informations générales :
8
+ ========================
9
+
10
+ Modèle Freebox ADSL
11
+ Version du firmware 1.5.20
12
+ Mode de connection Dégroupé
13
+ Temps depuis la mise en route 12 jours, 16 heures, 27 minutes
14
+
15
+
16
+ Téléphone :
17
+ ===========
18
+
19
+ Etat Ok
20
+ Etat du combiné Raccroché
21
+ Sonnerie Inactive
22
+
23
+
24
+ Adsl :
25
+ ======
26
+
27
+ Etat Showtime
28
+ Protocole ADSL2+
29
+ Mode Interleaved
30
+
31
+ Descendant Montant
32
+ -- --
33
+ Débit ATM 8949 kb/s 1025 kb/s
34
+ Marge de bruit 5.20 dB 7.30 dB
35
+ Atténuation 30.50 dB 15.30 dB
36
+ FEC 1190251 1771272
37
+ CRC 2338 0
38
+ HEC 120 149402
39
+
40
+ Journal de connexion adsl :
41
+ ---------------------------
42
+
43
+ Date Etat Débit (kb/s)
44
+ -- -- --
45
+ Mise en route Connexion 10292 / 1025
46
+
47
+
48
+ Wifi :
49
+ ======
50
+
51
+ Etat WiFi désactivé
52
+ Modèle Ralink RT2880
53
+ Canal 3
54
+ État du réseau Désactivé
55
+ FreeWifi Désactivé
56
+ FreeWifi Secure Désactivé
57
+
58
+
59
+ Réseau :
60
+ ========
61
+
62
+ Adresse MAC Freebox 12:34:56:78:9A:BC
63
+ Adresse IP 88.111.111.111
64
+ IPv6 Désactivé
65
+ Mode routeur Activé
66
+ Adresse IP privée 192.168.0.254
67
+ Adresse IP DMZ 192.168.0.0
68
+ Adresse IP Freeplayer 192.168.0.2
69
+ Réponse au ping Activé
70
+ Proxy Wake On Lan Désactivé
71
+ Serveur DHCP Activé
72
+ Plage d'adresses dynamique 192.168.0.10 - 192.168.0.50
73
+
74
+ Attributions dhcp :
75
+ -------------------
76
+
77
+ Adresse MAC Adresse IP
78
+ -- --
79
+ 01:23:45:67:89:AB 192.168.0.10
80
+
81
+ Redirections de ports :
82
+ -----------------------
83
+
84
+ Protocole Port source Destination Port destination
85
+ -- -- -- --
86
+ UDP 12345 192.168.0.10 2222
87
+
88
+ Redirections de plage de ports :
89
+ --------------------------------
90
+
91
+ Protocole Destination Plage de redirection
92
+ -- -- --
93
+ TCP 192.168.0.10 6881 - 6889
94
+
95
+ Interfaces réseau :
96
+ -------------------
97
+
98
+ Lien Débit entrant Débit sortant
99
+ -- -- --
100
+ WAN Ok 0 ko/s 0 ko/s
101
+ Ethernet 0 ko/s 0 ko/s
102
+ USB Non connecté
103
+ Switch 100baseTX-FD 0 ko/s 308 ko/s
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: internet_box_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Laurent B
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: whenever
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: easy_app_helper
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: elasticsearch
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Logs information gathered from your internet box and stores into ElasticSearch
126
+ for display into Kibana.
127
+ email:
128
+ - lbnetid+gh@gmail.com
129
+ executables:
130
+ - internet_box_logger
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - .rspec
136
+ - .travis.yml
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - bin/internet_box_logger
143
+ - config/internet_box_logger.conf
144
+ - config/kibana_reports/FreeboxV5_report.json
145
+ - config/schedule.rb
146
+ - internet_box_logger.gemspec
147
+ - lib/internet_box_logger.rb
148
+ - lib/internet_box_logger/elastic_search.rb
149
+ - lib/internet_box_logger/generic_box.rb
150
+ - lib/internet_box_logger/parsers.rb
151
+ - lib/internet_box_logger/parsers/freebox_v5_parser.rb
152
+ - lib/internet_box_logger/parsers/utils.rb
153
+ - lib/internet_box_logger/version.rb
154
+ - lib/tasks/cron.rb
155
+ - lib/tasks/elastic_search.rb
156
+ - lib/tasks/file.rb
157
+ - lib/tasks/internet_box_logger_tasks.rake
158
+ - lib/tasks/internet_box_logger_tasks.rb
159
+ - lib/tasks/kibana.rb
160
+ - spec/elastic_search_spec.rb
161
+ - spec/internet_box_logger_spec.rb
162
+ - spec/parsers_spec.rb
163
+ - spec/spec_helper.rb
164
+ - test/freebox_page_example.txt
165
+ homepage: ''
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.0.0
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Monitor your internet box.
189
+ test_files:
190
+ - spec/elastic_search_spec.rb
191
+ - spec/internet_box_logger_spec.rb
192
+ - spec/parsers_spec.rb
193
+ - spec/spec_helper.rb
194
+ - test/freebox_page_example.txt