1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
*************************************
ommysql: MySQL Database Output Module
*************************************
=========================== ===========================================================================
**Module Name:** **ommysql**
**Author:** Michael Meckelein (Initial Author) / `Rainer Gerhards <https://rainer.gerhards.net/>`_ <rgerhards@adiscon.com>
=========================== ===========================================================================
Purpose
=======
This module provides native support for logging to MySQL databases. It
offers superior performance over the more generic
`omlibdbi <omlibdbi.html>`_ module.
Configuration Parameters
========================
.. note::
Parameter names are case-insensitive.
Action Parameters
-----------------
Server
^^^^^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"word", "none", "yes", "none"
This is the address of the MySQL-Server.
Socket
^^^^^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"word", "none", "no", "none"
This is the unix socket path of the MySQL-Server. When the server
address is set localhost, the mysql client library connects using
the default unix socket specified at build time.
If you run mysql server and run the unix socket path differently
than the default, you can set the socket path with this option.
db
^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"word", "none", "yes", "none"
This is the name of the database used.
UID
^^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"word", "none", "yes", "none"
This is the user who is used.
PWD
^^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"word", "none", "yes", "none"
This is the password for the user specified in UID.
ServerPort
^^^^^^^^^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"integer", "none", "no", "``$ActionOmmysqlServerPort``"
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 parameter unless you know the server is
running on a non-standard listen port.
MySQLConfig.File
^^^^^^^^^^^^^^^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"word", "none", "no", "``$OmMySQLConfigFile``"
Permits the selection of an optional MySQL Client Library
configuration file (my.cnf) for extended configuration functionality.
The use of this configuration parameter is necessary only if you have
a non-standard environment or if fine-grained control over the
database connection is desired.
MySQLConfig.Section
^^^^^^^^^^^^^^^^^^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"word", "none", "no", "``$OmMySQLConfigSection``"
Permits the selection of the section within the configuration file
specified by the **$OmMySQLConfigFile** parameter.
This will likely only be used where the database administrator
provides a single configuration file with multiple profiles.
This configuration parameter is ignored unless **$OmMySQLConfigFile**
is also used in the rsyslog configuration file.
If omitted, the MySQL Client Library default of "client" will be
used.
Template
^^^^^^^^
.. csv-table::
:header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
:widths: auto
:class: parameter-table
"word", "StdDBFmt", "no", "none"
Rsyslog contains a canned default template to write to the MySQL
database. It works on the MonitorWare schema. This template is:
.. code-block:: none
$template tpl,"insert into SystemEvents (Message, Facility, FromHost,
Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values
('%msg%', %syslogfacility%, '%HOSTNAME%', %syslogpriority%,
'%timereported:::date-mysql%', '%timegenerated:::date-mysql%', %iut%,
'%syslogtag%')",SQL
As you can see, the template is an actual SQL statement. Note the ",SQL"
option: it tells the template processor that the template is used for
SQL processing, thus quote characters are quoted to prevent security
issues. You can not assign a template without ",SQL" to a MySQL output
action.
If you would like to change fields contents or add or delete your own
fields, you can simply do so by modifying the schema (if required) and
creating your own custom template.
Examples
========
Example 1
---------
The following sample writes all syslog messages to the database
"syslog_db" on mysqlserver.example.com. The server is being accessed
under the account of "user" with password "pwd".
.. code-block:: none
module(load="ommysql")
action(type="ommysql" server="mysqlserver.example.com" serverport="1234"
db="syslog_db" uid="user" pwd="pwd")
|