• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

CSV2Syslog perl script

Hi Perl junkies :-)

Is there a way to parse a .csv file and convert the strings to syslog?
I want to take in a log file and forward the information to a syslog server.

Thanks!
0
cdukes
Asked:
cdukes
  • 4
  • 2
1 Solution
 
cdukesAuthor Commented:
I should mention that the csv files are on a windows box, so using logger is out :-(
0
 
Romi KuntsmanCommented:
Converting formats is always possible, and even easy with perl.

What fields are there in the csv file, and what format is the syslog file?

RK.
0
 
cdukesAuthor Commented:
I think the tricky part is going to be taking in text and pushing the data out to udp port 161

so let's say I  have a line of text:
03/28/2006,10:00:00,Authen OK,cisco,Engineering,10.1.1.2,tty130,20.1.1.1

These fields are as follows:
$DATE, $TIME, $MSG, $USER, $GROUP, $CALLERID, $NASPRT, $NASIP

So I need to read each line with these tokens and spit them out to a syslog server.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ozoCommented:
$_="03/28/2006,10:00:00,Authen OK,cisco,Engineering,10.1.1.2,tty130,20.1.1.1";
my($DATE, $TIME, $MSG, $USER, $GROUP, $CALLERID, $NASPRT, $NASIP) = split/,/;
use Net::Syslog;
my $s=new Net::Syslog(Facility=>'local4',Priority=>'debug');
$s->send($_,Priority=>'info');
0
 
cdukesAuthor Commented:
Nice!
Does this just log to the local syslog service? What if it's on winders?
0
 
cdukesAuthor Commented:
Also, how do I read the values from a .csv file instead of declaring $_ ?
0
 
ozoCommented:
while( <> ){
my($DATE, $TIME, $MSG, $USER, $GROUP, $CALLERID, $NASPRT, $NASIP) = split/,/;
...
}


Net::Syslog talks to any syslogd you can reach over the net.
You can set SyslogHost to the address of the remote syslogd    
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now