bind_log_analyzer 0.1.1 → 0.2.0

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.
Files changed (35) hide show
  1. data/README.md +12 -9
  2. data/bin/bind_log_analyzer +30 -6
  3. data/bind_log_analyzer.gemspec +3 -0
  4. data/doc/BindLogAnalyzer.html +4 -4
  5. data/doc/BindLogAnalyzer/Base.html +65 -193
  6. data/doc/BindLogAnalyzer/Connector.html +380 -55
  7. data/doc/BindLogAnalyzer/DatabaseConfsNotValid.html +1 -1
  8. data/doc/BindLogAnalyzer/WebServer.html +127 -0
  9. data/doc/Log.html +142 -1
  10. data/doc/_index.html +16 -1
  11. data/doc/class_list.html +1 -1
  12. data/doc/file.README.html +1 -1
  13. data/doc/index.html +1 -1
  14. data/doc/method_list.html +35 -3
  15. data/doc/top-level-namespace.html +1 -1
  16. data/lib/bind_log_analyzer.rb +1 -0
  17. data/lib/bind_log_analyzer/base.rb +3 -27
  18. data/lib/bind_log_analyzer/connector.rb +58 -16
  19. data/lib/bind_log_analyzer/version.rb +1 -1
  20. data/lib/bind_log_analyzer/web_server.rb +45 -0
  21. data/lib/models/log.rb +10 -0
  22. data/resources/assets/images/glyphicons-halflings-white.png +0 -0
  23. data/resources/assets/images/glyphicons-halflings.png +0 -0
  24. data/resources/assets/javascripts/backbone-min.js +38 -0
  25. data/resources/assets/javascripts/bootstrap.min.js +6 -0
  26. data/resources/assets/stylesheets/bootstrap-responsive.min.css +12 -0
  27. data/resources/assets/stylesheets/bootstrap.min.css +689 -0
  28. data/resources/assets/stylesheets/main.css +4 -0
  29. data/resources/views/index.haml +16 -0
  30. data/resources/views/last_queries.haml +16 -0
  31. data/resources/views/layout.haml +14 -0
  32. data/resources/views/navbar.haml +12 -0
  33. data/resources/views/top_clients.haml +10 -0
  34. data/resources/views/top_queries.haml +10 -0
  35. metadata +56 -8
@@ -118,7 +118,7 @@
118
118
  </div>
119
119
 
120
120
  <div id="footer">
121
- Generated on Tue Apr 3 17:01:10 2012 by
121
+ Generated on Thu Apr 5 16:11:31 2012 by
122
122
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
123
  0.7.5 (ruby-1.9.3).
124
124
  </div>
@@ -0,0 +1,127 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: BindLogAnalyzer::WebServer
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../_index.html">Index (W)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../BindLogAnalyzer.html" title="BindLogAnalyzer (module)">BindLogAnalyzer</a></span></span>
38
+ &raquo;
39
+ <span class="title">WebServer</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Class: BindLogAnalyzer::WebServer
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName">Sinatra::Application</span>
70
+
71
+ <ul class="fullTree">
72
+ <li>Object</li>
73
+
74
+ <li class="next">Sinatra::Application</li>
75
+
76
+ <li class="next">BindLogAnalyzer::WebServer</li>
77
+
78
+ </ul>
79
+ <a href="#" class="inheritanceTree">show all</a>
80
+
81
+ </dd>
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ <dt class="r2 last">Defined in:</dt>
92
+ <dd class="r2 last">lib/bind_log_analyzer/web_server.rb</dd>
93
+
94
+ </dl>
95
+ <div class="clear"></div>
96
+
97
+ <h2>Overview</h2><div class="docstring">
98
+ <div class="discussion">
99
+
100
+ <p>The webserver</p>
101
+
102
+
103
+ </div>
104
+ </div>
105
+ <div class="tags">
106
+
107
+
108
+ </div>
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ </div>
119
+
120
+ <div id="footer">
121
+ Generated on Thu Apr 5 16:11:31 2012 by
122
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
+ 0.7.5 (ruby-1.9.3).
124
+ </div>
125
+
126
+ </body>
127
+ </html>
@@ -112,13 +112,154 @@
112
112
 
113
113
 
114
114
 
115
+
116
+ <h2>
117
+ Class Method Summary
118
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
119
+ </h2>
120
+
121
+ <ul class="summary">
122
+
123
+ <li class="public ">
124
+ <span class="summary_signature">
125
+
126
+ <a href="#top_clients-class_method" title="top_clients (class method)">+ (Object) <strong>top_clients</strong> </a>
127
+
128
+
129
+
130
+ </span>
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+ <span class="summary_desc"><div class='inline'>
140
+ <p>Shows 50 top clients.</p>
141
+ </div></span>
142
+
143
+ </li>
144
+
145
+
146
+ <li class="public ">
147
+ <span class="summary_signature">
148
+
149
+ <a href="#top_queries-class_method" title="top_queries (class method)">+ (Object) <strong>top_queries</strong> </a>
150
+
151
+
152
+
153
+ </span>
154
+
155
+
156
+
157
+
158
+
159
+
115
160
 
