From 02f768c37dac9dde424bbd31e378482750fc276c Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 12 Aug 2008 16:08:09 +0200 Subject: enhanced ommysql to support custom port to connect to server Port can be set via new $ActionOmmysqlServerPort config directive Note: this was a very minor change and thus deemed appropriate to be done in the stable release. --- ChangeLog | 4 ++++ configure.ac | 2 +- doc/ommysql.html | 46 ++++++++++++++++++++++++++++++++++++++++++++++ doc/rsyslog_conf.html | 2 +- plugins/ommysql/ommysql.c | 24 +++++++++++++++++++++--- 5 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 doc/ommysql.html diff --git a/ChangeLog b/ChangeLog index c3155874..931ff5ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ --------------------------------------------------------------------------- Version 3.18.3 (rgerhards), 2008-08-?? +- enhanced ommysql to support custom port to connect to server + Port can be set via new $ActionOmmysqlServerPort config directive + Note: this was a very minor change and thus deemed appropriate to be + done in the stable release. - bugfix: misspelled config directive, previously was $MainMsgQueueWorkeTimeoutrThreadShutdown, is now $MainMsgQueueWorkerTimeoutThreadShutdown. Note that the misspelled diff --git a/configure.ac b/configure.ac index 314dc10f..caffe01e 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[3.18.3],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[3.18.3-Test3],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([syslogd.c]) AC_CONFIG_HEADERS([config.h]) diff --git a/doc/ommysql.html b/doc/ommysql.html new file mode 100644 index 00000000..79d913eb --- /dev/null +++ b/doc/ommysql.html @@ -0,0 +1,46 @@ + + + +MySQL Database Output Module + + + +

MySQL Database Output Module

+

Module Name:    ommysql

+

Author: Michael Meckelein (Initial Author) / Rainer Gerhards +<rgerhards@adiscon.com>

+

Description:

+

This module provides native support for logging to MySQL databases. It offers +superior performance over the more generic omlibdbi module. +

+

Configuration Directives:

+

ommysql mostly uses the "old style" configuration, with almost everything on the +action line itself. A few newer features are being migrated to the new style-config +directive configuration system. +

+

Sample:

+

The following sample writes all syslog messages to the +database "syslog_db" on mysqlsever.example.com. The server is +being accessed under the account of "user" with password "pwd". +

+ +

[rsyslog.conf overview] +[manual index] [rsyslog site]

+

This documentation is part of the +rsyslog +project.
+Copyright © 2008 by Rainer Gerhards and +Adiscon. +Released under the GNU GPL version 3 or higher.

+ diff --git a/doc/rsyslog_conf.html b/doc/rsyslog_conf.html index e65be0bc..330fd51c 100644 --- a/doc/rsyslog_conf.html +++ b/doc/rsyslog_conf.html @@ -30,7 +30,7 @@ trap output module
  • omrelp - RELP output module
  • omgss - output module for GSS-enabled syslog
  • -
  • ommysql - output module for MySQL
  • +
  • ommysql - output module for MySQL
  • ompgsql - output module for PostgreSQL
  • omlibdbi - generic database output module (Firebird/Interbase, MS SQL, Sybase, diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index 0522e31d..807351d2 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -44,6 +44,7 @@ #include "ommysql.h" #include "module-template.h" #include "errmsg.h" +#include "cfsysline.h" MODULE_TYPE_OUTPUT @@ -55,12 +56,16 @@ DEFobjCurrIf(errmsg) typedef struct _instanceData { MYSQL *f_hmysql; /* handle to MySQL */ char f_dbsrv[MAXHOSTNAMELEN+1]; /* IP or hostname of DB server*/ + unsigned int f_dbsrvPort; /* port of MySQL server */ char f_dbname[_DB_MAXDBLEN+1]; /* DB name */ char f_dbuid[_DB_MAXUNAMELEN+1]; /* DB user */ char f_dbpwd[_DB_MAXPWDLEN+1]; /* DB user's password */ unsigned uLastMySQLErrno; /* last errno returned by MySQL or 0 if all is well */ } instanceData; +/* config variables */ +static int iSrvPort = 0; /* database server port */ + BEGINcreateInstance CODESTARTcreateInstance @@ -150,7 +155,7 @@ static rsRetVal initMySQL(instanceData *pData, int bSilent) } else { /* we could get the handle, now on with work... */ /* Connect to database */ if(mysql_real_connect(pData->f_hmysql, pData->f_dbsrv, pData->f_dbuid, - pData->f_dbpwd, pData->f_dbname, 0, NULL, 0) == NULL) { + pData->f_dbpwd, pData->f_dbname, pData->f_dbsrvPort, NULL, 0) == NULL) { reportDBError(pData, bSilent); closeMySQL(pData); /* ignore any error we may get */ iRet = RS_RET_SUSPENDED; @@ -273,6 +278,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) errmsg.LogError(NO_ERRCODE, "Trouble with MySQL connection properties. -MySQL logging disabled"); ABORT_FINALIZE(RS_RET_INVALID_PARAMS); } else { + pData->f_dbsrvPort = (unsigned) iSrvPort; /* set configured port */ pData->f_hmysql = NULL; /* initialize, but connect only on first message (important for queued mode!) */ } @@ -291,12 +297,24 @@ CODEqueryEtryPt_STD_OMOD_QUERIES ENDqueryEtryPt +/* Reset config variables for this module to default values. + */ +static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal) +{ + DEFiRet; + iSrvPort = 0; /* zero is the default port */ + RETiRet; +} + BEGINmodInit() CODESTARTmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(errmsg, CORE_COMPONENT)); + /* register our config handlers */ + CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionommysqlserverport", 0, eCmdHdlrInt, NULL, &iSrvPort, STD_LOADABLE_MODULE_ID)); + CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID)); ENDmodInit -/* - * vi:set ai: + +/* vi:set ai: */ -- cgit v1.2.3