internet_box_logger 0.1.1 → 0.1.2

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: d6eb612118c2d0893eaf96f60d371e1a4d96835f
4
- data.tar.gz: a5c4c091d8364206a56c843edcd071f1b8a7c3eb
3
+ metadata.gz: dafa9767902f6c0af10854c35f868267a3b53649
4
+ data.tar.gz: 98ef8698aae623a5c3b1222082095c823b8ac9a0
5
5
  SHA512:
6
- metadata.gz: d3ddbbe8a55e786285ba37ce681c07fc91d55e0ce765b945b28a1d3c81d34b2a7c2134b4734c70061695cb13f31bba3fc3cfa3afd3b1b304e8387161c73da32f
7
- data.tar.gz: 869d468ee6d9b08c9bd112f5e4acf4d859b292c37fb9835545d3ec997ac1a9447ee4be436ed19b7da175b327e5ed05b6c94df5f49f2ff6a6d4d04877def7cb98
6
+ metadata.gz: 1078ea5be514a32be8312a88c4db1073b6434a1a4d80c0fe92ec4a2bcf12c6c8bff4ba97d84671d44f4f882b6d5a00deefce6a9e5c7eba7ec09d0bf7ca4b61e5
7
+ data.tar.gz: 56c0477a59266bd91835cb7052c55fa076532bffd5a43c786e5b556a9b2aa8f8685e6004c89b02f350c57d9bcfe759dcbfc4fe877c43e7bc73c3ebf3c8423747
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # [InternetBoxLogger][IBL]
2
2
 
