[syslog-ng]How to log into mysql database - help required

Michael Earls syslog-ng@lists.balabit.hu
Mon, 10 May 2004 10:30:59 -0400


I would use if statement in cron to check to see if this is running if
not running start it.

## Mysql insert run the check
0-55/1 * * * *   root    if [ -x /bin/bash ] && [ -r
/etc/syslog-ng/mysql_pipe.sh ]; then /bin/bash
/etc/syslog-ng/mysql_pipe.sh >> /var/log/syslog-ng/mysql_pipe.log 2>&1;
fi

Michael



>>> gjg@sltnet.lk 5/10/2004 8:13:02 AM >>>
I require to log syslogs into a mysql database. I used syslog-ng
(downloaded the rpm for syslog-ng - ver 1.6 and libol from rpmseek.com
and installed it) and used the information available in the site 
http://www.vermeer.org/display_doc.php?doc_id=1 for this purpose. As
given in this website

(1) First I made the pipe file using the following command
 
# mkfifo /tmp/mysql.pipe
 
(2) Then I used the following command to log into mysql (first tried
with local logging)

# mysql -u root --password=passwd syslog < /tmp/mysql.pipe
 
This command gets stuck
 
But when syslog-ng is stopped and started it logs and the contenets in
/tmp/mysql.pipe gets loaded into the database table. The following
commands were used to stop and start syslog-ng

/etc/init.d/syslog-ng stop # Stop syslog-ng
/etc/ini.d/syslog-ng start # Start syslog-ng
 
(3) The site states about an initialization script like this one which
needs to be started at start up.
 
The script given is provided below.
 
#!/bin/bash

if [ -e /tmp/mysql.pipe ]; then
while [ -e /tmp/mysql.pipe ]
do
mysql -u theuserid --password=thepassword syslogdb < /tmp/mysql.pipe
done
else
mkfifo /tmp/mysql.pipe
fi

 
Where should I put this script and how to start it up at
initialization? 
 
Could you explain the working pricipal of this script?