apache_log_report 0.9.1 → 0.9.6
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.
- checksums.yaml +4 -4
- data/README.org +7 -0
- data/exe/apache_log_report +1 -2
- data/lib/apache_log_report.rb +36 -31
- data/lib/apache_log_report/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1355b18ac3bb8e190bcc4e7a7fa5e655c465ffd45a7797895bd2be4d78f54cff
|
4
|
+
data.tar.gz: caa3b8c7795633901db1b5e24ddddd90c49bc47a00dcc0d0e8f2d46bdc4cf162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a811150ba66b92f6763b9e4657207a964b8873579a6ee08f6d58e011b09690f888f85b4543230291793d0c5ef1623547c4a02aa888c44bda20399c95701d32fa
|
7
|
+
data.tar.gz: b7559878a74638baff3c4281faae927e024f5c6e702f8128c986f3a659f81c8162b4e2ee934c47d3cd007874da0188f083c5b3739cad058a117985baecc403c0
|
data/README.org
CHANGED
@@ -12,6 +12,13 @@
|
|
12
12
|
|
13
13
|
See the [[file:CHANGELOG.org][CHANGELOG]] file.
|
14
14
|
|
15
|
+
* Todo
|
16
|
+
|
17
|
+
** TODO Version information from command line and in reports
|
18
|
+
** TODO Refactor code from one giant class to more manageable chunkes
|
19
|
+
** TODO Move performance stats var to class (to isolate vars)
|
20
|
+
** TODO Check total number of days (which is not working, now)
|
21
|
+
|
15
22
|
* Compatibility
|
16
23
|
|
17
24
|
|
data/exe/apache_log_report
CHANGED
@@ -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
|
|
data/lib/apache_log_report.rb
CHANGED
@@ -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[:
|
65
|
+
args[:suffix] ||= ""
|
66
|
+
args[:code_export] ||= "both"
|
62
67
|
|
63
68
|
return args
|
64
69
|
end
|
@@ -116,17 +121,16 @@ module ApacheLogReport
|
|
116
121
|
|
117
122
|
parser = ApacheLog::Parser.new(options[:format] || 'combined')
|
118
123
|
|
119
|
-
content.
|
120
|
-
|
124
|
+
content.each do |line|
|
125
|
+
begin
|
126
|
+
hash = parser.parse line
|
121
127
|
|
122
|
-
if hash != {}
|
123
128
|
ua = Browser.new(hash[:user_agent], accept_language: "en-us")
|
124
|
-
|
125
129
|
ins.execute(
|
126
130
|
hash[:datetime].iso8601,
|
127
131
|
hash[:remote_host],
|
128
132
|
hash[:user],
|
129
|
-
hash[:remote_host] + hash[:user_agent],
|
133
|
+
hash[:datetime].iso8601 + " " + hash[:remote_host] + " " + hash[:user_agent],
|
130
134
|
hash[:request][:method],
|
131
135
|
hash[:request][:path],
|
132
136
|
(hash[:request][:path] ? File.extname(hash[:request][:path]) : ""),
|
@@ -140,17 +144,14 @@ module ApacheLogReport
|
|
140
144
|
(ua.platform.name || ""),
|
141
145
|
(ua.platform.version || "")
|
142
146
|
)
|
147
|
+
rescue
|
148
|
+
STDERR.puts "Apache Log parser error: could not parse #{line}"
|
143
149
|
end
|
144
|
-
|
145
|
-
|
150
|
+
end
|
151
|
+
|
146
152
|
db
|
147
153
|
end
|
148
154
|
|
149
|
-
|
150
|
-
def self.reasonable_response_type ext
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
155
|
#
|
155
156
|
# take a sqlite3 databae and analyze data
|
156
157
|
#
|
@@ -192,8 +193,8 @@ end
|
|
192
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]}"
|
193
194
|
|
194
195
|
@reasonable_requests_exts = [ ".html", ".css", ".js", ".jpg", ".svg", ".png", ".woff", ".xml", ".ttf", ".ico", ".pdf", ".htm", ".txt", ".org" ].map { |x|
|
195
|
-
"extension
|
196
|
-
}.join "
|
196
|
+
"extension != '#{x}'"
|
197
|
+
}.join " and "
|
197
198
|
|
198
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]}"
|
199
200
|
|
@@ -235,8 +236,9 @@ end
|
|
235
236
|
end
|
236
237
|
|
237
238
|
def self.emit options = {}, command, log_file, started_at, ended_at, duration
|
238
|
-
@
|
239
|
+
@prefix = options[:prefix]
|
239
240
|
@suffix = options[:suffix]
|
241
|
+
@export = options[:code_export]
|
240
242
|
|
241
243
|
<<EOS
|
242
244
|
#+TITLE: Apache Log Analysis: #{log_file}
|
@@ -257,7 +259,7 @@ end
|
|
257
259
|
|
258
260
|
#{ output_table "daily_distribution", ["Day", "Hits", "Visits", "Size"], @daily_distribution }
|
259
261
|
|
260
|
-
#+BEGIN_SRC gnuplot :var data = daily_distribution :results output :exports
|
262
|
+
#+BEGIN_SRC gnuplot :var data = daily_distribution :results output :exports #{@export} :file #{@prefix}daily#{@suffix}.svg
|
261
263
|
reset
|
262
264
|
set grid ytics linestyle 0
|
263
265
|
set grid xtics linestyle 0
|
@@ -271,7 +273,8 @@ set xtics rotate by 60 right
|
|
271
273
|
set title "Hits and Visitors"
|
272
274
|
set xlabel "Date"
|
273
275
|
set ylabel "Hits"
|
274
|
-
set
|
276
|
+
set y2label "Visits"
|
277
|
+
set y2tics
|
275
278
|
|
276
279
|
set style fill transparent solid 0.2 noborder
|
277
280
|
|
@@ -289,7 +292,7 @@ data using 1:($2+100):2 with labels notitle textcolor rgb "#0000AA" axes x1y2
|
|
289
292
|
#{ output_table "time_distribution", ["Hour", "Hits", "Visits", "Size"], @time_distribution }
|
290
293
|
|
291
294
|
|
292
|
-
#+BEGIN_SRC gnuplot :var data = time_distribution :results output :exports
|
295
|
+
#+BEGIN_SRC gnuplot :var data = time_distribution :results output :exports #{@export} :file #{@prefix}time#{@suffix}.svg
|
293
296
|
reset
|
294
297
|
set terminal svg size 1200,800 fname 'Arial' fsize 10
|
295
298
|
|
@@ -297,7 +300,9 @@ set grid ytics linestyle 0
|
|
297
300
|
|
298
301
|
set title "Hits and Visitors"
|
299
302
|
set xlabel "Date"
|
300
|
-
set ylabel "Hits
|
303
|
+
set ylabel "Hits"
|
304
|
+
set y2label "Visitors"
|
305
|
+
set y2tics
|
301
306
|
|
302
307
|
set style fill solid 0.25
|
303
308
|
set boxwidth 0.6
|
@@ -311,7 +316,7 @@ data using ($0 - 0.2):($2 + 10):2 with labels title "" textcolor rgb("#0000AA"),
|
|
311
316
|
data using ($0 + 0.2):($3 + 10):3 with labels title "" textcolor rgb("#AA0000") axes x1y2
|
312
317
|
#+END_SRC
|
313
318
|
|
314
|
-
#+BEGIN_SRC gnuplot :var data = time_distribution :results output :exports
|
319
|
+
#+BEGIN_SRC gnuplot :var data = time_distribution :results output :exports #{@export} :file #{@prefix}time-traffic#{@suffix}.svg
|
315
320
|
reset
|
316
321
|
set terminal svg size 1200,800 fname 'Arial' fsize 10
|
317
322
|
|
@@ -349,13 +354,13 @@ data using ($0):($2 + 10):2 with labels title "" textcolor rgb("#00AA00")
|
|
349
354
|
|
350
355
|
* Possible Attacks
|
351
356
|
|
352
|
-
#{ output_table "
|
357
|
+
#{ output_table "attacks", ["Path", "Hits", "Visitors"], @attacks }
|
353
358
|
|
354
359
|
* Statuses
|
355
360
|
|
356
361
|
#{ output_table "statuses", ["Status", "Count"], @statuses }
|
357
362
|
|
358
|
-
#+BEGIN_SRC gnuplot :var data = statuses :results output :exports
|
363
|
+
#+BEGIN_SRC gnuplot :var data = statuses :results output :exports #{@export} :file #{@prefix}statuses#{@suffix}.svg
|
359
364
|
reset
|
360
365
|
set grid ytics linestyle 0
|
361
366
|
set terminal svg size 1200,800 fname 'Arial' fsize 10
|
@@ -371,7 +376,7 @@ data using ($0):($2+100):2 with labels textcolor rgb "#0000AA"
|
|
371
376
|
|
372
377
|
#{ output_table "daily_statuses", ["Status", "2xx", "3xx", "4xx"], @statuses_by_day }
|
373
378
|
|
374
|
-
#+BEGIN_SRC gnuplot :var data = daily_statuses :results output :exports
|
379
|
+
#+BEGIN_SRC gnuplot :var data = daily_statuses :results output :exports #{@export} :file #{@prefix}daily-statuses#{@suffix}.svg
|
375
380
|
reset
|
376
381
|
set terminal svg size 1200,800 fname 'Arial' fsize 10
|
377
382
|
|
@@ -388,19 +393,19 @@ set boxwidth 0.6
|
|
388
393
|
set style data histograms
|
389
394
|
set style histogram clustered gap 1
|
390
395
|
|
391
|
-
plot data using 2:xtic(1) lc rgb "#
|
396
|
+
plot data using 2:xtic(1) lc rgb "#00AA00" title "2xx", \\
|
392
397
|
data using 3 lc rgb "#0000CC" title "3xx", \\
|
393
|
-
data using 4 lc rgb "#
|
394
|
-
data using ($0 - 1. / 4):($2 + 0.5):2 with labels title "" textcolor rgb("#
|
398
|
+
data using 4 lc rgb "#AA0000" title "4xx", \\
|
399
|
+
data using ($0 - 1. / 4):($2 + 0.5):2 with labels title "" textcolor rgb("#00AA00"), \\
|
395
400
|
data using ($0):($3 + 0.5):3 with labels title "" textcolor rgb("#0000CC"), \\
|
396
|
-
data using ($0 + 1. / 4):($4 + 0.5):4 with labels title "" textcolor rgb("#
|
401
|
+
data using ($0 + 1. / 4):($4 + 0.5):4 with labels title "" textcolor rgb("#AA0000")
|
397
402
|
#+END_SRC
|
398
403
|
|
399
404
|
* Browsers
|
400
405
|
|
401
406
|
#{ output_table "browsers", ["Browser", "Hits", "Visitors", "Size"], @browsers }
|
402
407
|
|
403
|
-
#+BEGIN_SRC gnuplot :var data = browsers :results output :exports
|
408
|
+
#+BEGIN_SRC gnuplot :var data = browsers :results output :exports #{@export} :file #{@prefix}browser#{@suffix}.svg
|
404
409
|
reset
|
405
410
|
set grid ytics linestyle 0
|
406
411
|
set terminal svg size 1200,800 fname 'Arial' fsize 10
|
@@ -416,7 +421,7 @@ data using ($0):($2+100):2 with labels textcolor rgb "#0000AA"
|
|
416
421
|
|
417
422
|
#{ output_table "platforms", ["Platform", "Hits", "Visitors", "Size"], @platforms }
|
418
423
|
|
419
|
-
#+BEGIN_SRC gnuplot :var data = platforms :results output :exports
|
424
|
+
#+BEGIN_SRC gnuplot :var data = platforms :results output :exports #{@export} :file #{@prefix}platforms#{@suffix}.svg
|
420
425
|
reset
|
421
426
|
set grid ytics linestyle 0
|
422
427
|
set terminal svg size 1200,800 fname 'Arial' fsize 10
|
@@ -437,7 +442,7 @@ data using ($0):($2+100):2 with labels textcolor rgb "#0000AA"
|
|
437
442
|
|
438
443
|
#{ output_table "referers", ["Referers", "Hits", "Visitors", "Size"], @referers }
|
439
444
|
|
440
|
-
#+BEGIN_SRC gnuplot :var data = referers :results output :exports
|
445
|
+
#+BEGIN_SRC gnuplot :var data = referers :results output :exports #{@export} :file #{@prefix}referers#{@suffix}.svg
|
441
446
|
reset
|
442
447
|
set terminal svg size 1200,800 fname 'Arial' fsize 10
|
443
448
|
|
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.
|
4
|
+
version: 0.9.6
|
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-
|
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
|