[syslog-ng]syslog-ng to MySQL
Richard E. Perlotto II
rperlott@cisco.com
Thu, 12 Dec 2002 16:27:28 -0800
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
>
>