apache_log_report 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apache_log_report.rb +23 -12
- data/lib/apache_log_report/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cfcc34ca8741250adff411009618f4a359c4c59606a911a924416650fa352e7
|
4
|
+
data.tar.gz: 4f366f09084266e0112f597aac8be998ff47df8ef50d8fd01b1c26361dc889b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddee7b7b3fd56327c3409f0a6de2778b83a0e67d743d300f00259ba314159d1cb62315f388fc0136052895903c7e6df47e08ba59b036db23f0722fc99e5f7b6d
|
7
|
+
data.tar.gz: 0e857dbb34cd66057a401016afcd457c19c995c7aff66a87d4db230569b67a091c19d5f3446377f1a7ee8f8cda3b70ea0b8b4753bd7aea3beadc07810cf2d54b
|
data/lib/apache_log_report.rb
CHANGED
@@ -18,11 +18,11 @@ module ApacheLogReport
|
|
18
18
|
args[:limit] = n
|
19
19
|
end
|
20
20
|
|
21
|
-
opts.on("-bDATE", "--
|
21
|
+
opts.on("-bDATE", "--begin=DATE", DateTime, "Consider entries after or on DATE") do |n|
|
22
22
|
args[:from_date] = n
|
23
23
|
end
|
24
24
|
|
25
|
-
opts.on("-eDATE", "--
|
25
|
+
opts.on("-eDATE", "--end=DATE", DateTime, "Consider entries before or on DATE") do |n|
|
26
26
|
args[:to_date] = n
|
27
27
|
end
|
28
28
|
|
@@ -186,18 +186,29 @@ module ApacheLogReport
|
|
186
186
|
"true"
|
187
187
|
].compact.join " and "
|
188
188
|
|
189
|
+
# in alternative to sum(size)
|
190
|
+
human_readable_size = <<-EOS
|
191
|
+
CASE
|
192
|
+
WHEN sum(size) < 1024 THEN sum(size) || ' B'
|
193
|
+
WHEN sum(size) >= 1024 AND sum(size) < (1024 * 1024) THEN ROUND((CAST(sum(size) AS REAL) / 1024),2) || ' KB'
|
194
|
+
WHEN sum(size) >= (1024 * 1024) AND sum(size) < (1024 * 1024 * 1024) THEN ROUND((CAST(sum(size) AS REAL) / (1024 * 1024)),2) || ' MB'
|
195
|
+
WHEN sum(size) >= (1024 * 1024 * 1024) AND sum(size) < (1024 * 1024 * 1024 *1024) THEN ROUND((CAST(sum(size) AS REAL) / (1024 * 1024 * 1024)),2) || ' GB'
|
196
|
+
WHEN sum(size) >= (1024 * 1024 * 1024 * 1024) THEN ROUND((CAST(sum(size) AS REAL) / (1024 * 1024 * 1024 * 1024)),2) || ' TB'
|
197
|
+
END AS size
|
198
|
+
EOS
|
199
|
+
|
189
200
|
@total_hits = db.execute "SELECT count(datetime) from LogLine where #{@filter}"
|
190
201
|
@total_unique_visitors = db.execute "SELECT count(distinct(unique_visitor)) from LogLine where #{@filter}"
|
191
|
-
@total_size = db.execute "SELECT
|
202
|
+
@total_size = db.execute "SELECT #{human_readable_size} from LogLine where #{@filter}"
|
192
203
|
@total_days = (Date.parse(@last_day[0][0]) - Date.parse(@first_day[0][0])).to_i
|
193
204
|
|
194
|
-
@daily_distribution = db.execute "SELECT date(datetime), count(datetime), count(distinct(unique_visitor)),
|
205
|
+
@daily_distribution = db.execute "SELECT date(datetime), count(datetime), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by date(datetime)"
|
195
206
|
|
196
|
-
@time_distribution = db.execute "SELECT strftime('%H', datetime), count(datetime), count(distinct(unique_visitor)),
|
207
|
+
@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)"
|
197
208
|
|
198
|
-
@most_requested_pages = db.execute "SELECT path, count(path), count(distinct(unique_visitor)),
|
209
|
+
@most_requested_pages = db.execute "SELECT path, count(path), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where extension == '.html' and #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
|
199
210
|
|
200
|
-
@most_requested_resources = db.execute "SELECT path, count(path), count(distinct(unique_visitor)),
|
211
|
+
@most_requested_resources = db.execute "SELECT path, count(path), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
|
201
212
|
|
202
213
|
@missed_pages = db.execute "SELECT path, count(path), count(distinct(unique_visitor)) from LogLine where status == '404' and extension == '.html' and #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
|
203
214
|
|
@@ -219,13 +230,13 @@ module ApacheLogReport
|
|
219
230
|
[x[0], x[1].map { |y| y[1] }].flatten
|
220
231
|
}
|
221
232
|
|
222
|
-
@browsers = db.execute "SELECT browser, count(browser), count(distinct(unique_visitor)),
|
233
|
+
@browsers = db.execute "SELECT browser, count(browser), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by browser order by count(browser) desc"
|
223
234
|
|
224
|
-
@platforms = db.execute "SELECT platform, count(platform), count(distinct(unique_visitor)),
|
235
|
+
@platforms = db.execute "SELECT platform, count(platform), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by platform order by count(platform) desc"
|
225
236
|
|
226
|
-
@ips = db.execute "SELECT ip, count(ip), count(distinct(unique_visitor)),
|
237
|
+
@ips = db.execute "SELECT ip, count(ip), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by ip order by count(ip) desc limit #{options[:limit]}"
|
227
238
|
|
228
|
-
@referers = db.execute "SELECT referer, count(referer), count(distinct(unique_visitor)),
|
239
|
+
@referers = db.execute "SELECT referer, count(referer), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by referer order by count(referer) desc limit #{options[:limit]}"
|
229
240
|
end
|
230
241
|
|
231
242
|
|
@@ -263,7 +274,7 @@ module ApacheLogReport
|
|
263
274
|
|
264
275
|
| Hits | #{"%10d" % @total_hits[0][0]} |
|
265
276
|
| Unique Visitors | #{"%10d" % @total_unique_visitors[0][0] } |
|
266
|
-
| Tx | #{"%
|
277
|
+
| Tx | #{"%10s" % @total_size[0][0]} |
|
267
278
|
| Days | #{"%10d" % @total_days[0][0] } |
|
268
279
|
|
269
280
|
* Daily Distribution
|