|
Hi how to get the hourly aggregation on the time
ex :
20050823 14:12:00
20050823 14:12:01
20050823 14:12:11
20050823 14:12:12
20050823 14:12:13
20050823 14:12:47
20050823 14:12:48
20050823 14:13:05
20050823 14:13:16
20050823 14:13:25
20050823 14:13:30
20050823 14:13:31
20050823 14:13:31
20050823 14:13:32
20050823 14:13:32
20050823 14:13:33
20050823 14:13:33
20050823 14:13:34
20050823 14:13:34
20050823 14:13:34
20050823 14:13:36
20050823 14:13:47
20050823 14:14:02
If this is the in an array
How can i get the hourly i.e 14 i have to trace the all urls at 14 hr and also should have the number of hits in a
single with hr 20050823 14:00:00 like
20050823 14:12:00,www.pdablast.com ,1
20050823 14:12:01,www.pdablast.com ,2
20050823 14:12:11,www.pdablast.com ,3
20050823 14:12:12,www.pdablast.com ,4
20050823 14:12:13,www.pdablast.com ,5
20050823 14:12:47,www.pdablast.com ,6
20050823 14:12:48,www.pdablast.com ,7
20050823 14:13:05,www.pdablast.com ,8
20050823 14:13:16,www.pdablast.com ,9
20050823 14:13:25,www.pdablast.com ,10
20050823 14:13:30,www.pdablast.com ,11
20050823 14:13:31,www.pdablast.com ,12
20050823 14:13:31,www.pdablast.com ,13
20050823 14:13:32,www.pdablast.com ,14
20050823 14:13:32,www.pdablast.com ,15
20050823 14:13:33,www.pdablast.com ,16
20050823 14:13:33,www.pdablast.com ,17
20050823 14:13:34,www.pdablast.com ,18
20050823 14:13:34,www.pdablast.com ,19
20050823 14:13:34,www.pdablast.com ,20
20050823 14:13:36,www.pdablast.com ,21
20050823 14:13:47,www.pdablast.com ,22
it should be displayed like
20050823 14:00:00,www.pdablast.com,hits:22
so could you please help me out to sort out the date by h
|
|
|
Here's a snippet that parses out all the fields from each log entry. Reads from a file. Should be simple enough to make it group values as you need. You'll probably want to use an associative array to store values until you get to the next hour.
#!/usr/bin/perl
open (FILE, "$ARGV[0]");
while (<FILE>)
{
$_ =~ /([0-9]{8}) ([0-9]{2}):.+?,(.+?) ,(.+?)/gso;
$date = $1;
$hour = $2;
$url = $3;
$hits = $4;
print "$date $hour:00:00,$url,hits:$hits\n"
} # While <FILE>
close(FILE);
|
|
|
|
|
|
|
|