apache_log_report 0.9.2 → 0.9.3

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
  SHA256:
3
- metadata.gz: 2a554ad8352b97f32dd81c004d6b78f1e7d8e2ea284bb7dc7ef18eb3fee7687a
4
- data.tar.gz: 0d6e6243eabf89425e174a7ce76948cfd9517fbf3c226a2e77bb746bb43e8223
3
+ metadata.gz: ca301cb770ac157383315a770b619d746c5381568bfb2b091942a965a702496f
4
+ data.tar.gz: 7fa3da83dcc3a9baab9c98ac180adadb7dab256ca7800f882f8f33f1457c3071
5
5
  SHA512:
6
- metadata.gz: 75a8de1b3375eec45a4ffb41cfa37d834c89ec07e92155d31b2e872e5040fb22709f759bd5aa6bbfc5ed5c84852a9b26c6f603019cb2fb43d21a56a0d33f8eaf
7
- data.tar.gz: baa9f268e1e7dcdb72463bf4b4aac1d585524b3ba7db2da1408259f8d54f59424003094372b491791b2788f9f7b3de68a8d1cec8919cd1991ccb5c856677b94c
6
+ metadata.gz: be85ba24ecf36635f055465c5f131054d29032e47b9780031973274a1ebdf579ea30c816eac16f697f83c7a523bd3fe568e653167b8c1420018c160d37f789df
7
+ data.tar.gz: ba0aa6fbf8112bca663fa2b8df6563d87b02be35034a00c42c887a2b3a5556abdfd56a54560e79e65748c37b5319f23887fa167793dd7b30ce13d0b7fbb1a742
@@ -16,13 +16,12 @@ if @log_file and not File.exist? @log_file
16
16
  end
17
17
 
18
18
  #
19
- # Parse Log
19
+ # Parse Log and Track Statistics
20
20
  #
21
21
 
22
22
  @started_at = Time.now
23
23
  @db = ApacheLogReport.parse @log_file
24
24
  ApacheLogReport.analyze_data @db, @options
25
-
26
25
  @ended_at = Time.now
27
26
  @duration = @ended_at - @started_at
28
27
 
@@ -45,6 +45,10 @@ module ApacheLogReport
45
45
  args[:suffix] = n
46
46
  end
47
47
 
48
+ opts.on("-c", "--code-export=WHAT", String, "Control :export directive in code blocks (code, results, *both*, none)") do |n|
49
+ args[:code_export] = n
50
+ end
51
+
48
52
  opts.on("-h", "--help", "Prints this help") do
49
53
  puts opts
50
54
  exit
@@ -58,7 +62,8 @@ module ApacheLogReport
58
62
  args[:no_selfpoll] ||= false
59
63
  args[:only_crawlers] ||= false
60
64
  args[:prefix] ||= ""
61
- args[:suffic] ||= ""
65
+ args[:suffix] ||= ""
66
+ args[:code_export] ||= "both"
62
67
 
63
68
  return args
64
69
  end
@@ -125,7 +130,7 @@ module ApacheLogReport
125
130
  hash[:datetime].iso8601,
126
131
  hash[:remote_host],
127
132
  hash[:user],
128
- hash[:remote_host] + hash[:user_agent],
133
+ hash[:datetime].iso8601 + " " + hash[:remote_host] + " " + hash[:user_agent],
129
134
  hash[:request][:method],
130
135
  hash[:request][:path],
131
136
  (hash[:request][:path] ? File.extname(hash[:request][:path]) : ""),
@@ -188,8 +193,8 @@ module ApacheLogReport
188
193
  @missed_resources = db.execute "SELECT path, count(path), count(distinct(unique_visitor)) from LogLine where status == '404' and #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
189
194
 
