R
Rhugga
I am writing a syslog parser that normalizes log entries and the loads
them into a oracle database, I open the input file and process each
line and tokenize it for use but I am running into a roadblock that I
can't seem to find a clean solution for. (my perl skills have grown
rusty over the years)
Here is a sample entry from my input file:
1 Feb 8 00:05:41 back-0202 tldcd[928]: [ID 359804 daemon.notice]
TLD(0) opening robotic path /dev/sg/c3t0l0
This is basically 7 fields of info:
<log count> <timestamp (3 fields)> <hostname> <process info> <log
content>
(<log count> is the number of times an identical log entry was detected
and truncated)
So using split I break this down into components:
@ARGS = (split / /, $line);
$line =~ s/ +/ /g;
$line =~ s/^ +//g;
$log_count = $ARGS[0];
$log_month = $ARGS[1];
$log_day = $ARGS[2];
$log_time = $ARGS[3];
$log_hostname = $ARGS[4];
$log_proc_info = $ARGS[5];
$log_message = $ARGS[6];
My problem is I want $log_message to contain everything after the
process info field. (in the sample entry above, $log_proc_info will
contain tldcd[928]). However $log_message will only contain the next
space delimited field, in this case it will be '[ID'. WHat I want to do
is after I glean $log_proc_info, I then want to set $log_message to the
remaining bytes up to but not including EOL. (ie: I want $log_message =
"[ID 359804 daemon.notice] TLD(0) opening robotic path /dev/sg/c3t0l0"
)
I hope this is making sense, I have working on no sleep as usual.
Thanks for any help,
CC
them into a oracle database, I open the input file and process each
line and tokenize it for use but I am running into a roadblock that I
can't seem to find a clean solution for. (my perl skills have grown
rusty over the years)
Here is a sample entry from my input file:
1 Feb 8 00:05:41 back-0202 tldcd[928]: [ID 359804 daemon.notice]
TLD(0) opening robotic path /dev/sg/c3t0l0
This is basically 7 fields of info:
<log count> <timestamp (3 fields)> <hostname> <process info> <log
content>
(<log count> is the number of times an identical log entry was detected
and truncated)
So using split I break this down into components:
@ARGS = (split / /, $line);
$line =~ s/ +/ /g;
$line =~ s/^ +//g;
$log_count = $ARGS[0];
$log_month = $ARGS[1];
$log_day = $ARGS[2];
$log_time = $ARGS[3];
$log_hostname = $ARGS[4];
$log_proc_info = $ARGS[5];
$log_message = $ARGS[6];
My problem is I want $log_message to contain everything after the
process info field. (in the sample entry above, $log_proc_info will
contain tldcd[928]). However $log_message will only contain the next
space delimited field, in this case it will be '[ID'. WHat I want to do
is after I glean $log_proc_info, I then want to set $log_message to the
remaining bytes up to but not including EOL. (ie: I want $log_message =
"[ID 359804 daemon.notice] TLD(0) opening robotic path /dev/sg/c3t0l0"
)
I hope this is making sense, I have working on no sleep as usual.
Thanks for any help,
CC