116
161
 
162
+ <span class="summary_desc"><div class='inline'>
163
+ <p>Shows 50 top queries.</p>
164
+ </div></span>
165
+
166
+ </li>
167
+
168
+
169
+ </ul>
170
+
171
+
172
+
173
+
174
+
175
+ <div id="class_method_details" class="method_details_list">
176
+ <h2>Class Method Details</h2>
177
+
178
+
179
+ <div class="method_details first">
180
+ <p class="signature first" id="top_clients-class_method">
181
+
182
+ + (<tt>Object</tt>) <strong>top_clients</strong>
183
+
184
+
185
+
186
+ </p><div class="docstring">
187
+ <div class="discussion">
188
+
189
+ <p>Shows 50 top clients</p>
190
+
191
+
192
+ </div>
193
+ </div>
194
+ <div class="tags">
195
+
196
+
197
+ </div><table class="source_code">
198
+ <tr>
199
+ <td>
200
+ <pre class="lines">
201
+
202
+
203
+ 10
204
+ 11
205
+ 12</pre>
206
+ </td>
207
+ <td>
208
+ <pre class="code"><span class="info file"># File 'lib/models/log.rb', line 10</span>
209
+
210
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_top_clients'>top_clients</span>
211
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>client, count(*) as hits</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_group'>group</span><span class='lparen'>(</span><span class='symbol'>:client</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>hits DESC</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_limit'>limit</span><span class='lparen'>(</span><span class='int'>50</span><span class='rparen'>)</span>
212
+ <span class='kw'>end</span></pre>
213
+ </td>
214
+ </tr>
215
+ </table>
216
+ </div>
217
+
218
+ <div class="method_details ">
219
+ <p class="signature " id="top_queries-class_method">
220
+
221
+ + (<tt>Object</tt>) <strong>top_queries</strong>
222
+
223
+
224
+
225
+ </p><div class="docstring">
226
+ <div class="discussion">
227
+
228
+ <p>Shows 50 top queries</p>
229
+
230
+
231
+ </div>
232
+ </div>
233
+ <div class="tags">
234
+
235
+
236
+ </div><table class="source_code">
237
+ <tr>
238
+ <td>
239
+ <pre class="lines">
240
+
241
+
242
+ 5
243
+ 6
244
+ 7</pre>
245
+ </td>
246
+ <td>
247
+ <pre class="code"><span class="info file"># File 'lib/models/log.rb', line 5</span>
248
+
249
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_top_queries'>top_queries</span>
250
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>query, count(*) as hits</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_group'>group</span><span class='lparen'>(</span><span class='symbol'>:query</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>hits DESC</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_limit'>limit</span><span class='lparen'>(</span><span class='int'>50</span><span class='rparen'>)</span>
251
+ <span class='kw'>end</span></pre>
252
+ </td>
253
+ </tr>
254
+ </table>
255
+ </div>
256
+
257
+ </div>
117
258
 
118
259
  </div>
119
260
 
120
261
  <div id="footer">
121
- Generated on Tue Apr 3 17:01:09 2012 by
262
+ Generated on Thu Apr 5 16:11:31 2012 by
122
263
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
264
  0.7.5 (ruby-1.9.3).
124
265
  </div>
@@ -138,6 +138,21 @@
138
138
  </ul>
139
139
  </ul>
140
140
 
141
+
142
+ <ul id="alpha_W" class="alpha">
143
+ <li class="letter">W</li>
144
+ <ul>
145
+
146
+ <li>
147
+ <span class='object_link'><a href="BindLogAnalyzer/WebServer.html" title="BindLogAnalyzer::WebServer (class)">WebServer</a></span>
148
+
149
+ <small>(BindLogAnalyzer)</small>
150
+
151
+ </li>
152
+
153
+ </ul>
154
+ </ul>
155
+
141
156
  </td>
142
157
  </tr>
143
158
  </table>
@@ -147,7 +162,7 @@
147
162
  </div>
148
163
 
149
164
  <div id="footer">
150
- Generated on Tue Apr 3 17:01:09 2012 by
165
+ Generated on Thu Apr 5 16:11:31 2012 by
151
166
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
152
167
  0.7.5 (ruby-1.9.3).
153
168
  </div>
@@ -39,7 +39,7 @@
39
39
 
40
40
  <ul id="full_list" class="class">
41
41
  <li><span class='object_link'><a href="top-level-namespace.html" title=" (root)">Top Level Namespace</a></span></li>
