Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syslog-ng connecting to mysql

I would like to log files from a switch to a mysql database. I am using syslog-ng and in the configuration file, i have done the following amendments

filter f_no_debug { not level(debug); };

destination d_mysql {
sql(
type(mysql)
username("logs")
password("SECUREPASSWORD")
database("logs")
host("localhost")
table("logs")
columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg")
values("$HOST", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG","$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC","$PROGRAM", "$MSG")
indexes("datetime", "host", "program", "pid", "message")
);
};

log {source(s_net); source(s_src); filter(f_no_debug); destination(d_mysql); }

When i run the command service syslog restart, i get the following error

Unable to initialize database access (DBI);rc='-1', error='No such file or directory (2)' Error initializing dest driver;dest='d_mysql',id='d_mysql'#0 Error initializing message pipeline

How can i overcome this problem to enable logs to be directed to the database?

like image 815
sosytee Avatar asked Jan 12 '23 10:01

sosytee


2 Answers

On Ubuntu and Debian:

MySQL database server driver for libdbi:

apt-get install libdbd-mysql

PostgreSQL database server driver for libdbi:

apt-get install libdbd-pgsql

SQLite3 database driver for libdbi:

apt-get install libdbd-sqlite3
like image 139
Hasan Ramezani Avatar answered Jan 25 '23 13:01

Hasan Ramezani


This message seems to be caused when the libdbi drivers are not installed. Take a look at http://libdbi.sourceforge.net/ or see if there is a libdbi package for your distribution.

like image 28
Richard Neish Avatar answered Jan 25 '23 11:01

Richard Neish