log_sense 1.0.6 → 1.0.7

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.
@@ -1,328 +1,245 @@
1
- <html>
1
+ <!doctype html>
2
+ <html class="no-js" lang="en">
2
3
  <head>
3
- <title>Apache Log Analysis: <%= data[:log_file] || "stdin" %></title>
4
- <meta name="author" content="apache_log_report">
4
+ <title>Log Sense: <%= data[:log_file] %></title>
5
+
6
+ <meta charset="utf-8" />
7
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
9
+ <meta name="author" content="Log Sense">
10
+ <meta name="description" content="Analysis of <%= data[:log_file] %>">
11
+
12
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.min.css">
13
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/css/foundation.min.css">
14
+ <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/zf/dt-1.11.3/datatables.min.css"/>
15
+
16
+ <style>
17
+ #offCanvas {
18
+ color: white;
19
+ background: #333333;
20
+ border-right: ;
21
+ box-shadow: none;
22
+ padding: 0.5rem;
23
+ }
24
+ #offCanvas a {
25
+ color: orange;
26
+ }
27
+
28
+ .contents-button {
29
+ font-size: xx-large;
30
+ }
31
+
32
+ .main-section {
33
+ margin-left: 45px;
34
+ }
35
+
36
+ </style>
5
37
 
6
- <link rel="stylesheet" href="alr-styles.css"></style>
7
-
8
- <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
9
- <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-exp.min.css">
10
- <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-icons.min.css">
11
38
  </head>
12
39
 
13
40
  <body>
14
- <div class="container">
15
- <nav>
16
- <ul class="nav">
17
- <li class="nav-item active">
18
- <a href="#">Navigation</a>
19
- <ul class="nav">
20
- <% [ "Summary",
21
- "Log Structure",
22
- "Daily Distribution",
23
- "Time Distribution",
24
- "Most Requested Pages",
25
- "Most Requested Resources",
26
- "404 on HTML Files",
27
- "404 on other Resources",
28
- "Attacks",
29
- "Statuses",
30
- "Daily Statuses",
31
- "Browsers",
32
- "Platforms",
33
- "Referers",
34
- "IPs",
35
- "Geolocation",
36
- "Streaks",
37
- "Command Invocation",
38
- "Performance"
39
- ].each do |item| %>
40
- <li class="nav-item">
41
- <a href="#<%= item.downcase.gsub(' ', '-') %>"><%= item %></a>
42
- </li>
43
- <% end %>
44
- </ul>
45
- </li>
46
- </ul>
47
- <p>
48
- Generated by<br />
49
- <a href="https://github.com/avillafiorita/log_sense">LogSense</a> <br />
50
- on <%= DateTime.now.strftime("%Y-%m-%d %H:%M") %>.<br />
51
- <a href='https://db-ip.com'>IP Geolocation by DB-IP</a>
52
- </p>
53
- </nav>
41
+ <div class="off-canvas-wrapper">
42
+ <div class="off-canvas position-left" id="offCanvas" data-off-canvas>
43
+ <nav>
44
+ <h2>Navigation</h2>
45
+ <ul class="no-bullet">
46
+ <% [ "Summary",
47
+ "Log Structure",
48
+ "Daily Distribution",
49
+ "Time Distribution",
50
+ "Most Requested Pages",
51
+ "Most Requested Resources",
52
+ "404 on HTML Files",
53
+ "404 on other Resources",
54
+ "Attacks",
55
+ "Statuses",
56
+ "Daily Statuses",
57
+ "Browsers",
58
+ "Platforms",
59
+ "Referers",
60
+ "IPs",
61
+ "Geolocation",
62
+ "Streaks",
63
+ "Command Invocation",
64
+ "Performance"
65
+ ].each do |item| %>
66
+ <li class="nav-item">
67
+ <a href="#<%= item.downcase.gsub(' ', '-') %>" data-close><%= item %></a>
68
+ </li>
69
+ <% end %>
70
+ </ul>
71
+
72
+ <p>
73
+ Generated by
74
+ <a href="https://github.com/avillafiorita/log_sense">LogSense</a> <br />
75
+ on <%= DateTime.now.strftime("%Y-%m-%d %H:%M") %>.<br />
76
+ <a href='https://db-ip.com'>IP Geolocation by DB-IP</a>
77
+ </p>
78
+ </nav>
79
+ </div>
80
+ <div class="off-canvas-content grid-container grid-x fluid" data-off-canvas-content>
81
+ <div data-sticky-container>
82
+ <div class="sticky" data-sticky data-margin-top="0">
83
+ <div class="contents-button">
84
+ <i id="hamburger" class="fi-list" data-toggle="offCanvas"></i>
85
+ </div>
86
+ </div>
87
+ </div>
54
88
 