42
- <li><a class='toggle'></a> <span class='object_link'><a href="BindLogAnalyzer.html" title="BindLogAnalyzer (module)">BindLogAnalyzer</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><span class='object_link'><a href="BindLogAnalyzer/Base.html" title="BindLogAnalyzer::Base (class)">Base</a></span> &lt; Object<small class='search_info'>BindLogAnalyzer</small></li><li><span class='object_link'><a href="BindLogAnalyzer/Connector.html" title="BindLogAnalyzer::Connector (module)">Connector</a></span><small class='search_info'>BindLogAnalyzer</small></li><li><span class='object_link'><a href="BindLogAnalyzer/DatabaseConfsNotValid.html" title="BindLogAnalyzer::DatabaseConfsNotValid (class)">DatabaseConfsNotValid</a></span> &lt; Exception<small class='search_info'>BindLogAnalyzer</small></li></ul><li><span class='object_link'><a href="Log.html" title="Log (class)">Log</a></span> &lt; Base<small class='search_info'>Top Level Namespace</small></li>
42
+ <li><a class='toggle'></a> <span class='object_link'><a href="BindLogAnalyzer.html" title="BindLogAnalyzer (module)">BindLogAnalyzer</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><span class='object_link'><a href="BindLogAnalyzer/Base.html" title="BindLogAnalyzer::Base (class)">Base</a></span> &lt; Object<small class='search_info'>BindLogAnalyzer</small></li><li><span class='object_link'><a href="BindLogAnalyzer/Connector.html" title="BindLogAnalyzer::Connector (module)">Connector</a></span><small class='search_info'>BindLogAnalyzer</small></li><li><span class='object_link'><a href="BindLogAnalyzer/DatabaseConfsNotValid.html" title="BindLogAnalyzer::DatabaseConfsNotValid (class)">DatabaseConfsNotValid</a></span> &lt; Exception<small class='search_info'>BindLogAnalyzer</small></li><li><span class='object_link'><a href="BindLogAnalyzer/WebServer.html" title="BindLogAnalyzer::WebServer (class)">WebServer</a></span> &lt; Application<small class='search_info'>BindLogAnalyzer</small></li></ul><li><span class='object_link'><a href="Log.html" title="Log (class)">Log</a></span> &lt; Base<small class='search_info'>Top Level Namespace</small></li>
43
43
 
44
44
  </ul>
45
45
  </div>
@@ -206,7 +206,7 @@ bind_log_analyzer -f query.log -c database.yml 322,44s user 22,90s system 76% c
206
206
  </div></div>
207
207
 
208
208
  <div id="footer">
209
- Generated on Tue Apr 3 17:01:09 2012 by
209
+ Generated on Thu Apr 5 16:11:31 2012 by
210
210
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
211
211
  0.7.5 (ruby-1.9.3).
212
212
  </div>
@@ -206,7 +206,7 @@ bind_log_analyzer -f query.log -c database.yml 322,44s user 22,90s system 76% c
206
206
  </div></div>
207
207
 
208
208
  <div id="footer">
209
- Generated on Tue Apr 3 17:01:09 2012 by
209
+ Generated on Thu Apr 5 16:11:31 2012 by
210
210
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
211
211
  0.7.5 (ruby-1.9.3).
212
212
  </div>
@@ -49,7 +49,7 @@
49
49
 
50
50
 
51
51
  <li class="r2 ">
52
- <span class='object_link'><a href="BindLogAnalyzer/Connector.html#connect-instance_method" title="BindLogAnalyzer::Connector#connect (method)">#connect</a></span>
52
+ <span class='object_link'><a href="BindLogAnalyzer/Connector.html#connect-class_method" title="BindLogAnalyzer::Connector.connect (method)">connect</a></span>
53
53
 
54
54
  <small>BindLogAnalyzer::Connector</small>
55
55
 
@@ -65,9 +65,9 @@
65
65
 
66
66
 
67
67
  <li class="r2 ">
68
- <span class='object_link'><a href="BindLogAnalyzer/Base.html#database_confs-instance_method" title="BindLogAnalyzer::Base#database_confs (method)">#database_confs</a></span>
68
+ <span class='object_link'><a href="BindLogAnalyzer/Connector.html#establish_connection-class_method" title="BindLogAnalyzer::Connector.establish_connection (method)">establish_connection</a></span>
69
69
 
70
- <small>BindLogAnalyzer::Base</small>
70
+ <small>BindLogAnalyzer::Connector</small>
71
71
 
72
72
  </li>
73
73
 
@@ -129,6 +129,14 @@
129
129
 
130
130
 
131
131
  <li class="r2 ">
