summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-08-12 16:08:09 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-08-12 16:08:09 +0200
commit02f768c37dac9dde424bbd31e378482750fc276c (patch)
tree440b44f612e4db65396da32af10caa5091f96013
parent018b2f4c86ca2e4849156db1b1d5b6b3ea9b3e0c (diff)
downloadrsyslog-02f768c37dac9dde424bbd31e378482750fc276c.tar.gz
rsyslog-02f768c37dac9dde424bbd31e378482750fc276c.tar.xz
rsyslog-02f768c37dac9dde424bbd31e378482750fc276c.zip
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.
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac2
-rw-r--r--doc/ommysql.html46
-rw-r--r--doc/rsyslog_conf.html2
-rw-r--r--plugins/ommysql/ommysql.c24
5 files changed, 73 insertions, 5 deletions
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 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+<meta http-equiv="Content-Language" content="en">
+<title>MySQL Database Output Module</title>
+</head>
+
+<body>
+<h1>MySQL Database Output Module</h1>
+<p><b>Module Name:&nbsp;&nbsp;&nbsp; ommysql</b></p>
+<p><b>Author: </b>Michael Meckelein (Initial Author) / Rainer Gerhards
+&lt;rgerhards@adiscon.com&gt;</p>
+<p><b>Description</b>:</p>
+<p>This module provides native support for logging to MySQL databases. It offers
+superior performance over the more generic <a href="omlibdbi.html">omlibdbi</a> module.
+</p>
+<p><b>Configuration Directives</b>:</p>
+<p>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.
+<ul>
+<li><b>$ActionOmmysqlServerPort &lt;port&gt;</b><br>Permits to select
+a non-standard port for the MySQL server. The default is 0, which means the
+system default port is used. There is no need to specify this directive unless
+you know the server is running on a non-standard listen port.
+<li>Action parameters:
+<br><b>:ommysql:database-server,database-name,database-userid,database-password</b>
+<br>All parameters should be filled in for a successful connect.
+</ul>
+<p><b>Sample:</b></p>
+<p>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".
+</p>
+<textarea rows="5" cols="80">$ModLoad ommysql
+$ActionOmmysqlServerPort 1234 # use non-standard port
+*.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :ommysql:mysqlserver.example.com,syslog_db,user,pwd
+</textarea>
+<p>[<a href="rsyslog_conf.html">rsyslog.conf overview</a>]
+[<a href="manual.html">manual index</a>] [<a href="http://www.rsyslog.com/">rsyslog site</a>]</p>
+<p><font size="2">This documentation is part of the
+<a href="http://www.rsyslog.com/">rsyslog</a>
+project.<br>
+Copyright &copy; 2008 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and
+<a href="http://www.adiscon.com/">Adiscon</a>.
+Released under the GNU GPL version 3 or higher.</font></p>
+</body></html>
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</li>
<li><a href="omrelp.html">omrelp</a> - RELP
output module</li>
<li>omgss - output module for GSS-enabled syslog</li>
-<li>ommysql - output module for MySQL</li>
+<li><a href="ommysql.html">ommysql</a> - output module for MySQL</li>
<li>ompgsql - output module for PostgreSQL</li>
<li><a href="omlibdbi.html">omlibdbi</a> -
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:
*/