55
- <section>
56
- <h1>Apache Log Analysis: <%= data[:log_file] || "stdin" %></h1>
89
+ <section class="main-section">
90
+ <h1>Apache Log Analysis: <%= data[:log_file] || "stdin" %></h1>
57
91
 
58
- <div class="columns">
59
- <article class="col-6 column">
60
- <h2 id="summary">Summary</h2>
92
+ <div class="grid-x grid-margin-x">
93
+ <article class="small-12 large-6 cell">
94
+ <h2 id="summary">Summary</h2>
95
+ <%= render "summary.html.erb", data: data %>
96
+ </article>
61
97
 
62
- <table class="table summary">
63
- <tr>
64
- <th>Input file</th>
65
- <td><b><%= (data[:log_file] || "stdin") %></b></td>
66
- </tr>
67
- <tr>
68
- <th class="period">Period Analyzed</th>
69
- <td class="period">
70
- <%= data[:first_day_in_analysis] %>
71
- --
72
- <%= data[:last_day_in_analysis] %>
73
- </td>
74
- </tr>
75
- <tr>
76
- <th class="days">Days </th>
77
- <td class="days"><%= data[:total_days_in_analysis] %></td>
78
- </tr>
79
- <tr>
80
- <th class="hits">Hits</th>
81
- <td class="hits"><%= data[:total_hits][0][0] %></td>
82
- </tr>
83
- <tr>
84
- <th class="unique-visitors">Unique Visitors</th>
85
- <td class="unique-visitors"><%= data[:total_unique_visitors][0][0] %></td>
86
- </tr>
87
- <tr>
88
- <th class="tx">Tx</th>
89
- <td class="tx"><%= data[:total_size][0][0] %></td>
90
- </tr>
91
- </table>
92
- </article>
93
- <article class="column col-6">
94
- <h2 id="log-structure">Log Structure</h2>
98
+ <article class="cell small-12 large-6">
99
+ <h2 id="log-structure">Log Structure</h2>
100
+ <%= render "total_hits.html.erb", data: data %>
101
+ </article>
102
+ </div>
95
103
 
