5

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?

sosytee
  • 1,257
  • 2
  • 11
  • 14

2 Answers2

8

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
Hasan Ramezani
  • 5,004
  • 24
  • 30
3

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.

Richard Neish
  • 8,414
  • 4
  • 39
  • 69