190
195
  @reasonable_requests_exts = [ ".html", ".css", ".js", ".jpg", ".svg", ".png", ".woff", ".xml", ".ttf", ".ico", ".pdf", ".htm", ".txt", ".org" ].map { |x|
191
- "extension == '#{x}'"
192
- }.join " or "
196
+ "extension != '#{x}'"
197
+ }.join " and "
193
198
 
194
199
  @attacks = db.execute "SELECT path, count(path), count(distinct(unique_visitor)) from LogLine where status == '404' and #{@filter} and (#{@reasonable_requests_exts}) group by path order by count(path) desc limit #{options[:limit]}"
195
200
 
@@ -233,6 +238,7 @@ module ApacheLogReport
233
238
  def self.emit options = {}, command, log_file, started_at, ended_at, duration
234
239
  @prefx = options[:prefix]
235
240
  @suffix = options[:suffix]
241
+ @export = option[:code_export]
236
242
 
237
243
  <<EOS
238
244
  #+TITLE: Apache Log Analysis: #{log_file}
@@ -253,7 +259,7 @@ module ApacheLogReport
253
259
 
254
260
  #{ output_table "daily_distribution", ["Day", "Hits", "Visits", "Size"], @daily_distribution }
255
261
 
256
- #+BEGIN_SRC gnuplot :var data = daily_distribution :results output :exports both :file #{@prefix}daily#{@suffix}.svg
262
+ #+BEGIN_SRC gnuplot :var data = daily_distribution :results output :exports #{@export} :file #{@prefix}daily#{@suffix}.svg
257
263
  reset
258
264
  set grid ytics linestyle 0
259
265
  set grid xtics linestyle 0
@@ -267,7 +273,8 @@ set xtics rotate by 60 right
267
273
  set title "Hits and Visitors"
268
274
  set xlabel "Date"
269
275
  set ylabel "Hits"
270
- set ylabel2 "Visits"
276
+ set y2label "Visits"
277
+ set y2tics
271
278
 
272
279
  set style fill transparent solid 0.2 noborder
273
280
 
@@ -285,7 +292,7 @@ data using 1:($2+100):2 with labels notitle textcolor rgb "#0000AA" axes x1y2
285
292
  #{ output_table "time_distribution", ["Hour", "Hits", "Visits", "Size"], @time_distribution }
286
293
 
287
294
 
288
- #+BEGIN_SRC gnuplot :var data = time_distribution :results output :exports both :file #{@prefix}time#{@suffix}.svg
295
+ #+BEGIN_SRC gnuplot :var data = time_distribution :results output :exports #{@export} :file #{@prefix}time#{@suffix}.svg
289
296
  reset
290
297
  set terminal svg size 1200,800 fname 'Arial' fsize 10
291
298
 
@@ -293,7 +300,9 @@ set grid ytics linestyle 0
293
300
 
294
301
  set title "Hits and Visitors"
295
302
  set xlabel "Date"
296
- set ylabel "Hits and Visits"
303
+ set ylabel "Hits"
304
+ set y2label "Visitors"
305
+ set y2tics
297
306
 
298
307
  set style fill solid 0.25
299
308
  set boxwidth 0.6
@@ -307,7 +316,7 @@ data using ($0 - 0.2):($2 + 10):2 with labels title "" textcolor rgb("#0000AA"),
307
316
  data using ($0 + 0.2):($3 + 10):3 with labels title "" textcolor rgb("#AA0000") axes x1y2
308
317
  #+END_SRC
309
318
 
310
- #+BEGIN_SRC gnuplot :var data = time_distribution :results output :exports both :file #{@prefix}time-traffic#{@suffix}.svg
319
+ #+BEGIN_SRC gnuplot :var data = time_distribution :results output :exports #{@export} :file #{@prefix}time-traffic#{@suffix}.svg
311
320
  reset
312
321
  set terminal svg size 1200,800 fname 'Arial' fsize 10
313
322
 
@@ -345,13 +354,13 @@ data using ($0):($2 + 10):2 with labels title "" textcolor rgb("#00AA00")
345
354
 