96
- <table class="table log-structure">
97
- <tbody>
98
- <tr>
99
- <th>Input file</th>
100
- <td><b><%= (data[:log_file] || "stdin") %></b></td>
101
- </tr>
102
- <tr>
103
- <th>Period in Log</th>
104
- <td><%= data[:first_day] %> -- <%= data[:last_day] %></td>
105
- </tr>
106
- <tr>
107
- <th>Total days</th>
108
- <td><%= data[:total_days] %></td>
109
- </tr>
110
- <tr>
111
- <th>Log size</th>
112
- <td><%= data[:log_size][0][0] %></td>
113
- </tr>
114
- <tr>
115
- <th>Self poll entries</th>
116
- <td><%= data[:selfpolls_size][0][0] %></td>
117
- </tr>
118
- <tr>
119
- <th>Crawlers</th>
120
- <td><%= data[:crawlers_size][0][0] %></td>
121
- </tr>
104
+ <% @reports = [
105
+ { title: "Daily Distribution", header: ["Day", "DOW", "Hits", "Visits", "Size"], rows: data[:daily_distribution] },
106
+ { title: "Time Distribution", header: ["Hour", "Hits", "Visits", "Size"], rows: data[:time_distribution] },
107
+ { title: "Most Requested Pages", header: ["Path", "Hits", "Visits", "Size"], rows: data[:most_requested_pages] },
108
+ { title: "Most Requested Resources", header: ["Path", "Hits", "Visits", "Size"], rows: data[:most_requested_resources] },
109
+ { title: "404 on HTML Files", header: ["Path", "Hits", "Visits"], rows: data[:missed_pages] },
110
+ { title: "404 on other Resources", header: ["Path", "Hits", "Visits"], rows: data[:missed_resources] },
111
+ { title: "Attacks", header: ["Path", "Hits", "Visits"], rows: data[:attacks] },
112
+ { title: "Statuses", header: ["Status", "Count"], rows: data[:statuses] },
113
+ { title: "Daily Statuses", header: ["Status", "2xx", "3xx", "4xx"], rows: data[:statuses_by_day] },
114
+ { title: "Browsers", header: ["Browser", "Hits", "Visits", "Size"], rows: data[:browsers] },
115
+ { title: "Platforms", header: ["Platform", "Hits", "Visits", "Size"], rows: data[:platforms] },
116
+ { title: "Referers", header: ["Referers", "Hits", "Visits", "Size"], rows: data[:referers], col: "col-12" },
117
+ { title: "IPs", header: ["IPs", "Hits", "Visits", "Size", "Country"], rows: data[:ips] },
118
+ ]
119
+ %>
120
+ <div class="grid-x grid-margin-x">
121
+ <% @reports.each do |report| %>
122
+ <article class="cell <%= report[:col] || "small-12 large-6" %>" >
123
+ <h2 id="<%= report[:title].downcase.gsub(/ +/, '-') %>">
124
+ <%= report[:title] %>
125
+ </h2>
126
+ <%= render "output_table.html.erb", report %>
127
+ </article>
128
+ <% end %>
129
+ </div>
130
+
131
+ <article>
132
+ <h2 id="geolocation">Geolocation</h2>
133
+ <table id="geolocation-table" class="table unstriped">
134
+ <thead>
122
135
  <tr>
123
- <th>Entries considered</th>
124
- <td><%= data[:total_hits][0][0] %></td>
125
- </tr>
136
+ <th>Country Code</th>
137
+ <th>Total Hits</th>
138
+ <th>Total Visits</th>
139
+ <th>IPs</th>
140
+ </tr>
141
+ </thead>
142
+ <tbody>
143
+ <%# IP, Hits, Visits Size, Country%>
144
+ <% data[:ips].group_by { |x| x[4] }.each do |k, v| %>
145
+ <tr>
146
+ <td><%= k %></td>
147
+ <td><%= v.map { |x| x[1] }.inject(&:+) %></td>
148
+ <td><%= v.map { |x| x[2] }.inject(&:+) %></td>
149
+ <td><%= v.map { |x| x[0] }.join(", ") %></td>
150
+ </tr>
151
+ <% end %>
126
152
  </tbody>
127
153
  </table>
128
154
  </article>