132
+ <span class='object_link'><a href="BindLogAnalyzer/Connector.html#set_log_level-class_method" title="BindLogAnalyzer::Connector.set_log_level (method)">set_log_level</a></span>
133
+
134
+ <small>BindLogAnalyzer::Connector</small>
135
+
136
+ </li>
137
+
138
+
139
+ <li class="r1 ">
132
140
  <span class='object_link'><a href="BindLogAnalyzer/Connector.html#setup_db-instance_method" title="BindLogAnalyzer::Connector#setup_db (method)">#setup_db</a></span>
133
141
 
134
142
  <small>BindLogAnalyzer::Connector</small>
@@ -136,6 +144,14 @@
136
144
  </li>
137
145
 
138
146
 
147
+ <li class="r2 ">
148
+ <span class='object_link'><a href="BindLogAnalyzer/Connector.html#setup_db_confs-class_method" title="BindLogAnalyzer::Connector.setup_db_confs (method)">setup_db_confs</a></span>
149
+
150
+ <small>BindLogAnalyzer::Connector</small>
151
+
152
+ </li>
153
+
154
+
139
155
  <li class="r1 ">
140
156
  <span class='object_link'><a href="BindLogAnalyzer/Base.html#store_query-instance_method" title="BindLogAnalyzer::Base#store_query (method)">#store_query</a></span>
141
157
 
@@ -144,6 +160,22 @@
144
160
  </li>
145
161
 
146
162
 
163
+ <li class="r2 ">
164
+ <span class='object_link'><a href="Log.html#top_clients-class_method" title="Log.top_clients (method)">top_clients</a></span>
165
+
166
+ <small>Log</small>
167
+
168
+ </li>
169
+
170
+
171
+ <li class="r1 ">
172
+ <span class='object_link'><a href="Log.html#top_queries-class_method" title="Log.top_queries (method)">top_queries</a></span>
173
+
174
+ <small>Log</small>
175
+
176
+ </li>
177
+
178
+
147
179
  </ul>
148
180
  </div>
149
181
  </body>
@@ -98,7 +98,7 @@
98
98
  </div>
99
99
 
100
100
  <div id="footer">
101
- Generated on Tue Apr 3 17:01:10 2012 by
101
+ Generated on Thu Apr 5 16:11:31 2012 by
102
102
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
103
103
  0.7.5 (ruby-1.9.3).
104
104
  </div>
@@ -1,5 +1,6 @@
1
1
  require "bind_log_analyzer/version"
2
2
  require "bind_log_analyzer/base"
3
+ require "bind_log_analyzer/web_server"
3
4
 
4
5
  # BindLogAnalyzer analyzes a Bind query log file, parses the logs and store them in
5
6
  # a database. The database choise is "limited" to the databases supported by ActiveRecord.
@@ -10,40 +10,16 @@ module BindLogAnalyzer
10
10
  # @attribute [r]
11
11
  # @return [String] The file containing the logs to be analyzed
12
12
  attr_reader :log_filename
13
- # @attribute [r]
14
- # @return [Hash] The hash containing the database params and credentials
15
- attr_reader :database_confs
16
13
 
17
14
  # The constructor of BindLogAnalyzer::Base sets some vars and manages the setup of the database
18
- # @param [Hash, String] database_confs The path to the database configurations file or a hash containing such informations
15
+ # @param [Hash, String] database_params The path to the database configurations file or a hash containing such informations
19
16
  # @param [String] logfile The path to the file containing the Bind's logs to analyze
20
17
  # @param [true, false] setup_database A flag which indicates whether to launch the database migration
21
18
  # @param [Integer] log_level The level of the log requested by the user
22
- def initialize(database_confs = nil, logfile = nil, setup_database = false, log_level = 0)
23
- if database_confs
24
- if database_confs.instance_of?(Hash)
25
- @database_confs = database_confs
26
- else
27
- # Load the yaml file
28
- if FileTest.exists?(database_confs)
29
- @database_confs = YAML::load(File.open(database_confs))['database']
30
- else
31
- raise BindLogAnalyzer::DatabaseConfsNotValid, "The indicated YAML file doesn't exist or is invalid"
32
- end
33
- end
34
- else
35
- # Tries to find the yaml file or prints an error
36
- filename = File.join(File.dirname(__FILE__), 'database.yml')
37
- if FileTest.exists?(filename)
38
- @database_confs = YAML::load(File.open(filename))['database']
39
- else
40
- raise BindLogAnalyzer::DatabaseConfsNotValid, "Can't find valid database configurations"
41
- end
42
- end
43
-
19
+ def initialize(database_params = nil, logfile = nil, setup_database = false, log_level = 0)
44
20
  @stored_queries = 0
45
21
  self.logfile = logfile if logfile
46
- setup_db(@database_confs, setup_database, log_level)
22
+ setup_db(database_params, setup_database, log_level)
47
23
  end
48
24
 
49
25
  # Sets the path to the log file checking if exists