346
355
  * Possible Attacks
347
356
 
348
- #{ output_table "Attacks", ["Path", "Hits", "Visitors"], @attacks }
357
+ #{ output_table "attacks", ["Path", "Hits", "Visitors"], @attacks }
349
358
 
350
359
  * Statuses
351
360
 
352
361
  #{ output_table "statuses", ["Status", "Count"], @statuses }
353
362
 
354
- #+BEGIN_SRC gnuplot :var data = statuses :results output :exports both :file #{@prefix}statuses#{@suffix}.svg
363
+ #+BEGIN_SRC gnuplot :var data = statuses :results output :exports #{@export} :file #{@prefix}statuses#{@suffix}.svg
355
364
  reset
356
365
  set grid ytics linestyle 0
357
366
  set terminal svg size 1200,800 fname 'Arial' fsize 10
@@ -367,7 +376,7 @@ data using ($0):($2+100):2 with labels textcolor rgb "#0000AA"
367
376
 
368
377
  #{ output_table "daily_statuses", ["Status", "2xx", "3xx", "4xx"], @statuses_by_day }
369
378
 
370
- #+BEGIN_SRC gnuplot :var data = daily_statuses :results output :exports both :file #{@prefix}daily-statuses#{@suffix}.svg
379
+ #+BEGIN_SRC gnuplot :var data = daily_statuses :results output :exports #{@export} :file #{@prefix}daily-statuses#{@suffix}.svg
371
380
  reset
372
381
  set terminal svg size 1200,800 fname 'Arial' fsize 10
373
382
 
@@ -396,7 +405,7 @@ data using ($0 + 1. / 4):($4 + 0.5):4 with labels title "" textcolor rgb("#00AA0
396
405
 
397
406
  #{ output_table "browsers", ["Browser", "Hits", "Visitors", "Size"], @browsers }
398
407
 
399
- #+BEGIN_SRC gnuplot :var data = browsers :results output :exports both :file #{@prefix}browser#{@suffix}.svg
408
+ #+BEGIN_SRC gnuplot :var data = browsers :results output :exports #{@export} :file #{@prefix}browser#{@suffix}.svg
400
409
  reset
401
410
  set grid ytics linestyle 0
402
411
  set terminal svg size 1200,800 fname 'Arial' fsize 10
@@ -412,7 +421,7 @@ data using ($0):($2+100):2 with labels textcolor rgb "#0000AA"
412
421
 
413
422
  #{ output_table "platforms", ["Platform", "Hits", "Visitors", "Size"], @platforms }
414
423
 
415
- #+BEGIN_SRC gnuplot :var data = platforms :results output :exports both :file #{@prefix}platforms#{@suffix}.svg
424
+ #+BEGIN_SRC gnuplot :var data = platforms :results output :exports #{@export} :file #{@prefix}platforms#{@suffix}.svg
416
425
  reset
417
426
  set grid ytics linestyle 0
418
427
  set terminal svg size 1200,800 fname 'Arial' fsize 10
@@ -433,7 +442,7 @@ data using ($0):($2+100):2 with labels textcolor rgb "#0000AA"
433
442
 
434
443
  #{ output_table "referers", ["Referers", "Hits", "Visitors", "Size"], @referers }
435
444
 
436
- #+BEGIN_SRC gnuplot :var data = referers :results output :exports both :file #{@prefix}referers#{@suffix}.svg
445
+ #+BEGIN_SRC gnuplot :var data = referers :results output :exports #{@export} :file #{@prefix}referers#{@suffix}.svg
437
446
  reset
438
447
  set terminal svg size 1200,800 fname 'Arial' fsize 10
439
448
 
@@ -1,3 +1,3 @@
1
1
  module ApacheLogReport
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apache_log_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adolfo Villafiorita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-28 00:00:00.000000000 Z
11
+ date: 2020-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apache_log-parser