I’ve just had to struggle with the hex ip addresses which dnscache logs, after a bit of searching I found some nice notes about the log format here thanks to Rob Mayoff.
Finally I found this handy perl script.
Some perl that sets a timeout value
#!/usr/bin/perl
$SIG{ALRM} = sub { alarmed(); };
alarm(20);
eval { check_whatever; };
alarm(0);
sub check_whatever()
{
# stuff to do that might timeout
exit 0;
}
sub alarmed()
{
# stuff to do after the alarm has gone off.
exit 1;
}
Thanks to Timbo for help with this…
Justin sent over a regex he wrote for catching the various bits of a url:
(http|ftp):\/\/((?:[^./]+\.){1,}(?:[^./]+))((?:/[^/]+)*/)([^/]+)\.([^./]+)
I need to parse ftp xferlogs and our current regex was broken by spaces in uploaded filenames. Have fixed it, is shown below with the names of the fields.
$_ =~ /^(\w{3} \w{3} \s?\d\d? \d\d:\d\d:\d\d \d{4})
(\d\d?)(\S+) (\d+) (.+) ([ab]) (_|C|U|T) (i|o)
(a|g|r) (\w+) (\w+) (0|1) (\w+|\*) ([c|i])$/o;
$current_time = $1;
$transfer_time = $2;
$remote_host = $3;
$byte_count = $4;
$filename = $5;
$transfer_type = $6;
$special_action_flag = $7;
$direction = $8;
$access_mode = $9;
$username = $10;
$service_name =$11;
$authentication_method = $12;
$authenticated_user_id=$13;
$completion_status = $14;
To reconfigure CPAN:
towel root # perl -MCPAN -e shell cpan shell -- CPAN exploration and modules installation (v1.59_54) ReadLine support available (try 'install Bundle::CPAN') cpan> o conf init /usr/lib/perl5/5.6.1/CPAN/Config.pm initialized. CPAN is the world-wide archive of perl resources. It consists of about 100 sites that all replicate the same contents all around the globe. Many countries have at least one CPAN site already. The resources found on CPAN are easily accessible with the CPAN.pm module. If you want to use CPAN.pm, you have to configure it properly. If you do not want to enter a dialog now, you can answer 'no' to this question and I'll try to autoconfigure. (Note: you can revisit this dialog anytime later by typing 'o conf init' at the cpan prompt.) Are you ready for manual configuration? [yes]