First page Back Continue Last page Overview Graphics
Accessing Log Data
Now, we can use the AnyData API to access our logs:
my $reaperlogs = adTie( 'ReaperLogs', '/path/to/logs' );
Print a list of all times Joe's processes were reaped:
my $reaps = $reaperlogs->{ {user => 'joe'} };
print ā$_->{date}\nā for @$reaps;
Count per-user how many times we reaped PHP:
my %count;
my $reaps = $reaperlogs->{ {cmd => qr/php/} };
$count{$_->{user}}++ for @$reaps;
Notes:
Now, with that little bit of code, we have full access to search our log files in lots of interesting ways.
AnyData has built in support to search using regular expressions as well as a number of other character and arithmetic operations.