129
- </div>
130
-
131
- <% @reports = [
132
- { title: "Daily Distribution", header: ["Day", "DOW", "Hits", "Visits", "Size"], rows: data[:daily_distribution] },
133
- { title: "Time Distribution", header: ["Hour", "Hits", "Visits", "Size"], rows: data[:time_distribution] },
134
- { title: "Most Requested Pages", header: ["Path", "Hits", "Visits", "Size"], rows: data[:most_requested_pages] },
135
- { title: "Most Requested Resources", header: ["Path", "Hits", "Visits", "Size"], rows: data[:most_requested_resources] },
136
- { title: "404 on HTML Files", header: ["Path", "Hits", "Visitors"], rows: data[:missed_pages] },
137
- { title: "404 on other Resources", header: ["Path", "Hits", "Visitors"], rows: data[:missed_resources] },
138
- { title: "Attacks", header: ["Path", "Hits", "Visitors"], rows: data[:attacks] },
139
- { },
140
- { title: "Statuses", header: ["Status", "Count"], rows: data[:statuses] },
141
- { title: "Daily Statuses", header: ["Status", "2xx", "3xx", "4xx"], rows: data[:statuses_by_day] },
142
- { title: "Browsers", header: ["Browser", "Hits", "Visitors", "Size"], rows: data[:browsers] },
143
- { title: "Platforms", header: ["Platform", "Hits", "Visitors", "Size"], rows: data[:platforms] },
144
- { title: "Referers", header: ["Referers", "Hits", "Visitors", "Size"], rows: data[:referers], col: "col-12" },
145
- { title: "IPs", header: ["IPs", "Hits", "Visitors", "Size", "Country"], rows: data[:ips] },
146
- { },
147
- ]
148
- %>
149
- <div class="columns">
150
- <% @reports.each do |report| %>
151
- <div class="column <%= report[:col] || "col-6" %>">
152
- <article>
153
- <% if report[:title] != nil %>
154
- <h2 id="<%= report[:title].downcase.gsub(/ +/, '-') %>">
155
- <%= report[:title] %>
156
- </h2>
157
- <%= render "output_table", report %>
158
- <% end %>
159
- </article>
160
- </div>
161
- <% end %>
162
- </div>
163
-
164
- <article>
165
- <h2 id="geolocation">Geolocation</h2>
166
- <table class="table">
167
- <thead>
168
- <tr>
169
- <th>Country Code</th>
170
- <th>Total Hits</th>
171
- <th>Total Visitors</th>
172
- <th>IPs</th>
173
- </tr>
174
- </thead>
175
- <tbody>
176
- <%# IP, Hits, Visitors Size, Country%>
177
- <% data[:ips].group_by { |x| x[4] }.each do |k, v| %>
178
- <tr>
179
- <td><%= k %></td>
180
- <td><%= v.map { |x| x[1] }.inject(&:+) %></td>
181
- <td><%= v.map { |x| x[2] }.inject(&:+) %></td>
182
- <td><%= v.map { |x| x[0] }.join(", ") %></td>
183
- </tr>
184
- <% end %>
185
- </tbody>
186
- </table>
187
- </article>
188
155
 
189
- <article>
190
- <h2 id="streaks">Streaks</h2>
156
+ <article>
157
+ <h2 id="streaks">Streaks</h2>
191
158
 
192
- <table class="table streaks">
193
- <thead>
194
- <tr>
195
- <th>IP</th>
196
- <th>
197
- <div class="columns">
198
- <div class="col-2 column">
199
- Day
200
- </div>
201
- <div class="col-10 column">
202
- Resources
203
- </div>
204
- </div>
205
- </th>
206
- </tr>
207
- </thead>
208
- <tbody>
209
- <% data[:streaks].group_by(&:first).each do |ip, date_urls| %>
159
+ <table id="streaks-table" class="table data-table streaks">
160
+ <thead>
210
161
  <tr>
211
- <td class="ip"><%= ip %></td>
212
- <td class="streaks">
213
- <div class="columns">
214
- <% date_urls.group_by { |x| x[1] }.each do |date, urls| %>
215
- <div class="col-2 column">
216
- <%= date %>
162
+ <th>IP</th>
163
+ <th>
164
+ <div class="grid-x grid-margin-x">
165
+ <div class="col-2 cell">
166
+ Day
217
167
  </div>
218
- <div class="col-10 column">
219
- <span class="res-title">HTML:</span>
220
- <ul>
221
- <% urls.map { |x| x[2] }.compact.select { |x| x.match /.*\.html?/ }.each do |url| %>
222
- <li><%= url %></li>
223
- <% end %>
224
- </ul>
225
-
226
- <span class="res-title">Other Resources:</span>
227
- <ul>
228
- <% urls.map { |x| x[2] }.compact.sort.select { |x| x and not x.match /.*\.html?/ }.each do |url| %>
229
- <li><%= url %></li>
230
- <% end %>
231
- </ul>
168
+ <div class="col-10 cell">
169
+ Resources
232
170
  </div>
