I'm running syslog-ng v 1.6.11 on RHEL 4. I can log to local files with no problem. I want to also log to a mysql database. I have a mysql database server with a syslog database configured to receive logs.
On the syslog-ng server, do I need mysql installed in order to make the mysql pipe work? From what I read, you need a script scheduled in cron to run every minute to make the mysql connection to send the data. So the script goes on the syslog-ng server, and therefore I need mysql installed on the syslog-ng server to initiate the connection? I thought maybe mysql was somehow built into syslog-ng and it can make the connection itself. If mysql is needed on the syslog-ng server, are there any parameters to pass with reference to syslog-ng while installing mysql?
Here's my syslog-ng.conf, let me know if I'm missing anything:[/color green]
source net { udp(); };
destination d_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)); };
filter f_server { host("server"); };
log { source(net); filter(f_server); destination(d_mysql); };
To create the pipe I did:
mkfifo /tmp/mysql.pipe
Here's a script I found for sending data through the pipe:
#
# Created by Tadghe Patrick Danu
#
#!/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
Thanks in advance, your help is greatly appreciated.
On the syslog-ng server, do I need mysql installed in order to make the mysql pipe work? From what I read, you need a script scheduled in cron to run every minute to make the mysql connection to send the data. So the script goes on the syslog-ng server, and therefore I need mysql installed on the syslog-ng server to initiate the connection? I thought maybe mysql was somehow built into syslog-ng and it can make the connection itself. If mysql is needed on the syslog-ng server, are there any parameters to pass with reference to syslog-ng while installing mysql?
Here's my syslog-ng.conf, let me know if I'm missing anything:[/color green]
source net { udp(); };
destination d_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)); };
filter f_server { host("server"); };
log { source(net); filter(f_server); destination(d_mysql); };
To create the pipe I did:
mkfifo /tmp/mysql.pipe
Here's a script I found for sending data through the pipe:
#
# Created by Tadghe Patrick Danu
#
#!/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
Thanks in advance, your help is greatly appreciated.