apache_log_report 1.1.5 → 1.1.6

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: c4cd01d24bc31eb2fe1107781a94578b43210fdc7d63dd65190643e637dc8da1
4
- data.tar.gz: f1889cc37617847862274bd3d65fab82662d5c8e988129a227ed80b1fe4b7887
3
+ metadata.gz: 742584032338664834cd5c1b669289980e083e68d172827f6517ce040543aa4d
4
+ data.tar.gz: 1bf08e255feb434ded62589d5c70ea5a6eb83dc1f6a69e60a31cb520eea6b48f
5
5
  SHA512:
6
- metadata.gz: 520c9648ccd15f9a3bc0b1761989bb091bc81cf7f16eac6cf5bc5bb73c0aef3e47a03eafd85f468c08834dbf93163c4b750ef31d61b63d277f546afcd21082b2
7
- data.tar.gz: a1833663a335da90513d1054117b9ca39b2f9802c021f7f75dda929312c00e32e7a3725901454c3a3f583839d0addbf511f08e421117f2317892fe1fe1f93628
6
+ metadata.gz: 955dbe90321c68f5694aaa892cae97926172ca47b684a0eee1b9f7644dc26a13f853b3b3d20e35cf06872b29db0c06bc16c4c86e69c740ea86fe8768ae92b2a1
7
+ data.tar.gz: e6d9ebc88435442bfb77faa3cb2eccb94a355e9ca7af44548a7b443531c9fae923e41f5d97201044f71414f2d9894162b593cd15170e255030ab49bd9992e3f0
data/README.org CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  * Introduction
6
6
 
7
+ ApacheLogReport is an Apache log analyzer.
8
+
7
9
  * Installation
8
10
 
9
11
  * Usage
@@ -14,8 +16,12 @@ See the [[file:CHANGELOG.org][CHANGELOG]] file.
14
16
 
15
17
  * Todo
16
18
 
19
+ ** TODO Referers should only include the hostname?
17
20
  ** TODO Graphs in HTML output
18
21
  ** TODO Countries
22
+ ** TODO Light and Dark Theme
23
+ ** TODO Embed CSS
24
+ ** TODO Declare datatypes in table outputs, so that we can format data
19
25
 
20
26
  * Compatibility
21
27
 
@@ -1,17 +1,41 @@
1
+
1
2
  module ApacheLogReport
2
3
  module DataCruncher
3
4
 
4
5
  #
5
6
  # take a sqlite3 database and analyze data
6
7
  #
8
+ # @ variables are automatically put in the returned data
9
+ #
7
10
 
8
11
  def self.crunch db, options = {}
9
- @first_day = db.execute "SELECT datetime from LogLine order by datetime limit 1"
10
- @last_day = db.execute "SELECT datetime from LogLine order by datetime desc limit 1"
12
+ first_day_s = db.execute "SELECT datetime from LogLine order by datetime limit 1"
13
+ last_day_s = db.execute "SELECT datetime from LogLine order by datetime desc limit 1"
14
+
15
+ # make first and last day into dates or nil
16
+ @first_day = first_day_s.empty? ? nil : Date.parse(first_day_s[0][0])
17
+ @last_day = last_day_s.empty? ? nil : Date.parse(last_day_s[0][0])
18
+
19
+ @total_days = 0
20
+ if @first_day and @last_day
21
+ @total_days = (@last_day - @first_day).to_i
22
+ end
23
+
11
24
  @log_size = db.execute "SELECT count(datetime) from LogLine"
12
25
  @crawlers_size = db.execute "SELECT count(datetime) from LogLine where bot == 1"
13
26
  @selfpolls_size = db.execute "SELECT count(datetime) from LogLine where ip == '::1'"
14
27
 
28
+ @first_day_requested = options[:from_date]
29
+ @last_day_requested = options[:to_date]
30
+
31
+ @first_day_in_analysis = date_intersect options[:from_date], @first_day, :max
32
+ @last_day_in_analysis = date_intersect options[:to_date], @last_day, :min
33
+
34
+ @total_days_in_analysis = 0
35
+ if @first_day_in_analysis and @last_day_in_analysis
36
+ @total_days_in_analysis = (@last_day_in_analysis - @first_day_in_analysis).to_i
37
+ end
38
+
15
39
  #
16
40
  # generate the where clause corresponding to the command line options to filter data
17
41
  #
@@ -54,7 +78,6 @@ module ApacheLogReport
54
78
  @total_hits = db.execute "SELECT count(datetime) from LogLine where #{filter}"
55
79
  @total_unique_visitors = db.execute "SELECT count(distinct(unique_visitor)) from LogLine where #{filter}"
56
80
  @total_size = db.execute "SELECT #{human_readable_size} from LogLine where #{filter}"
57
- @total_days = (Date.parse(@last_day[0][0]) - Date.parse(@first_day[0][0])).to_i
58
81
 
59
82
  @daily_distribution = db.execute "SELECT date(datetime), #{human_readable_day}, count(datetime), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{filter} group by date(datetime)"
