[syslog-ng]syslog-ng to MySQL

Richard E. Perlotto II rperlott@cisco.com
Fri, 13 Dec 2002 18:46:40 -0800


Just as an FYI for everyone.  I have abandoned the pipe method of
writing to a database and instead have modified the PostgreSQL scripts
for MySQL for sourcing the buffered files.  These seems much more
stable and almost as fast.


Richard

> -----Original Message-----
> From: syslog-ng-admin@lists.balabit.hu 
> [mailto:syslog-ng-admin@lists.balabit.hu] On Behalf Of 
> Richard E. Perlotto II
> Sent: Thursday, December 12, 2002 4:27 PM
> To: syslog-ng@lists.balabit.hu
> Subject: RE: [syslog-ng]syslog-ng to MySQL
> 
> 
> I posted the full files, but they will require moderator 
> approval, so here are the pieces:
> 
> >From the config files:
> 
> destination mysql          { pipe("/tmp/mysql.pipe"
>                              template("INSERT INTO logs 
> (host, facility,
> 
>                              priority, level, tag, date, 
> time, program, 
>                              msg) VALUES ( '$HOST', 
> '$FACILITY', '$PRIORITY', 
>                              '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY', 
>                              '$HOUR:$MIN:$SEC', '$PROGRAM', '$MSG'
> );\n") 
>                              template-escape(yes)); };
> 
> log { source(src); destination(mysql); };
> 
> 
> >From the init file (minus most stuff for brevity):
> 
> myfifo=/tmp/mysql.pipe
> mysqlstart=/etc/syslog-ng/mysql-syslog
> 
> start() 
>   {
>     gprintf "Preping for MySQL and Syslog: "
>     rm -f $myfifo
>     mkfifo $myfifo
>     echo
> 
>     gprintf "Starting $INIT_PROG: "
>     daemon $INIT_PROG $SYSLOGNG_OPTIONS
> 
>     RETVAL=$?
>     echo
>     [ $RETVAL -eq 0 ] && touch "/var/lock/subsys/${INIT_PROG}"
>     return $RETVAL
> 
>     gprintf "Starting MySQL/Syslog pipe: "
>     $mysqlstart
>     echo
>   }
> 
> >From mysql-syslog file (again extra stuff removed):
> 
> dbuser=dbuser
> dbpassword=dbpassword
> db=db
> pipe=/tmp/mysql.pipe
> 
> mysql -u $dbuser --password=$dbpassword $db < $pipe &
> 
> 
> The command does not seem to go in the background, but if I 
> run this command manually minus the & everything works fine.  
> I had also tried with running the mysql-syslog program in the 
> background from the init file which did not work.  I had all 
> the test cases in there from the example from campin.net, but 
> ended up removing them by adding to the init file to ensure 
> that the pipe file 
> was created in the right sequence.
> 
> 
> Richard
> 
> > -----Original Message-----
> > From: syslog-ng-admin@lists.balabit.hu
> > [mailto:syslog-ng-admin@lists.balabit.hu] On Behalf Of Nate Campi
> > Sent: Thursday, December 12, 2002 3:26 PM
> > To: syslog-ng@lists.balabit.hu
> > Subject: Re: [syslog-ng]syslog-ng to MySQL
> > 
> > 
> > On Thu, Dec 12, 2002 at 03:16:37PM -0800, Richard E. Perlotto
> > II wrote:
> > > Has anyone successfully gotten this to auto start
> > successfully, and if
> > > so, could you please share your programs?  I have followed the
> > > instructions on campin.net, which while very nice do not 
> seem work 
> > > successfully for auto starts.
> > > 
> > > I can get the logging to go to the database via the pipe
> > command, but
> > > cannot seem to get any form of /etc/init.d file to properly
> > auto start
> > > the logging to the database.
> > > 
> > > Or perhaps there is a better way to do this?
> > 
> > This is pretty vague Richard.
> > 
> > What is in your init script and what are the error messages?
> > Does it start from the command line as root? If so is root's 
> > path different from the system path?
> > 
> > We need more info to be of any help.
> > -- 
> > Nate Campi   http://www.campin.net 
> > 
> > "When angry, count four; when very angry, swear." -
> > Pudd'nhead Wilson's 
> > Calendar(1894) - Samuel Clemens
> > 
> > 
> 
> 
> _______________________________________________
> syslog-ng maillist  -  syslog-ng@lists.balabit.hu 
> https://lists.balabit.hu/mailman/listinfo/sysl> og-ng
> 
> Frequently asked questions at 
> http://www.campin.net/syslog-ng/faq.html
> 
> 
>