233
- <% end %>
234
171
  </div>
235
- </td>
172
+ </th>
236
173
  </tr>
237
- <% end %>
238
- </tbody>
239
- </table>
240
- </article>
241
-
242
- <div class="columns">
243
- <div class="column col-6">
244
- <article>
245
- <h2 id="command-invocation">Command Invocation</h2>
246
-
247
- <table class="table command-invocation">
248
- <tbody>
249
- <tr>
250
- <th>CLI Command</th>
251
- <td><code><%= data[:command] %></code></td>
252
- </tr>
253
- <tr>
254
- <th>Input file</th>
255
- <td><code><%= (data[:log_file] || "stdin") %></code></td>
256
- </tr>
257
- <tr>
258
- <th>Ignore crawlers</th>
259
- <td><code><%= options[:ignore_crawlers] %></code></td></tr>
260
- <tr>
261
- <th>Only crawlers</th>
262
- <td><code><%= options[:only_crawlers] %></code></td>
263
- </tr>
264
- <tr>
265
- <th>No selfpoll</th>
266
- <td><code><%= options[:no_selfpoll] %></code></td>
267
- </tr>
174
+ </thead>
175
+ <tbody>
176
+ <% data[:streaks].group_by(&:first).each do |ip, date_urls| %>
268
177
  <tr>
269
- <th>Filter by date</th>
270
- <td>
271
- <code><%= (options[:from_date] != nil or options[:to_date] != nil) %></code>
178
+ <td class="ip"><%= ip %></td>
179
+ <td class="streaks">
180
+ <div class="grid-x grid-margin-x">
181
+ <% date_urls.group_by { |x| x[1] }.each do |date, urls| %>
182
+ <div class="col-2 cell">
183
+ <%= date %>
184
+ </div>
185
+ <div class="col-10 cell">
186
+ <span class="res-title">HTML:</span>
187
+ <ul>
188
+ <% urls.map { |x| x[2] }.compact.select { |x| x.match /.*\.html?/ }.each do |url| %>
189
+ <li><%= url %></li>
190
+ <% end %>
191
+ </ul>
192
+
193
+ <span class="res-title">Other Resources:</span>
194
+ <ul>
195
+ <% urls.map { |x| x[2] }.compact.sort.select { |x| x and not x.match /.*\.html?/ }.each do |url| %>
196
+ <li><%= url %></li>
197
+ <% end %>
198
+ </ul>
199
+ </div>
200
+ <% end %>
201
+ </div>
272
202
  </td>
273
203
  </tr>
274
- <tr>
275
- <th>Prefix</th>
276
- <td><code><%= @prefix %></code></td>
277
- </tr>
278
- <tr>
279
- <th>Suffix</th>
280
- <td><code><%= @suffix %></code></td>
281
- </tr>
282
- </tbody>
283
- </table>
284
- </article>
285
- </div>
204
+ <% end %>
205
+ </tbody>
206
+ </table>
207
+ </article>
286
208
 
287
- <div class="column col-6">
288
- <article>
289
- <h2 id="performance"> Performance</h2>
209
+ <div class="grid-x grid-margin-x">
210
+ <div class="cell small-12 large-6">
211
+ <article>
212
+ <h2 id="command-invocation">Command Invocation</h2>
290
213
 