60
83
  @time_distribution = db.execute "SELECT strftime('%H', datetime), count(datetime), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{filter} group by strftime('%H', datetime)"
@@ -92,7 +115,20 @@ module ApacheLogReport
92
115
  end
93
116
  data
94
117
  end
95
- end
96
118
 
119
+ private
120
+
121
+ def self.date_intersect date1, date2, method
122
+ if date1 and date2
123
+ [date1, date2].send(method)
124
+ elsif date1
125
+ date1
126
+ else
127
+ date2
128
+ end
129
+ end
130
+
131
+
132
+ end
97
133
  end
98
134
 
@@ -18,11 +18,11 @@ module ApacheLogReport
18
18
  args[:limit] = n
19
19
  end
20
20
 
21
- opts.on("-bDATE", "--begin=DATE", DateTime, "Consider entries after or on DATE") do |n|
21
+ opts.on("-bDATE", "--begin=DATE", Date, "Consider entries after or on DATE") do |n|
22
22
  args[:from_date] = n
23
23
  end
24
24
 
25
- opts.on("-eDATE", "--end=DATE", DateTime, "Consider entries before or on DATE") do |n|
25
+ opts.on("-eDATE", "--end=DATE", Date, "Consider entries before or on DATE") do |n|
26
26
  args[:to_date] = n
27
27
  end
28
28
 
@@ -31,7 +31,9 @@
31
31
  "Browsers",
32
32
  "Platforms",
33
33
  "Referers",
34
- "IPs"
34
+ "IPs",
35
+ "Command Invocation",
36
+ "Performance"
35
37
  ].each do |item| %>
36
38
  <li class="nav-item">
37
39
  <a href="#<%= item.downcase.gsub(' ', '-') %>"><%= item %></a>
@@ -40,6 +42,14 @@
40
42
  </ul>
41
43
  </li>
42
44
  </ul>
45
+ <p>
46
+ Generated by<br />
47
+ <a href="https://www.ict4g.net/gitea/adolfo/apache_log_report">
48
+ Apache Log Report
49
+ </a> <br />
50
+ on <%= DateTime.now.strftime("%Y-%m-%d %H:%M") %>.<br />
51
+ The lean log analyzer.
52
+ </p>
43
53
  </nav>
44
54
 
45
55
  <section>
@@ -50,6 +60,22 @@
50
60
  <h2 id="summary">Summary</h2>
51
61
 
52
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>
53
79
  <tr>
54
80
  <th class="hits">Hits</th>
55
81
  <td class="hits"><%= data[:total_hits][0][0] %></td>
@@ -62,18 +88,6 @@
62
88
  <th class="tx">Tx</th>
63
89
  <td class="tx"><%= data[:total_size][0][0] %></td>
64
90
  </tr>
65
- <tr>
66
- <th class="period">Period</th>
67
- <td class="period">
68
- <%= data[:first_day][0][0] %>
69
- --
70
- <%= data[:last_day][0][0] %>
71
- </td>
72
- </tr>
73
- <tr>
74
- <th class="days">Days </th>
75
- <td class="days"><%= data[:total_days] %></td>
76
- </tr>
77
91
  </table>
78
92
  </article>
79
93
  <article class="column col-6">
@@ -85,6 +99,14 @@
85
99
  <th>Input file</th>
86
100
  <td><b><%= (data[:log_file] || "stdin") %></b></td>
87
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>
88
110
  <tr>
89
111
  <th>Log size</th>
90
112
  <td><%= data[:log_size][0][0] %></td>
@@ -175,7 +197,7 @@
175
197
  <tbody>
176
198
  <tr>
177
199
  <th>CLI Command</th>
178
- <td><pre><%= data[:command] %></pre></td>
200
+ <td><code><%= data[:command] %></code></td>
179
201
  </tr>
180
202
  <tr>
181
203
  <th>Input file</th>
@@ -10,7 +10,11 @@
10
10
  | Hits | <%= "%10d" % data[:total_hits][0][0] %> |
11
11
  | Unique Visitors | <%= "%10d" % data[:total_unique_visitors][0][0] %> |
12
12
  | Tx | <%= "%10s" % data[:total_size][0][0] %> |
13
- | Days | <%= "%10d" % data[:total_days][0][0] %> |
13
+ | Logged Period | <%= data[:first_day] %> -- <%= data[:last_day] %> |
14
+ | Days | <%= "%10d" % data[:total_days] %> |
15
+ | Period Requested | <%= data[:first_day_requested] %> -- <%= data[:last_day_requested] %> |
16
+ | Period Analyzed | <%= data[:first_day_in_analysis] %> -- <%= data[:last_day_in_analysis] %> |
17
+ | Days in Analysis | <%= data[:total_days_in_analysis] %> |
14
18
 
15
19
  * Daily Distribution
16
20
 
@@ -1,3 +1,3 @@
1
1
  module ApacheLogReport
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apache_log_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adolfo Villafiorita