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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With