+ Logging, Syslog and Log Anaylsys Forums » Forums » Syslog & syslogd » syslog-ng
|-+ 

syslog-ng to mysql, but also using filters?

Username:
Password:
News:

Pages: [1]
0 Members and 1 Guest are viewing this topic. Topic Tools  
Read November 03, 2008, 05:09:20 pm #0
doug.hairfield

syslog-ng to mysql, but also using filters?

Hi, I'm a bit new to syslog-ng so please excuse my n00b question.

I have syslog-ng piping logs into mysql using the setup from http://vermeer.org/docs/1, and it seems to be working fine.  But, when I try to apply a filter I wrote to only log the facility(mail) logs to the sql destination, I get no log output and my mysql >/tmp/mysql.pipe script ceases to work.  Take the filter statement out and restart syslog-ng and it's all back to normal.  Conversely, if I use the filter and just write to a file, that works.  I just don't seem to be able to use the mail filter and mysql piping at the same time.

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-esc
};

filter f_ALLMaillogs { host("staging") and facility(mail); };

log { source(s_sys); filter(f_ALLMaillogs); destination(d_mysql); }; 

All I want to do is aggregate my mail logs per host to a central database using syslog-ng.  Is using using filters to only do the mail logs the right way to go?

Offline  
Read November 05, 2008, 11:09:21 am #1
doug.hairfield

Re: syslog-ng to mysql, but also using filters?

Well I figured it out.  Turns out it was my script to pipe in the the text to MySQL, wound up finding and using this

if [ -e /tmp/mysql.pipe ]; then
        while [ -e /tmp/mysql.pipe ]
                                do
                                                  mysql syslog < /tmp/mysql.pipe
                done
else
        mkfifo /tmp/mysql.pipe
fi

I think it was just dying if there was no input at the moment.
Offline  
Pages: [1]
Jump to:  


Information Security News | Jerry Bell's blog | Enterprise IT | Tropical Fish Information | Tropical Fish Forums