291
- <table class="table performance">
292
- <tbody>
293
- <tr>
294
- <th>Analysis started at</th>
295
- <td><%= data[:started_at].to_s %></td>
296
- </tr>
297
- <tr>
298
- <th>Analysis ended at</th>
299
- <td><%= data[:ended_at].to_s %></td>
300
- </tr>
301
- <tr>
302
- <th>Duration (sec)</th>
303
- <td><%= "%.1f" % data[:duration] %></td>
304
- </tr>
305
- <tr>
306
- <th>Duration (min)</th>
307
- <td><%= "%d" % (data[:duration] / 60 ) %></td>
308
- </tr>
309
- <tr>
310
- <th>Log size</th>
311
- <td><%= data[:log_size][0][0] %></td>
312
- </tr>
313
- <tr>
314
- <th>Lines/sec</th>
315
- <td><%= "%.2f" % (data[:log_size][0][0] / data[:duration]) %></td></tr>
316
- </tbody>
317
- </table>
318
- </article>
214
+ <%= render "command_invocation.html.erb", data: data, options: options %>
215
+ </article>
216
+ </div>
217
+
218
+ <div class="small-12 large-6 cell">
219
+ <article>
220
+ <h2 id="performance"> Performance</h2>
221
+
222
+ <%= render "performance.html.erb", data: data %>
223
+ </article>
224
+ </div>
319
225
  </div>
320
- </div>
321
- </section>
226
+ </section>
227
+ </div>
228
+
229
+ <script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
230
+ <script type="text/javascript" src="js/vendor/what-input.js"></script>
231
+ <script type="text/javascript" src="https://cdn.datatables.net/v/zf/dt-1.11.3/datatables.min.js"></script>
232
+ <script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
233
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/js/foundation.min.js" crossorigin="anonymous"></script>
234
+ <script>
235
+ $(document).foundation();
236
+
237
+ $(document).ready(function () {
238
+ $('.data-table').each(function () {
239
+ $(this).DataTable();
240
+ });
241
+ });
242
+ </script>
322
243
  </div>
323
244
  </body>
324
245
  </html>
325
-
326
-
327
-
328
-
@@ -1,9 +1,8 @@
1
- Rails Log Analysis
1
+ * Rails Log Analysis
2
2
 
3
- <%= data[:first_day] %>
4
- <%= data[:last_day] %>
5
- <%= data[:total_days] %>
6
- <%= data[:events] %>
3
+ <%= render "summary.txt.erb", data: data %>
4
+
5
+ ** Access by Day
7
6
 
8
7
  <%=
9
8
  table = Terminal::Table.new headings: ['Date', 'Day', 'Events'], rows: @data[:daily_distribution]
@@ -11,29 +10,45 @@ table.align_column(3, :right)
11
10
  table
12
11
  %>
13
12
 
13
+ ** Access by Time
14
+
14
15
  <%=
15
16
  table = Terminal::Table.new headings: ['Hour', 'Events'], rows: @data[:time_distribution]
16
17
  table.align_column(2, :right)
17
18
  table
18
19
  %>
19
20
 
21
+ ** Statuses
22
+
20
23
  <%=
21
24
  table = Terminal::Table.new headings: ['Status', 'Events'], rows: @data[:statuses]
22
25
  table.align_column(2, :right)
23
26
  table
24
27
  %>
25
28
 
29
+ ** IP and Country
30
+
26
31
  <%=
27
- table = Terminal::Table.new headings: ['IP', 'Events'], rows: @data[:ips]
28
- table.align_column(2, :right)
32
+ table = Terminal::Table.new headings: ['IP', 'Events', 'Country'], rows: @data[:ips]
33
+ table.align_column(1, :right)
29
34
  table
30
35
  %>
31
36
 
37
+ ** Rails Performance
38
+
32
39
  <%= table = Terminal::Table.new headings: ['Controller', 'Hits', 'Min', 'Avg', 'Max'], rows: @data[:performance]
40
+ table.align_column(1, :right)
33
41
  table.align_column(2, :right)
34
42
  table.align_column(3, :right)
35
43
  table.align_column(4, :right)
36
44
  table
37
45
  %>
38
46
 
47
+ ** Command Invocation
48
+
49
+ <%= render "command_invocation.txt.erb", data: data %>
50
+
51
+ ** Log Sense Performance
52
+
53
+ <%= render "performance.txt.erb", data: data %>
39
54
 
@@ -1,3 +1,3 @@
1
1
  module LogSense
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
File without changes