3
- [![Build Status](https://travis-ci.org/lbriais/internet_box_logger.png?branch=master)](https://travis-ci.org/lbriais/internet_box_logger)
4
- [![Gem Version](https://badge.fury.io/rb/internet_box_logger.png)](http://badge.fury.io/rb/internet_box_logger)
3
+ [![Build Status](https://travis-ci.org/lbriais/internet_box_logger.svg)](https://travis-ci.org/lbriais/internet_box_logger)
4
+ [![Gem Version](https://badge.fury.io/rb/internet_box_logger.svg)](http://badge.fury.io/rb/internet_box_logger)
5
5
 
6
6
  ## Overview
7
7
 
@@ -37,7 +37,8 @@ Or install it yourself as:
37
37
 
38
38
  ### Configuration
39
39
 
40
- Configuration thanks to [EasyAppHelper][EAP] enables multiple places to store your configuration. But most useful one should be:
40
+ Configuration, thanks to [EasyAppHelper][EAP], enables multiple places to store your configuration. But most useful
41
+ ones should be:
41
42
 
42
43
  * '`/etc/internet_box_logger.conf`' for a system-wide installation
43
44
  * '`~/.config/internet_box_logger.conf`' for a user-specific installation
@@ -59,22 +60,18 @@ default_elastic_search:
59
60
  elastic_binary: /opt/elasticsearch/bin/elasticsearch
60
61
  ```
61
62
 
62
- `box_type` specifies the module in charge of gathering data from your box. it Should not be changed but you can define
63
+ * `box_type` specifies the module in charge of gathering data from your box. it Should not be changed but you can define
63
64
  your own. **It is the way for you to add other types of boxes** if needed. If you do so, please do a pull-request
64
65
  afterwards.
65
-
66
- `cron_interval` defines the time in minutes between two measurements.
67
-
68
- `kibana_path` defines where your [Kibana][ELK] is installed. This one is only used by a rake task to setup default
66
+ * `cron_interval` defines the time in minutes between two measurements.
67
+ * `kibana_path` defines where your [Kibana][ELK] is installed. This one is only used by a rake task to setup default
69
68
  dashboards for your box. This is not really needed for the script to work.
70
-
71
- `server_port` defines the port to run a simple HTTP server to serve the Kibana UI.
72
-
73
- `elastic_servers` You can specify here, how to reach your ElasticSearch cluster. If you did the default install of
69
+ * `server_port` defines the port to run a simple HTTP server to serve the Kibana UI.
70
+ * `elastic_servers` You can specify here, how to reach your ElasticSearch cluster. If you did the default install of
74
71
  ElasticSearch on the same machine as the gem is installed, then it should already be the correct host:port.
75
-
76
- `elastic_binary` defines where your [ElasticSearch][ELK] is installed. This one is only used by a rake task
72
+ * `elastic_binary` defines where your [ElasticSearch][ELK] is installed. This one is only used by a rake task
77
73
  (to stop/start and get info) about the ElasticSearch cluster. This is not really needed for the log process to work.
74
+ Only to enable stop/start of the server.
78
75
  When you change it in your config, you do not need to set it in the `default_elastic_search` hash, but instead you can
79
76
  directly set it at the root.
80
77
 
@@ -217,9 +214,30 @@ Then provided you started the embedded server you just need to navigate to:
217
214
  Basically, to contribute you may want to:
218
215
 
219
216
  * create the module to gather information from your box.
220
- * build the Kibana report to display information.
221
217
  * Update the tests accordingly
218
+ * build the Kibana report to display information.
219
+
220
+ ### Code
221
+
222
+ The contract is pretty simple. Create a module to gather your box's data into the InternetBoxLogger::Parsers namespace
223
+ (module). This module should implement two methods:
224
+
225
+ * `get_box_data` that returns a hash of key-value pairs representing the data you monitor from your box. The way you
226
+ get these is not important. In the case of the Freebox V5 the sole possibility is to parse a page returned by the
227
+ box itself and than contains a lot of metrics. But maybe your box provides a more sophisticated API, REST or
228
+ whatever.
229
+ * `as_es_documents` should return an array of documents in the ElasticSearch way of thinking. This should the
230
+ transformation of the data returned by `get_box_data`, organised as an array of documents. This way you can organize
231
+ your data in a way that will allow you to query this data from Kibana to build your dashboards.
232
+
233
+ ### Tests
234
+
235
+ You should upgrade the test set to cover what you added.
236
+
237
+ ### Dashboard
222
238
 
239
+ You should add a new report into `config/kibana_reports`. The filename should end by "`_report.json`" to be taken in
240
+ account by the script and rake tasks.
223
241
 
224
242
  That's all folks.
225
243
 
@@ -121,6 +121,45 @@ module InternetBoxLogger
121
121
  self.send FIELD_POST_PROCESSING[field_name], field_name, match_data[field_name]
122
122
  end
123
123
 
124
+ def as_es_documents(created_at=Time.now)
125
+ res = []
126
+ self.up_down_reports.each_pair do |measurement, name|
127
+ %w(up down).each do |measurement_type|
128
+ data_name = "#{measurement}_#{measurement_type}"
129
+ es_object = {
130
+ index: "#{self.class.name.underscore.tr('/', '_')}_#{measurement}",
131
+ type: measurement_type
132
+ }
133
+ data = {
134
+ created_at: created_at,
135
+ name: data_name,
136
+ description: name,
137
+ value: attributes[data_name.to_sym]
138
+ }
139
+ es_object[:body] = data
140
+ res << es_object
141
+ end
142
+ end
143
+ generic_info = {}
144
+
145
+ attributes.each do |attr_name, content|
146
+ # Tries to remove data that are up/down measurements already covered by previous collection
147
+ data_key = attr_name.to_s.gsub(/_(up|down)$/, '').to_sym
148
+ next if attr_name.length > 3 && self.up_down_reports.keys.include?(data_key)
149
+ # Else adds info to generic info
150
+ generic_info[attr_name] = content
151
+ end
152
+ generic_info[:name] = 'generic'
153
+ generic_info[:created_at] = created_at
154
+
155
+ res << {
156
+ index: "#{self.class.name.underscore.tr('/', '_')}_generic",
157
+ type: :info.to_s,
158
+ body: generic_info
159
+ }
160
+
161
+ res
162
+ end
124
163
 
125
164
  end
126
165
  end
@@ -69,47 +69,6 @@ module InternetBoxLogger
69
69
  nil
70
70
  end
71
71
 
72
- def as_es_documents(created_at=Time.now)
73
- res = []
74
- self.up_down_reports.each_pair do |measurement, name|
75
- %w(up down).each do |measurement_type|
76
- data_name = "#{measurement}_#{measurement_type}"
77
- es_object = {
78
- index: "#{self.class.name.underscore.tr('/', '_')}_#{measurement}",
79
- type: measurement_type
80
- }
81
- data = {
82
- created_at: created_at,
83
- name: data_name,
84
- description: name,
85
- value: attributes[data_name.to_sym]
86
- }
87
- es_object[:body] = data
88
- res << es_object
89
- end
90
- end
91
- generic_info = {}
92
-
93
- attributes.each do |attr_name, content|
94
- # Tries to remove data that are up/down measurements already covered by previous collection
95
- data_key = attr_name.to_s.gsub(/_(up|down)$/, '').to_sym
96
- next if attr_name.length > 3 && self.up_down_reports.keys.include?(data_key)
97
- # Else adds info to generic info
98
- generic_info[attr_name] = content
99
- end
100
- generic_info[:name] = 'generic'
101
- generic_info[:created_at] = created_at
102
-
103
- res << {
104
- index: "#{self.class.name.underscore.tr('/', '_')}_generic",
105
- type: :info.to_s,
106
- body: generic_info
107
- }
108
-
109
- res
110
- end
111
-
112
-
113
72
 
114
73
  end
115
74
  end
@@ -1,3 +1,3 @@
1
1
  module InternetBoxLogger
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/spec/parsers_spec.rb CHANGED
@@ -46,7 +46,7 @@ describe InternetBoxLogger::Parsers do
46
46
  up += 1
47
47
  when 'down'
48
48
  down += 1
49
- when :info
49
+ when 'info'
50
50
  info += 1
51
51
  else
52
52
  unknown += 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: internet_box_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent B