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

Hamilton, Andrew syslog-ng@lists.balabit.hu
Mon, 10 May 2004 09:19:26 -0400


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C43691.6AF5F007
Content-Type: text/plain;
	charset="iso-8859-1"

Try going here:
 
 <http://www.campin.net/syslog-ng/faq.html>
http://www.campin.net/syslog-ng/faq.html

 

Regards.

-----Original Message-----
From: Gayathri J. Gunawardena [mailto:gjg@sltnet.lk]
Sent: Monday, May 10, 2004 8:13 AM
To: syslog-ng@lists.balabit.hu
Subject: [syslog-ng]How to log into mysql database - help required




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
<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?
 

 


------_=_NextPart_001_01C43691.6AF5F007
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=496011913-10052004><FONT face=Arial color=#0000ff size=2>Try 
going here:</FONT></SPAN></DIV>
<DIV><SPAN class=496011913-10052004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=496011913-10052004>
<P><A href="http://www.campin.net/syslog-ng/faq.html"><FONT 
size=2>http://www.campin.net/syslog-ng/faq.html</FONT></A></P>
<P><FONT size=2></FONT>&nbsp;</P>
<P><SPAN class=496011913-10052004><FONT face=Arial color=#0000ff 
size=2>Regards.</FONT></SPAN></P></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Gayathri J. Gunawardena 
  [mailto:gjg@sltnet.lk]<BR><B>Sent:</B> Monday, May 10, 2004 8:13 
  AM<BR><B>To:</B> syslog-ng@lists.balabit.hu<BR><B>Subject:</B> [syslog-ng]How 
  to log into mysql database - help required<BR><BR></FONT></DIV>
  <DIV><FONT face=Arial size=2>
  <DIV><FONT face=Arial size=2>
  <DIV><FONT face=Arial size=2>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 
  </FONT></DIV>
  <DIV><FONT face=Arial size=2><A 
  href="http://www.vermeer.org/display_doc.php?doc_id=1">http://www.vermeer.org/display_doc.php?doc_id=1</A>&nbsp;for 
  this purpose. As given in this website</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>(1) First I made the pipe file using the 
  following command</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2># mkfifo /tmp/mysql.pipe</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>(2) Then I used the following command to log into 
  mysql (first tried with local logging)</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2># mysql -u root --password=passwd syslog &lt; 
  /tmp/mysql.pipe</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>This command gets stuck</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>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<BR></DIV></FONT>
  <DIV><FONT face=Arial size=2>/etc/init.d/syslog-ng stop # Stop 
  syslog-ng<BR>/etc/ini.d/syslog-ng start # Start syslog-ng</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>(3) The site states about an initialization 
  script like this one which needs to be started at start u</FONT><FONT 
  face=Arial size=2>p.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>The script given is provided below.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>#!/bin/bash<BR><BR><FONT color=#800000>if [ -e 
  /tmp/mysql.pipe ]; then<BR>while [ -e /tmp/mysql.pipe ]<BR>do<BR>mysql -u 
  theuserid --password=thepassword syslogdb &lt; 
  /tmp/mysql.pipe<BR>done<BR>else<BR>mkfifo 
  /tmp/mysql.pipe<BR>fi</FONT></FONT></DIV>
  <DIV><FONT face=Arial size=2><FONT 
color=#800000><BR>&nbsp;</DIV></FONT></FONT>
  <DIV><FONT face=Arial size=2>Where should I put this script and how to start 
  it up at initialization?&nbsp;</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Could you explain the working pricipal of this 
  script?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2><BR></FONT><FONT face=Arial 
  size=2>&nbsp;</FONT></DIV></FONT></DIV></FONT></DIV></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C43691.6AF5F007--