[syslog-ng]How to log into mysql database - help required
Gayathri J. Gunawardena
syslog-ng@lists.balabit.hu
Mon, 10 May 2004 18:13:02 +0600
This is a multi-part message in MIME format.
------=_NextPart_000_0027_01C436BA.6EC02680
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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=20
http://www.vermeer.org/display_doc.php?doc_id=3D1 for this purpose. As =
given in this website
(1) First I made the pipe file using the following command
=20
# mkfifo /tmp/mysql.pipe
=20
(2) Then I used the following command to log into mysql (first tried =
with local logging)
# mysql -u root --password=3Dpasswd syslog < /tmp/mysql.pipe
=20
This command gets stuck
=20
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
=20
(3) The site states about an initialization script like this one which =
needs to be started at start up.
=20
The script given is provided below.
=20
#!/bin/bash
if [ -e /tmp/mysql.pipe ]; then
while [ -e /tmp/mysql.pipe ]
do
mysql -u theuserid --password=3Dthepassword syslogdb < /tmp/mysql.pipe
done
else
mkfifo /tmp/mysql.pipe
fi
=20
Where should I put this script and how to start it up at initialization? =
=20
Could you explain the working pricipal of this script?
=20
=20
------=_NextPart_000_0027_01C436BA.6EC02680
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3502.5390" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>I require to log syslogs into a mysql =
database. I=20
used syslog-ng (downloaded the rpm for syslog-ng - ver 1.6 and libol =
from=20
rpmseek.com and installed it) and used the information available in the =
site=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"http://www.vermeer.org/display_doc.php?doc_id=3D1">http://www.ver=
meer.org/display_doc.php?doc_id=3D1</A> for=20
this purpose. As given in this website</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>(1) First I made the pipe file using =
the following=20
command</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2># mkfifo /tmp/mysql.pipe</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>(2) Then I used the following command =
to log into=20
mysql (first tried with local logging)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># mysql -u root --password=3Dpasswd =
syslog <=20
/tmp/mysql.pipe</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>This command gets stuck</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>But when syslog-ng is stopped and =
started it logs=20
and the contenets in /tmp/mysql.pipe gets loaded into the database =
table. The=20
following commands were used to stop and start =
syslog-ng<BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>/etc/init.d/syslog-ng stop # Stop=20
syslog-ng<BR>/etc/ini.d/syslog-ng start # Start syslog-ng</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>(3) The site states about an =
initialization script=20
like this one which needs to be started at start u</FONT><FONT =
face=3DArial=20
size=3D2>p.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The script given is provided =
below.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>#!/bin/bash<BR><BR><FONT =
color=3D#800000>if [ -e=20
/tmp/mysql.pipe ]; then<BR>while [ -e /tmp/mysql.pipe ]<BR>do<BR>mysql =
-u=20
theuserid --password=3Dthepassword syslogdb <=20
/tmp/mysql.pipe<BR>done<BR>else<BR>mkfifo=20
/tmp/mysql.pipe<BR>fi</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
color=3D#800000><BR> </DIV></FONT></FONT>
<DIV><FONT face=3DArial size=3D2>Where should I put this script and how =
to start it=20
up at initialization? </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Could you explain the working pricipal =
of this=20
script?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><BR></FONT><FONT face=3DArial=20
size=3D2> </FONT></DIV></FONT></DIV></FONT></DIV></BODY></HTML>
------=_NextPart_000_0027_01C436BA.6EC02680--