├── .gitignore ├── LICENSE ├── README.md └── src ├── Makefile.am ├── configure.ac └── contrib └── mmgrok ├── Makefile.am └── mmgrok.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rsyslog-mmgrok 2 | 3 | Rsyslog 可以通过 rainerscript 和 mmnoramlize 模块对日志数据做一定的切割解析。但是 mmnormalize 的 rulebase 表达式和传统的正则表达式差异很大,功能有局限,而且可读性不高,大多数人不愿意使用。 4 | 5 | Logstash 自带的 Grok 正则,在标准正则表达式基础上,添加了预定义表达式的功能,随着 ELK Stack 的流行 Grok 接受程度也在逐渐提高。logstash-patterns-core 附带了数百种预定义表达式,很大程度上帮助了对正则表达式不算精通的运维人员。 6 | 7 | rsyslog-mmgrok 插件,用来在 rsyslog 中,使用 grok 正则处理数据。 8 | 9 | ## 编译 10 | 11 | 0. 安装 libgrok 库: 12 | ``` 13 | # MacOS 上可以直接安装 14 | port install grok 15 | # CentOS 上没有现成的,需要自己编译 16 | git clone git@github.com:jordansissel/grok.git 17 | rpm -bb grok.spec.template 18 | # 使用 yum 而不是 rpm,因为 grok 有 libevent, pcre, tokyocabinet 依赖 19 | yum install grok*.rpm 20 | ``` 21 | 1. 下载 rsyslog 源码包: 22 | ``` 23 | git clone https://github.com/rsyslog/rsyslog.git 24 | ``` 25 | 2. 复制本仓库源码文件到 rsyslog 源码目录内: 26 | ``` 27 | cp -r src/contrib/mmgrok ../rsyslog/contrib/ 28 | cp src/configure.ac ../rsyslog/ 29 | cp src/Makefile.am ../rsyslog/ 30 | ``` 31 | 3. 编译 rsyslog: 32 | ``` 33 | yum install -y libjson-c-devel glib-devel 34 | export PKG_CONFIG_PATH=/lib64/pkgconfig/ 35 | autoconf 36 | ./configure --enable-mmgrok 37 | make 38 | make install 39 | ``` 40 | 41 | ## 配置示例 42 | 43 | ``` 44 | module(load="mmgrok") 45 | action(type="mmgrok" patterndir="path/to/yourpatternsDir" match="%{WORD:test}" source="msg" target="!msg") 46 | template(name="tmlp" type="string" string="%$!msg!test%\n") 47 | action(type="omfile" file="path/to/file" template="tmlp") 48 | ``` 49 | 50 | ## 参数说明 51 | * patterndir: grok模板路径(默认/usr/share/grok/patterns/base) 52 | * match:grok使用的匹配模板,在/usr/share/grok/patterns/base文件下可以查看预定义的模板 53 | * source: 所要解析的源消息 54 | * target : grok解析后的消息为json tree,target参数指定了json tree的root 55 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | sbin_PROGRAMS = 2 | pkglib_LTLIBRARIES = 3 | 4 | pkgconfigdir = $(libdir)/pkgconfig 5 | 6 | # 7 | # systemd support 8 | # 9 | if HAVE_SYSTEMD 10 | 11 | nodist_systemdsystemunit_DATA = \ 12 | rsyslog.service 13 | 14 | CLEANFILES = \ 15 | rsyslog.service 16 | 17 | %.service: %.service.in 18 | $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ 19 | 20 | endif 21 | 22 | EXTRA_DIST = \ 23 | README.md \ 24 | platform/README \ 25 | platform/freebsd/rsyslogd \ 26 | platform/slackware/rc.rsyslogd \ 27 | platform/redhat/rsyslog.conf \ 28 | contrib/README \ 29 | CONTRIBUTING.md \ 30 | COPYING \ 31 | COPYING.LESSER \ 32 | COPYING.ASL20 \ 33 | contrib/gnutls/ca.pem \ 34 | contrib/gnutls/cert.pem \ 35 | contrib/gnutls/key.pem \ 36 | rsyslog.service.in 37 | 38 | SUBDIRS = compat runtime grammar . plugins/immark plugins/imuxsock plugins/imtcp plugins/imudp plugins/omtesting 39 | # external plugin driver is always enabled (core component) 40 | SUBDIRS += plugins/mmexternal 41 | 42 | if ENABLE_RSYSLOGD 43 | SUBDIRS += tools 44 | endif 45 | 46 | if ENABLE_IMKLOG 47 | SUBDIRS += plugins/imklog 48 | endif 49 | 50 | if ENABLE_IMKMSG 51 | SUBDIRS += contrib/imkmsg 52 | endif 53 | 54 | if ENABLE_IMPSTATS 55 | SUBDIRS += plugins/impstats 56 | endif 57 | 58 | if ENABLE_IMSOLARIS 59 | SUBDIRS += plugins/imsolaris 60 | endif 61 | 62 | if ENABLE_GSSAPI 63 | SUBDIRS += plugins/omgssapi plugins/imgssapi 64 | endif 65 | 66 | if ENABLE_RELP 67 | SUBDIRS += plugins/omrelp plugins/imrelp 68 | endif 69 | 70 | if ENABLE_MYSQL 71 | SUBDIRS += plugins/ommysql 72 | endif 73 | 74 | if ENABLE_OMLIBDBI 75 | SUBDIRS += plugins/omlibdbi 76 | endif 77 | 78 | if ENABLE_PGSQL 79 | SUBDIRS += plugins/ompgsql 80 | endif 81 | 82 | if ENABLE_SNMP 83 | SUBDIRS += plugins/omsnmp 84 | endif 85 | 86 | if ENABLE_OMSTDOUT 87 | SUBDIRS += plugins/omstdout 88 | endif 89 | 90 | if ENABLE_PMCISCONAMES 91 | SUBDIRS += contrib/pmcisconames 92 | endif 93 | 94 | if ENABLE_PMCISCOIOS 95 | SUBDIRS += plugins/pmciscoios 96 | endif 97 | 98 | if ENABLE_PMAIXFORWARDEDFROM 99 | SUBDIRS += contrib/pmaixforwardedfrom 100 | endif 101 | 102 | if ENABLE_PMSNARE 103 | SUBDIRS += contrib/pmsnare 104 | endif 105 | 106 | if ENABLE_PMLASTMSG 107 | SUBDIRS += plugins/pmlastmsg 108 | endif 109 | 110 | if ENABLE_OMRULESET 111 | SUBDIRS += plugins/omruleset 112 | endif 113 | 114 | if ENABLE_OMUDPSPOOF 115 | SUBDIRS += plugins/omudpspoof 116 | endif 117 | 118 | if ENABLE_OMMONGODB 119 | SUBDIRS += plugins/ommongodb 120 | endif 121 | 122 | if ENABLE_OMHIREDIS 123 | SUBDIRS += contrib/omhiredis 124 | endif 125 | 126 | if ENABLE_OMZMQ3 127 | SUBDIRS += contrib/omzmq3 128 | endif 129 | 130 | if ENABLE_OMCZMQ 131 | SUBDIRS += contrib/omczmq 132 | endif 133 | 134 | if ENABLE_OMRABBITMQ 135 | SUBDIRS += contrib/omrabbitmq 136 | endif 137 | 138 | if ENABLE_IMZMQ3 139 | SUBDIRS += contrib/imzmq3 140 | endif 141 | 142 | if ENABLE_IMCZMQ 143 | SUBDIRS += contrib/imczmq 144 | endif 145 | 146 | if ENABLE_OMUXSOCK 147 | SUBDIRS += plugins/omuxsock 148 | endif 149 | 150 | if ENABLE_OMHDFS 151 | SUBDIRS += plugins/omhdfs 152 | endif 153 | 154 | if ENABLE_OMJOURNAL 155 | SUBDIRS += plugins/omjournal 156 | endif 157 | 158 | if ENABLE_IMJOURNAL 159 | SUBDIRS += plugins/imjournal 160 | endif 161 | 162 | if ENABLE_ELASTICSEARCH 163 | SUBDIRS += plugins/omelasticsearch 164 | endif 165 | 166 | if ENABLE_MMSNMPTRAPD 167 | SUBDIRS += plugins/mmsnmptrapd 168 | endif 169 | 170 | if ENABLE_IMFILE 171 | SUBDIRS += plugins/imfile 172 | endif 173 | 174 | if ENABLE_IMPTCP 175 | SUBDIRS += plugins/imptcp 176 | endif 177 | 178 | if ENABLE_IMDIAG 179 | SUBDIRS += plugins/imdiag 180 | endif 181 | 182 | if ENABLE_MAIL 183 | SUBDIRS += plugins/ommail 184 | endif 185 | 186 | if ENABLE_OMKAFKA 187 | SUBDIRS += plugins/omkafka 188 | endif 189 | 190 | if ENABLE_OMPROG 191 | SUBDIRS += plugins/omprog 192 | endif 193 | 194 | if ENABLE_RFC3195 195 | SUBDIRS += plugins/im3195 196 | endif 197 | 198 | if ENABLE_MMNORMALIZE 199 | SUBDIRS += plugins/mmnormalize 200 | endif 201 | 202 | if ENABLE_MMJSONPARSE 203 | SUBDIRS += plugins/mmjsonparse 204 | endif 205 | 206 | 207 | if ENABLE_MMGROK 208 | SUBDIRS += plugins/mmgrok 209 | endif 210 | 211 | if ENABLE_MMAUDIT 212 | SUBDIRS += plugins/mmaudit 213 | endif 214 | 215 | if ENABLE_MMANON 216 | SUBDIRS += plugins/mmanon 217 | endif 218 | 219 | if ENABLE_MMUTF8FIX 220 | SUBDIRS += plugins/mmutf8fix 221 | endif 222 | 223 | if ENABLE_MMCOUNT 224 | SUBDIRS += contrib/mmcount 225 | endif 226 | 227 | if ENABLE_MMSEQUENCE 228 | SUBDIRS += contrib/mmsequence 229 | endif 230 | 231 | if ENABLE_MMFIELDS 232 | SUBDIRS += plugins/mmfields 233 | endif 234 | 235 | if ENABLE_MMPSTRUCDATA 236 | SUBDIRS += plugins/mmpstrucdata 237 | endif 238 | 239 | if ENABLE_MMRFC5424ADDHMAC 240 | SUBDIRS += contrib/mmrfc5424addhmac 241 | endif 242 | 243 | # omhttpfs 244 | if ENABLE_OMHTTPFS 245 | SUBDIRS += contrib/omhttpfs 246 | endif 247 | 248 | # tests are added as last element, because tests may need different 249 | # modules that need to be generated first 250 | SUBDIRS += tests 251 | 252 | 253 | 254 | # make sure "make distcheck" tries to build all modules. This means that 255 | # a developer must always have an environment where every supporting library 256 | # is available. If that is not the case, the respective configure option may 257 | # temporarily be removed below. The intent behind forcing everthing to compile 258 | # in a make distcheck is so that we detect code that accidently was not updated 259 | # when some global update happened. 260 | DISTCHECK_CONFIGURE_FLAGS= \ 261 | --disable-silent-rules \ 262 | --disable-testbench 263 | 264 | THIS_IS_TEMPORARILY_DISABLED = \ 265 | --enable-distcheck-workaround \ 266 | --enable-testbench \ 267 | --enable-imdiag \ 268 | --enable-testbench \ 269 | --enable-imfile \ 270 | --enable-snmp \ 271 | --enable-libdbi \ 272 | --enable-mysql \ 273 | --enable-relp \ 274 | --enable-rsyslogd \ 275 | --enable-mail \ 276 | --enable-klog \ 277 | --enable-diagtools \ 278 | --enable-mmgrok \ 279 | --enable-gnutls \ 280 | --enable-omstdout \ 281 | --enable-pmlastmsg \ 282 | --enable-omruleset \ 283 | --enable-omprog \ 284 | --enable-imptcp \ 285 | --enable-omuxsock \ 286 | --enable-impstats \ 287 | --enable-memcheck \ 288 | --enable-pmaixforwardedfrom \ 289 | --enable-pmcisconames \ 290 | --enable-pmsnare \ 291 | --enable-elasticsearch \ 292 | --enable-valgrind \ 293 | --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) 294 | # temporarily disable these checks for make distcheck 2012-09-06 rgerhards 295 | # --enable-mmsnmptrapd \ 296 | # --enable-gssapi_krb5 \ 297 | # --enable-extended-tests \ 298 | # --enable-pgsql 299 | 300 | dist-hook: 301 | $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version 302 | 303 | ACLOCAL_AMFLAGS = -I m4 304 | -------------------------------------------------------------------------------- /src/configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ(2.61) 5 | AC_INIT([rsyslog],[8.14.0.master],[rsyslog@lists.adiscon.com]) 6 | AM_INIT_AUTOMAKE([subdir-objects]) 7 | 8 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 9 | 10 | AC_CONFIG_SRCDIR([ChangeLog]) 11 | AC_CONFIG_MACRO_DIR([m4]) 12 | AC_CONFIG_HEADERS([config.h]) 13 | 14 | AC_USE_SYSTEM_EXTENSIONS 15 | 16 | # Checks for programs. 17 | AC_PROG_LEX 18 | AC_PROG_YACC 19 | AC_PROG_CC 20 | AC_PROG_CC_C99 21 | AC_DISABLE_STATIC 22 | AC_PROG_LIBTOOL 23 | AC_CANONICAL_HOST 24 | 25 | PKG_PROG_PKG_CONFIG 26 | 27 | # modules we require 28 | PKG_CHECK_MODULES(LIBESTR, libestr >= 0.1.9) 29 | PKG_CHECK_MODULES([JSON_C], [json],, [ 30 | PKG_CHECK_MODULES([JSON_C], [json-c],,) 31 | ]) 32 | 33 | save_CFLAGS="$CFLAGS" 34 | save_LIBS="$LIBS" 35 | 36 | CFLAGS="$CFLAGS $JSON_C_CFLAGS" 37 | LIBS="$LIBS $JSON_C_LIBS" 38 | 39 | # if int64 is supported, use it 40 | AC_CHECK_LIB(json-c, json_object_new_object,,) 41 | AC_CHECK_FUNCS(json_object_new_int64,,) 42 | 43 | # look for newer API 44 | AC_CHECK_FUNCS(json_tokener_error_desc,,) 45 | AC_CHECK_FUNCS(json_object_object_get_ex,,) 46 | AC_CHECK_FUNCS(json_object_to_json_string_ext,,) 47 | AC_CHECK_TYPES([json_bool],,,[[#include ]]) 48 | 49 | CFLAGS="$save_CFLAGS" 50 | LIBS="$save_LIBS" 51 | 52 | AC_DEFINE_UNQUOTED([PLATFORM_ID], ["${host}"], [platform id for display purposes]) 53 | # we don't mind if we don't have the lsb_release utility. But if we have, it's 54 | # nice to have the extra information. 55 | AC_DEFINE_UNQUOTED([PLATFORM_ID_LSB], ["`lsb_release -d`"], [platform id for display purposes]) 56 | 57 | case "${host}" in 58 | *-*-linux*) 59 | AC_DEFINE([OS_LINUX], [1], [Indicator for a Linux OS]) 60 | os_type="linux" 61 | ;; 62 | *-*-*darwin*|*-*-dragonfly*|*-*-freebsd*|*-*-netbsd*|*-*-openbsd*) 63 | AC_DEFINE([OS_BSD], [1], [Indicator for a BSD OS]) 64 | os_type="bsd" 65 | ;; 66 | *-*-kfreebsd*) 67 | # kernel is FreeBSD, but userspace is glibc - i.e. like linux 68 | # do not DEFINE OS_BSD 69 | os_type="bsd" 70 | ;; 71 | *-*-solaris*) 72 | os_type="solaris" 73 | AC_DEFINE([OS_SOLARIS], [1], [Indicator for a Solaris OS]) 74 | AC_DEFINE([_POSIX_PTHREAD_SEMANTICS], [1], [Use POSIX pthread semantics]) 75 | AC_DEFINE([_XOPEN_SOURCE], [600], [Use X/Open CAE Specification]) 76 | SOL_LIBS="-lsocket -lnsl" 77 | # Solaris libuuid does not ship with a pkgconfig file so override the appropriate 78 | # variables (but only if they have not been set by the user). 79 | LIBUUID_CFLAGS=${LIBUUID_CFLAGS:= } 80 | LIBUUID_LIBS=${LIBUUID_LIBS:=-luuid} 81 | AC_SUBST(SOL_LIBS) 82 | ;; 83 | esac 84 | 85 | AC_DEFINE_UNQUOTED([HOSTENV], "$host", [the host environment, can be queried via a system variable]) 86 | 87 | # Checks for libraries. 88 | save_LIBS=$LIBS 89 | LIBS= 90 | AC_SEARCH_LIBS(clock_gettime, rt) 91 | RT_LIBS=$LIBS 92 | AC_SEARCH_LIBS(mq_getattr, rt) 93 | RT_LIBS="$RT_LIBS $LIBS" 94 | LIBS= 95 | AC_SEARCH_LIBS(dlopen, dl) 96 | DL_LIBS=$LIBS 97 | LIBS=$save_LIBS 98 | 99 | AC_SUBST(RT_LIBS) 100 | AC_SUBST(DL_LIBS) 101 | 102 | # Checks for header files. 103 | AC_HEADER_RESOLV 104 | AC_HEADER_STDC 105 | AC_HEADER_SYS_WAIT 106 | AC_CHECK_HEADERS([arpa/inet.h libgen.h malloc.h fcntl.h locale.h netdb.h netinet/in.h paths.h stddef.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h sys/stat.h sys/inotify.h unistd.h utmp.h utmpx.h sys/epoll.h sys/prctl.h]) 107 | 108 | # Checks for typedefs, structures, and compiler characteristics. 109 | AC_C_CONST 110 | AC_C_INLINE 111 | AC_TYPE_OFF_T 112 | AC_TYPE_PID_T 113 | AC_TYPE_SIZE_T 114 | AC_TYPE_SSIZE_T 115 | AC_TYPE_MODE_T 116 | AC_TYPE_UID_T 117 | AC_TYPE_UINT8_T 118 | AC_HEADER_TIME 119 | AC_STRUCT_TM 120 | AC_C_VOLATILE 121 | 122 | sa_includes="\ 123 | $ac_includes_default 124 | #if HAVE_SYS_SOCKET_H 125 | # include 126 | #endif 127 | " 128 | AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[$sa_includes]) 129 | 130 | # Checks for library functions. 131 | AC_FUNC_CHOWN 132 | AC_FUNC_FORK 133 | AC_PROG_GCC_TRADITIONAL 134 | AC_FUNC_MALLOC 135 | AC_FUNC_REALLOC 136 | AC_FUNC_SELECT_ARGTYPES 137 | AC_TYPE_SIGNAL 138 | AC_FUNC_STAT 139 | AC_FUNC_STRERROR_R 140 | AC_FUNC_VPRINTF 141 | AC_CHECK_FUNCS([flock inotify_init recvmmsg basename alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setsid socket strcasecmp strchr strdup strerror strndup strnlen strrchr strstr strtol strtoul uname ttyname_r getline malloc_trim prctl epoll_create epoll_create1 fdatasync syscall lseek64]) 142 | AC_CHECK_TYPES([off64_t]) 143 | 144 | # getifaddrs is in libc (mostly) or in libsocket (eg Solaris 11) or not defined (eg Solaris 10) 145 | AC_SEARCH_LIBS([getifaddrs], [socket], [AC_DEFINE(HAVE_GETIFADDRS, [1], [set define])]) 146 | 147 | # the check below is probably ugly. If someone knows how to do it in a better way, please 148 | # let me know! -- rgerhards, 2010-10-06 149 | AC_CHECK_DECL([SCM_CREDENTIALS], [AC_DEFINE(HAVE_SCM_CREDENTIALS, [1], [set define])], [], [#include 150 | #include ]) 151 | AC_CHECK_DECL([SO_TIMESTAMP], [AC_DEFINE(HAVE_SO_TIMESTAMP, [1], [set define])], [], [#include 152 | #include ]) 153 | AC_CHECK_DECL([SYS_gettid], [AC_DEFINE(HAVE_SYS_gettid, [1], [set define])], [], [#include ]) 154 | AC_CHECK_MEMBER([struct sysinfo.uptime], [AC_DEFINE(HAVE_SYSINFO_UPTIME, [1], [set define])], [], [#include ]) 155 | AC_CHECK_DECL([GLOB_NOMAGIC], [AC_DEFINE(HAVE_GLOB_NOMAGIC, [1], [set define])], [], [#include ]) 156 | 157 | # Check for MAXHOSTNAMELEN 158 | AC_MSG_CHECKING(for MAXHOSTNAMELEN) 159 | AC_TRY_COMPILE([ 160 | #include 161 | ], [ 162 | return MAXHOSTNAMELEN; 163 | ] 164 | , 165 | AC_MSG_RESULT(yes) 166 | , 167 | # note: we use 1024 here, which should be far more than needed by any system. If that's too low, we simply 168 | # life with the need to change it. Most of the code doesn't need it anyways, but there are a few places 169 | # where it actually is needed and it makes no sense to change them. 170 | AC_DEFINE(MAXHOSTNAMELEN, 1024, [Define with a value if your does not define MAXHOSTNAMELEN]) 171 | AC_MSG_RESULT(no; defined as 64) 172 | ) 173 | 174 | # Check for __builtin_expect() 175 | AC_MSG_CHECKING([for __builtin_expect()]) 176 | AC_LINK_IFELSE([AC_LANG_PROGRAM(, return __builtin_expect(main != 0, 1))], 177 | [AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, 178 | Define to 1 if compiler supports __builtin_expect) 179 | AC_MSG_RESULT([yes])], 180 | [AC_MSG_RESULT([no])]) 181 | 182 | # check for availability of atomic operations 183 | RS_ATOMIC_OPERATIONS 184 | RS_ATOMIC_OPERATIONS_64BIT 185 | 186 | # fall back to POSIX sems for atomic operations (cpu expensive) 187 | AC_CHECK_HEADERS([semaphore.h sys/syscall.h]) 188 | 189 | 190 | # Additional module directories 191 | AC_ARG_WITH(moddirs, 192 | [AS_HELP_STRING([--with-moddirs=DIRS],[Additional module search paths appended to @<:@$libdir/rsyslog@:>@])], 193 | [_save_IFS=$IFS ; IFS=$PATH_SEPARATOR ; moddirs="" 194 | for w in ${with_moddirs} ; 195 | do 196 | case $w in 197 | "") continue ;; */) ;; *) w="${w}/" ;; 198 | esac 199 | for m in ${moddirs} ; 200 | do 201 | test "x$w" = "x${libdir}/${PACKAGE}/" || \ 202 | test "x$w" = "x$m" || test "x$w" = "x/" && \ 203 | continue 2 204 | done 205 | case $moddirs in 206 | "") moddirs="$w" ;; *) moddirs="${moddirs}:${w}" ;; 207 | esac 208 | done ; IFS=$_save_IFS],[moddirs=""] 209 | ) 210 | AM_CONDITIONAL(WITH_MODDIRS, test x$moddirs != x) 211 | AC_SUBST(moddirs) 212 | 213 | 214 | # Large file support 215 | # http://www.gnu.org/software/autoconf/manual/html_node/System-Services.html#index-AC_005fSYS_005fLARGEFILE-1028 216 | AC_SYS_LARGEFILE 217 | case "${enable_largefile}" in 218 | no) ;; 219 | *) enable_largefile="yes" ;; 220 | esac 221 | 222 | # Regular expressions 223 | AC_ARG_ENABLE(regexp, 224 | [AS_HELP_STRING([--enable-regexp],[Enable regular expressions support @<:@default=yes@:>@])], 225 | [case "${enableval}" in 226 | yes) enable_regexp="yes" ;; 227 | no) enable_regexp="no" ;; 228 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-regexp) ;; 229 | esac], 230 | [enable_regexp=yes] 231 | ) 232 | AM_CONDITIONAL(ENABLE_REGEXP, test x$enable_regexp = xyes) 233 | if test "$enable_regexp" = "yes"; then 234 | AC_DEFINE(FEATURE_REGEXP, 1, [Regular expressions support enabled.]) 235 | fi 236 | 237 | 238 | # zlib support 239 | PKG_CHECK_MODULES([ZLIB], [zlib], [found_zlib=yes], [found_zlib=no]) 240 | AS_IF([test "x$found_zlib" = "xno"], [ 241 | AC_SEARCH_LIBS([inflate], [z], [AC_CHECK_HEADER([zlib.h], [found_zlib=yes])]) 242 | if test "x$found_zlib" = "xno" ; then 243 | AC_MSG_ERROR([zlib library and headers not found]) 244 | fi 245 | ZLIB_LIBS="-lz" 246 | AC_SUBST(ZLIB_LIBS) 247 | ]) 248 | 249 | 250 | #gssapi 251 | AC_ARG_ENABLE(gssapi_krb5, 252 | [AS_HELP_STRING([--enable-gssapi-krb5],[Enable GSSAPI Kerberos 5 support @<:@default=no@:>@])], 253 | [case "${enableval}" in 254 | yes) enable_gssapi_krb5="yes" ;; 255 | no) enable_gssapi_krb5="no" ;; 256 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-gssapi-krb5) ;; 257 | esac], 258 | [enable_gssapi_krb5=no] 259 | ) 260 | if test $enable_gssapi_krb5 = yes; then 261 | AC_CHECK_LIB(gssapi_krb5, gss_acquire_cred, [ 262 | AC_CHECK_HEADER(gssapi/gssapi.h, [ 263 | AC_DEFINE(USE_GSSAPI,, 264 | Define if you want to use GSSAPI) 265 | GSS_LIBS="-lgssapi_krb5" 266 | AC_SUBST(GSS_LIBS) 267 | ]) 268 | ]) 269 | fi 270 | AM_CONDITIONAL(ENABLE_GSSAPI, test x$enable_gssapi_krb5 = xyes) 271 | 272 | 273 | # multithreading via pthreads 274 | AC_CHECK_HEADERS( 275 | [pthread.h], 276 | [ 277 | AC_CHECK_LIB( 278 | [pthread], 279 | [pthread_create], 280 | [ 281 | AC_DEFINE([USE_PTHREADS], [1], [Multithreading support enabled.]) 282 | PTHREADS_LIBS="-lpthread" 283 | case "${os_type}" in 284 | solaris) PTHREADS_CFLAGS="-pthreads" ;; 285 | *) PTHREADS_CFLAGS="-pthread" ;; 286 | esac 287 | AC_SUBST(PTHREADS_LIBS) 288 | AC_SUBST(PTHREADS_CFLAGS) 289 | ], 290 | [AC_MSG_FAILURE([pthread is missing])], 291 | [-lpthread] 292 | ) 293 | ], 294 | [AC_MSG_FAILURE([pthread is missing])] 295 | ) 296 | 297 | AC_CHECK_FUNCS( 298 | [pthread_setschedparam], 299 | [ 300 | rsyslog_have_pthread_setschedparam=yes 301 | ], 302 | [ 303 | rsyslog_have_pthread_setschedparam=no 304 | ] 305 | ) 306 | AC_CHECK_HEADERS( 307 | [sched.h], 308 | [ 309 | rsyslog_have_sched_h=yes 310 | ], 311 | [ 312 | rsyslog_have_sched_h=no 313 | ] 314 | ) 315 | if test "$rsyslog_have_pthread_setschedparam" = "yes" -a "$rsyslog_have_sched_h" = "yes"; then 316 | save_LIBS=$LIBS 317 | LIBS= 318 | AC_SEARCH_LIBS(sched_get_priority_max, rt) 319 | if test "x$ac_cv_search" != "xno"; then 320 | AC_CHECK_FUNCS(sched_get_priority_max) 321 | fi 322 | IMUDP_LIBS=$LIBS 323 | AC_SUBST(IMUDP_LIBS) 324 | LIBS=$save_LIBS 325 | fi 326 | 327 | 328 | # klog 329 | AC_ARG_ENABLE(klog, 330 | [AS_HELP_STRING([--enable-klog],[Integrated klog functionality @<:@default=yes@:>@])], 331 | [case "${enableval}" in 332 | yes) enable_klog="yes" ;; 333 | no) enable_klog="no" ;; 334 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-klog) ;; 335 | esac], 336 | [enable_klog="yes"] 337 | ) 338 | AM_CONDITIONAL(ENABLE_IMKLOG, test x$enable_klog = xyes) 339 | AM_CONDITIONAL(ENABLE_IMKLOG_BSD, test x$os_type = xbsd) 340 | AM_CONDITIONAL(ENABLE_IMKLOG_LINUX, test x$os_type = xlinux) 341 | AM_CONDITIONAL(ENABLE_IMKLOG_SOLARIS, test x$os_type = xsolaris) 342 | 343 | # kmsg 344 | AC_ARG_ENABLE(kmsg, 345 | [AS_HELP_STRING([--enable-kmsg],[Kmsg structured kernel logs functionality @<:@default=no@:>@])], 346 | [case "${enableval}" in 347 | yes) enable_kmsg="yes" ;; 348 | no) enable_kmsg="no" ;; 349 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-kmsg) ;; 350 | esac], 351 | [enable_kmsg="no"] 352 | ) 353 | AM_CONDITIONAL(ENABLE_IMKMSG, test x$enable_kmsg = xyes) 354 | 355 | # imjournal 356 | AC_ARG_ENABLE(imjournal, 357 | [AS_HELP_STRING([--enable-imjournal],[Systemd journal message import @<:@default=no@:>@])], 358 | [case "${enableval}" in 359 | yes) enable_imjournal="yes" ;; 360 | no) enable_imjournal="no" ;; 361 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-imjournal) ;; 362 | esac], 363 | [enable_imjournal="no"] 364 | ) 365 | if test "x$enable_imjournal" = "xyes"; then 366 | PKG_CHECK_MODULES([LIBSYSTEMD_JOURNAL], [libsystemd >= 209] ,, [ 367 | PKG_CHECK_MODULES([LIBSYSTEMD_JOURNAL], [libsystemd-journal >= 197]) 368 | ]) 369 | fi 370 | AM_CONDITIONAL(ENABLE_IMJOURNAL, test x$enable_imjournal = xyes) 371 | 372 | # inet 373 | AC_ARG_ENABLE(inet, 374 | [AS_HELP_STRING([--enable-inet],[Enable networking support @<:@default=yes@:>@])], 375 | [case "${enableval}" in 376 | yes) enable_inet="yes" ;; 377 | no) enable_inet="no" ;; 378 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-inet) ;; 379 | esac], 380 | [enable_inet="yes"] 381 | ) 382 | AM_CONDITIONAL(ENABLE_INET, test x$enable_inet = xyes) 383 | if test "$enable_inet" = "yes"; then 384 | AC_DEFINE(SYSLOG_INET, 1, [network support is integrated.]) 385 | fi 386 | 387 | # jemalloc 388 | AC_ARG_ENABLE(jemalloc, 389 | [AS_HELP_STRING([--enable-jemalloc],[Enable jemalloc support @<:@default=no@:>@])], 390 | [case "${enableval}" in 391 | yes) enable_jemalloc="yes" ;; 392 | no) enable_jemalloc="no" ;; 393 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-jemalloc) ;; 394 | esac], 395 | [enable_jemalloc="no"] 396 | ) 397 | AM_CONDITIONAL(ENABLE_JEMALLOC, test x$enable_jemalloc = xyes) 398 | if test "$enable_jemalloc" = "yes"; then 399 | AC_CHECK_LIB( 400 | [jemalloc], 401 | [malloc_stats_print], 402 | [RT_LIBS="$RT_LIBS -ljemalloc" 403 | AC_DEFINE(HAVE_JEMALLOC, 1, [jemalloc support is integrated.]) 404 | ], 405 | [AC_MSG_FAILURE([jemalloc library is missing])], 406 | [] 407 | ) 408 | fi 409 | 410 | 411 | # support for unlimited select() syscall 412 | AC_ARG_ENABLE(unlimited_select, 413 | [AS_HELP_STRING([--enable-unlimited-select],[Enable unlimited select() syscall @<:@default=no@:>@])], 414 | [case "${enableval}" in 415 | yes) enable_unlimited_select="yes" ;; 416 | no) enable_unlimited_select="no" ;; 417 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-unlimited-select) ;; 418 | esac], 419 | [enable_unlimited_select="no"] 420 | ) 421 | if test "$enable_unlimited_select" = "yes"; then 422 | AC_DEFINE(USE_UNLIMITED_SELECT, 1, [If defined, the select() syscall won't be limited to a particular number of file descriptors.]) 423 | fi 424 | 425 | 426 | # support for systemd unit files 427 | AC_ARG_WITH([systemdsystemunitdir], 428 | AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]), 429 | [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]) 430 | if test "x$with_systemdsystemunitdir" != xno; then 431 | AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) 432 | fi 433 | AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) 434 | 435 | 436 | # debug 437 | AC_ARG_ENABLE(debug, 438 | [AS_HELP_STRING([--enable-debug],[Enable debug mode @<:@default=no@:>@])], 439 | [case "${enableval}" in 440 | yes) enable_debug="yes" ;; 441 | no) enable_debug="no" ;; 442 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; 443 | esac], 444 | [enable_debug="no"] 445 | ) 446 | if test "$enable_debug" = "yes"; then 447 | AC_DEFINE(DEBUG, 1, [Defined if debug mode is enabled (its easier to check).]) 448 | fi 449 | if test "$enable_debug" = "no"; then 450 | AC_DEFINE(NDEBUG, 1, [Defined if debug mode is disabled.]) 451 | fi 452 | 453 | 454 | # debug-symbols 455 | AC_ARG_ENABLE(debug_symbols, 456 | [AS_HELP_STRING([--disable-debug-symbols],[Disable debugging symbols @<:@default=no@:>@])], 457 | [case "${enableval}" in 458 | yes) enable_debug_symbols="yes" ;; 459 | no) enable_debug_symbols="no" ;; 460 | *) AC_MSG_ERROR(bad value ${enableval} for --disable-debug-symbols) ;; 461 | esac], 462 | [enable_debug_symbols="yes"] 463 | ) 464 | 465 | 466 | # runtime instrumentation 467 | AC_ARG_ENABLE(rtinst, 468 | [AS_HELP_STRING([--enable-rtinst],[Enable runtime instrumentation mode @<:@default=no@:>@])], 469 | [case "${enableval}" in 470 | yes) enable_rtinst="yes" ;; 471 | no) enable_rtinst="no" ;; 472 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-rtinst) ;; 473 | esac], 474 | [enable_rtinst="no"] 475 | ) 476 | if test "$enable_rtinst" = "yes"; then 477 | AC_DEFINE(RTINST, 1, [Defined if runtime instrumentation mode is enabled.]) 478 | fi 479 | 480 | 481 | # total debugless: highest performance, but no way at all to enable debug 482 | # logging 483 | AC_ARG_ENABLE(debugless, 484 | [AS_HELP_STRING([--enable-debugless],[Enable runtime instrumentation mode @<:@default=no@:>@])], 485 | [case "${enableval}" in 486 | yes) enable_debugless="yes" ;; 487 | no) enable_debugless="no" ;; 488 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-debugless) ;; 489 | esac], 490 | [enable_debugless="no"] 491 | ) 492 | if test "$enable_debugless" = "yes"; then 493 | AC_DEFINE(DEBUGLESS, 1, [Defined if debugless mode is enabled.]) 494 | fi 495 | 496 | 497 | # valgrind 498 | AC_ARG_ENABLE(valgrind, 499 | [AS_HELP_STRING([--enable-valgrind],[Enable somes special code that rsyslog core developers consider useful for testing. Do NOT use if you don't exactly know what you are doing, except if told so by rsyslog developers. NOT to be used by distro maintainers for building regular packages. @<:@default=no@:>@])], 500 | [case "${enableval}" in 501 | yes) enable_valgrind="yes" ;; 502 | no) enable_valgrind="no" ;; 503 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind) ;; 504 | esac], 505 | [enable_valgrind="no"] 506 | ) 507 | if test "$enable_valgrind" = "yes"; then 508 | AC_DEFINE(VALGRIND, 1, [Defined if valgrind support settings are to be enabled (e.g. prevents dlclose()).]) 509 | fi 510 | 511 | 512 | # memcheck 513 | AC_ARG_ENABLE(memcheck, 514 | [AS_HELP_STRING([--enable-memcheck],[Enable extended memory check support @<:@default=no@:>@])], 515 | [case "${enableval}" in 516 | yes) enable_memcheck="yes" ;; 517 | no) enable_memcheck="no" ;; 518 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-memcheck) ;; 519 | esac], 520 | [enable_memcheck="no"] 521 | ) 522 | if test "$enable_memcheck" = "yes"; then 523 | AC_DEFINE(MEMCHECK, 1, [Defined if memcheck support settings are to be enabled (e.g. prevents dlclose()).]) 524 | fi 525 | 526 | 527 | # compile diagnostic tools (small helpers usually not needed) 528 | AC_ARG_ENABLE(diagtools, 529 | [AS_HELP_STRING([--enable-diagtools],[Enable diagnostic tools @<:@default=no@:>@])], 530 | [case "${enableval}" in 531 | yes) enable_diagtools="yes" ;; 532 | no) enable_diagtools="no" ;; 533 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-diagtools) ;; 534 | esac], 535 | [enable_diagtools=no] 536 | ) 537 | AM_CONDITIONAL(ENABLE_DIAGTOOLS, test x$enable_diagtools = xyes) 538 | 539 | 540 | # compile end-user tools 541 | AC_ARG_ENABLE(usertools, 542 | [AS_HELP_STRING([--enable-usertools],[Enable end user tools @<:@default=no@:>@])], 543 | [case "${enableval}" in 544 | yes) enable_usertools="yes" ;; 545 | no) enable_usertools="no" ;; 546 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-usertools) ;; 547 | esac], 548 | [enable_usertools=no] 549 | ) 550 | AM_CONDITIONAL(ENABLE_USERTOOLS, test x$enable_usertools = xyes) 551 | 552 | 553 | # MySQL support 554 | AC_ARG_ENABLE(mysql, 555 | [AS_HELP_STRING([--enable-mysql],[Enable MySql database support @<:@default=no@:>@])], 556 | [case "${enableval}" in 557 | yes) enable_mysql="yes" ;; 558 | no) enable_mysql="no" ;; 559 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mysql) ;; 560 | esac], 561 | [enable_mysql=no] 562 | ) 563 | if test "x$enable_mysql" = "xyes"; then 564 | AC_CHECK_PROG( 565 | [MYSQL_CONFIG], 566 | [mysql_config], 567 | [mysql_config], 568 | [no],, 569 | ) 570 | if test "x${MYSQL_CONFIG}" = "xno"; then 571 | AC_MSG_FAILURE([mysql_config not found - usually a package named mysql-dev, libmysql-dev or similar, is missing - install it to fix this issue]) 572 | fi 573 | AC_CHECK_LIB( 574 | [mysqlclient], 575 | [mysql_init], 576 | [MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags` 577 | MYSQL_LIBS=`$MYSQL_CONFIG --libs` 578 | ], 579 | [AC_MSG_FAILURE([MySQL library is missing])], 580 | [`$MYSQL_CONFIG --libs`] 581 | ) 582 | AC_MSG_CHECKING(if we have mysql_library_init) 583 | save_CFLAGS="$CFLAGS" 584 | CFLAGS="$CFLAGS $MYSQL_CFLAGS" 585 | save_LIBS="$LIBS" 586 | LIBS="$LIBS $MYSQL_LIBS" 587 | AC_TRY_LINK( 588 | [#include 589 | #include ], 590 | [mysql_library_init(0, NULL, NULL)], 591 | [have_mysql_library_init=yes], 592 | [have_mysql_library_init=no]) 593 | CFLAGS="$save_CFLAGS" 594 | LIBS="$save_LIBS" 595 | fi 596 | AM_CONDITIONAL(ENABLE_MYSQL, test x$enable_mysql = xyes) 597 | if test "$have_mysql_library_init" = "yes"; then 598 | AC_DEFINE([HAVE_MYSQL_LIBRARY_INIT], [1], [mysql_library_init available]) 599 | fi 600 | AC_SUBST(MYSQL_CFLAGS) 601 | AC_SUBST(MYSQL_LIBS) 602 | 603 | 604 | # PostgreSQL support 605 | AC_ARG_ENABLE(pgsql, 606 | [AS_HELP_STRING([--enable-pgsql],[Enable PostgreSQL database support @<:@default=no@:>@])], 607 | [case "${enableval}" in 608 | yes) enable_pgsql="yes" ;; 609 | no) enable_pgsql="no" ;; 610 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-pgsql) ;; 611 | esac], 612 | [enable_pgsql=no] 613 | ) 614 | if test "x$enable_pgsql" = "xyes"; then 615 | AC_CHECK_PROG( 616 | [PG_CONFIG], 617 | [pg_config], 618 | [pg_config], 619 | [no],,, 620 | ) 621 | if test "x${PG_CONFIG}" = "xno"; then 622 | AC_MSG_FAILURE([pg_config not found]) 623 | fi 624 | AC_CHECK_LIB( 625 | [pq], 626 | [PQconnectdb], 627 | [PGSQL_CFLAGS="-I`$PG_CONFIG --includedir`" 628 | PGSQL_LIBS="-L`$PG_CONFIG --libdir` -lpq" 629 | ], 630 | [AC_MSG_FAILURE([PgSQL library is missing])], 631 | [-L`$PG_CONFIG --libdir`] 632 | ) 633 | fi 634 | AM_CONDITIONAL(ENABLE_PGSQL, test x$enable_pgsql = xyes) 635 | AC_SUBST(PGSQL_CFLAGS) 636 | AC_SUBST(PGSQL_LIBS) 637 | 638 | # libdbi support 639 | AC_ARG_ENABLE(libdbi, 640 | [AS_HELP_STRING([--enable-libdbi],[Enable libdbi database support @<:@default=no@:>@])], 641 | [case "${enableval}" in 642 | yes) enable_libdbi="yes" ;; 643 | no) enable_libdbi="no" ;; 644 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-libdbi) ;; 645 | esac], 646 | [enable_libdbi=no] 647 | ) 648 | if test "x$enable_libdbi" = "xyes"; then 649 | AC_CHECK_HEADERS( 650 | [dbi/dbi.h],, 651 | [AC_MSG_FAILURE([libdbi is missing])] 652 | ) 653 | AC_CHECK_LIB( 654 | [dbi], 655 | [dbi_initialize], 656 | [LIBDBI_CFLAGS="" 657 | LIBDBI_LIBS="-ldbi" 658 | ], 659 | [AC_MSG_FAILURE([libdbi library is missing])] 660 | ) 661 | AC_CHECK_LIB( 662 | [dbi], 663 | [dbi_initialize_r], 664 | [AC_DEFINE([HAVE_DBI_R], [1], [Define to 1 if libdbi supports the new plugin-safe interface])] 665 | ) 666 | AC_CHECK_LIB( 667 | [dbi], 668 | [dbi_conn_transaction_begin], 669 | [AC_DEFINE([HAVE_DBI_TXSUPP], [1], [Define to 1 if libdbi supports transactions])] 670 | ) 671 | fi 672 | AM_CONDITIONAL(ENABLE_OMLIBDBI, test x$enable_libdbi = xyes) 673 | AC_SUBST(LIBDBI_CFLAGS) 674 | AC_SUBST(LIBDBI_LIBS) 675 | 676 | # SNMP support 677 | AC_ARG_ENABLE(snmp, 678 | [AS_HELP_STRING([--enable-snmp],[Enable SNMP support @<:@default=no@:>@])], 679 | [case "${enableval}" in 680 | yes) enable_snmp="yes" ;; 681 | no) enable_snmp="no" ;; 682 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-snmp) ;; 683 | esac], 684 | [enable_snmp=no] 685 | ) 686 | if test "x$enable_snmp" = "xyes"; then 687 | AC_CHECK_HEADERS( 688 | [net-snmp/net-snmp-config.h],, 689 | [AC_MSG_FAILURE([Net-SNMP is missing])] 690 | ) 691 | AC_CHECK_LIB( 692 | [netsnmp], 693 | [snmp_timeout], 694 | [SNMP_CFLAGS="" 695 | SNMP_LIBS="-lnetsnmp" 696 | ], 697 | [AC_MSG_FAILURE([Net-SNMP library is missing])] 698 | ) 699 | fi 700 | AM_CONDITIONAL(ENABLE_SNMP, test x$enable_snmp = xyes) 701 | AC_SUBST(SNMP_CFLAGS) 702 | AC_SUBST(SNMP_LIBS) 703 | 704 | 705 | # uuid support 706 | AC_ARG_ENABLE(uuid, 707 | [AS_HELP_STRING([--enable-uuid],[Enable support for uuid generation @<:@default=yes@:>@])], 708 | [case "${enableval}" in 709 | yes) enable_uuid="yes" ;; 710 | no) enable_uuid="no" ;; 711 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-uuid) ;; 712 | esac], 713 | [enable_uuid=yes] 714 | ) 715 | if test "x$enable_uuid" = "xyes"; then 716 | PKG_CHECK_MODULES([LIBUUID], [uuid]) 717 | AC_DEFINE(USE_LIBUUID, 1, [Define if you want to enable libuuid support]) 718 | fi 719 | AM_CONDITIONAL(ENABLE_UUID, test x$enable_uuid = xyes) 720 | 721 | 722 | # elasticsearch support 723 | AC_ARG_ENABLE(elasticsearch, 724 | [AS_HELP_STRING([--enable-elasticsearch],[Enable elasticsearch output module @<:@default=no@:>@])], 725 | [case "${enableval}" in 726 | yes) enable_elasticsearch="yes" ;; 727 | no) enable_elasticsearch="no" ;; 728 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-elasticsearch) ;; 729 | esac], 730 | [enable_elasticsearch=no] 731 | ) 732 | if test "x$enable_elasticsearch" = "xyes"; then 733 | PKG_CHECK_MODULES([CURL], [libcurl]) 734 | LT_LIB_M 735 | fi 736 | AM_CONDITIONAL(ENABLE_ELASTICSEARCH, test x$enable_elasticsearch = xyes) 737 | 738 | 739 | # capability to enable elasticsearch testbench tests. This requries that an ES test 740 | # environment is present on the local (127.0.0.1) machine. 741 | AC_ARG_ENABLE(elasticsearch_tests, 742 | [AS_HELP_STRING([--enable-elasticsearch-tests],[enable MySQL specific tests in testbench @<:@default=no@:>@])], 743 | [case "${enableval}" in 744 | yes) enable_elasticsearch_tests="yes" ;; 745 | no) enable_elasticsearch_tests="no" ;; 746 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-elasticsearch-tests) ;; 747 | esac], 748 | [enable_elasticsearch_tests=no] 749 | ) 750 | AM_CONDITIONAL(ENABLE_ELASTICSEARCH_TESTS, test x$enable_elasticsearch_tests = xyes) 751 | 752 | 753 | # GnuTLS support 754 | AC_ARG_ENABLE(gnutls, 755 | [AS_HELP_STRING([--enable-gnutls],[Enable GNU TLS support @<:@default=no@:>@])], 756 | [case "${enableval}" in 757 | yes) enable_gnutls="yes" ;; 758 | no) enable_gnutls="no" ;; 759 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-gnutls) ;; 760 | esac], 761 | [enable_gnutls=no] 762 | ) 763 | if test "x$enable_gnutls" = "xyes"; then 764 | PKG_CHECK_MODULES(GNUTLS, gnutls >= 1.4.0) 765 | AC_DEFINE([ENABLE_GNUTLS], [1], [Indicator that GnuTLS is present]) 766 | save_libs=$LIBS 767 | LIBS="$LIBS $GNUTLS_LIBS" 768 | AC_CHECK_FUNCS(gnutls_certificate_set_retrieve_function,,) 769 | AC_CHECK_FUNCS(gnutls_certificate_type_set_priority,,) 770 | LIBS=$save_libs 771 | fi 772 | 773 | AM_CONDITIONAL(ENABLE_GNUTLS, test x$enable_gnutls = xyes) 774 | 775 | # libgcrypt support 776 | AC_ARG_ENABLE(libgcrypt, 777 | [AS_HELP_STRING([--enable-libgcrypt],[Enable log file encryption support (libgcrypt) @<:@default=yes@:>@])], 778 | [case "${enableval}" in 779 | yes) enable_libgcrypt="yes" ;; 780 | no) enable_libgcrypt="no" ;; 781 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-libgcrypt) ;; 782 | esac], 783 | [enable_libgcrypt=yes] 784 | ) 785 | if test "x$enable_libgcrypt" = "xyes"; then 786 | AC_PATH_PROG([LIBGCRYPT_CONFIG],[libgcrypt-config],[no]) 787 | if test "x${LIBGCRYPT_CONFIG}" = "xno"; then 788 | AC_MSG_FAILURE([libgcrypt-config not found in PATH]) 789 | fi 790 | AC_CHECK_LIB( 791 | [gcrypt], 792 | [gcry_cipher_open], 793 | [LIBGCRYPT_CFLAGS="`${LIBGCRYPT_CONFIG} --cflags`" 794 | LIBGCRYPT_LIBS="`${LIBGCRYPT_CONFIG} --libs`" 795 | ], 796 | [AC_MSG_FAILURE([libgcrypt is missing])], 797 | [`${LIBGCRYPT_CONFIG} --libs --cflags`] 798 | ) 799 | AC_DEFINE([ENABLE_LIBGCRYPT], [1], [Indicator that LIBGCRYPT is present]) 800 | fi 801 | AM_CONDITIONAL(ENABLE_LIBGCRYPT, test x$enable_libgcrypt = xyes) 802 | AC_SUBST(LIBGCRYPT_CFLAGS) 803 | AC_SUBST(LIBGCRYPT_LIBS) 804 | 805 | 806 | # support for building the rsyslogd runtime 807 | AC_ARG_ENABLE(rsyslogrt, 808 | [AS_HELP_STRING([--enable-rsyslogrt],[Build rsyslogrt @<:@default=yes@:>@])], 809 | [case "${enableval}" in 810 | yes) enable_rsyslogrt="yes" ;; 811 | no) enable_rsyslogrt="no" ;; 812 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-rsyslogrt) ;; 813 | esac], 814 | [enable_rsyslogrt=yes] 815 | ) 816 | if test "x$enable_rsyslogrt" = "xyes"; then 817 | RSRT_CFLAGS1="-I\$(top_srcdir)/runtime -I\$(top_srcdir) -I\$(top_srcdir)/grammar" 818 | RSRT_LIBS1="\$(top_builddir)/runtime/librsyslog.la" 819 | fi 820 | AM_CONDITIONAL(ENABLE_RSYSLOGRT, test x$enable_rsyslogrt = xyes) 821 | RSRT_CFLAGS="\$(RSRT_CFLAGS1) \$(LIBESTR_CFLAGS) \$(JSON_C_CFLAGS)" 822 | if test "$GCC" = "yes"; then 823 | RSRT_CFLAGS="$RSRT_CFLAGS -W -Wall -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute" 824 | if $CC -Werror=implicit-function-declaration -x c -c /dev/null -o /dev/null 2>/dev/null; then 825 | RSRT_CFLAGS="$RSRT_CFLAGS -Werror=implicit-function-declaration" 826 | elif $CC -Werror-implicit-function-declaration -x c -c /dev/null -o /dev/null 2>/dev/null; then 827 | RSRT_CFLAGS="$RSRT_CFLAGS -Werror-implicit-function-declaration" 828 | fi 829 | 830 | if test "x$enable_debug_symbols" = "xyes"; then 831 | RSRT_CFLAGS="$RSRT_CFLAGS -g" 832 | fi 833 | fi 834 | RSRT_LIBS="\$(RSRT_LIBS1) \$(LIBESTR_LIBS) \$(JSON_C_LIBS)" 835 | AC_SUBST(RSRT_CFLAGS1) 836 | AC_SUBST(RSRT_LIBS1) 837 | AC_SUBST(RSRT_CFLAGS) 838 | AC_SUBST(RSRT_LIBS) 839 | 840 | 841 | # support for NOT building rsyslogd (useful for source-based packaging systems) 842 | AC_ARG_ENABLE(rsyslogd, 843 | [AS_HELP_STRING([--enable-rsyslogd],[Build rsyslogd @<:@default=yes@:>@])], 844 | [case "${enableval}" in 845 | yes) enable_rsyslogd="yes" ;; 846 | no) enable_rsyslogd="no" ;; 847 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-rsyslogd) ;; 848 | esac], 849 | [enable_rsyslogd=yes] 850 | ) 851 | AM_CONDITIONAL(ENABLE_RSYSLOGD, test x$enable_rsyslogd = xyes) 852 | 853 | 854 | # capability to enable an extended testbench. By default, this is off. The reason 855 | # for this switch is that some test simply take too long to execute them on a regular 856 | # basis. So we enable to skip them, while the majority of tests can still be used. The 857 | # idea is that at least "make distcheck" executes the extended testbench, and also 858 | # developers should explicitely enable it after important changes. -- rgerhards, 2010-04-12 859 | AC_ARG_ENABLE(extended_tests, 860 | [AS_HELP_STRING([--enable-extended-tests],[extended testbench @<:@default=no@:>@])], 861 | [case "${enableval}" in 862 | yes) enable_extended_tests="yes" ;; 863 | no) enable_extended_tests="no" ;; 864 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-extended-tests) ;; 865 | esac], 866 | [enable_extended_tests=no] 867 | ) 868 | AM_CONDITIONAL(ENABLE_EXTENDED_TESTS, test x$enable_extended_tests = xyes) 869 | 870 | 871 | # capability to enable MySQL testbench tests. This requries that a Syslog database 872 | # with the default schema has been created on the local (127.0.0.1) MySQL server and 873 | # a user "rsyslog" with password "testbench" exists, is able to login with default 874 | # parameters and has sufficient (read: all) privileges on that database. 875 | # rgerhards, 2011-03-09 876 | AC_ARG_ENABLE(mysql_tests, 877 | [AS_HELP_STRING([--enable-mysql-tests],[enable MySQL specific tests in testbench @<:@default=no@:>@])], 878 | [case "${enableval}" in 879 | yes) enable_mysql_tests="yes" ;; 880 | no) enable_mysql_tests="no" ;; 881 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mysql-tests) ;; 882 | esac], 883 | [enable_mysql_tests=no] 884 | ) 885 | AM_CONDITIONAL(ENABLE_MYSQL_TESTS, test x$enable_mysql_tests = xyes) 886 | 887 | 888 | # Mail support (so far we do not need a library, but we need to turn this on and off) 889 | AC_ARG_ENABLE(mail, 890 | [AS_HELP_STRING([--enable-mail],[Enable mail support @<:@default=no@:>@])], 891 | [case "${enableval}" in 892 | yes) enable_mail="yes" ;; 893 | no) enable_mail="no" ;; 894 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mail) ;; 895 | esac], 896 | [enable_mail=no] 897 | ) 898 | AM_CONDITIONAL(ENABLE_MAIL, test x$enable_mail = xyes) 899 | 900 | 901 | # imdiag support 902 | # This is a core testbench tool. You need to enable it if you want to 903 | # use not only a small subset of the testbench. 904 | AC_ARG_ENABLE(imdiag, 905 | [AS_HELP_STRING([--enable-imdiag],[Enable imdiag @<:@default=no@:>@])], 906 | [case "${enableval}" in 907 | yes) enable_imdiag="yes" ;; 908 | no) enable_imdiag="no" ;; 909 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-imdiag) ;; 910 | esac], 911 | [enable_imdiag=no] 912 | ) 913 | if test "x$enable_imdiag" = "xyes"; then 914 | AC_DEFINE([ENABLE_IMDIAG], [1], [Indicator that IMDIAG is present]) 915 | fi 916 | AM_CONDITIONAL(ENABLE_IMDIAG, test x$enable_imdiag = xyes) 917 | 918 | 919 | # mmnormalize 920 | AC_ARG_ENABLE(mmnormalize, 921 | [AS_HELP_STRING([--enable-mmnormalize],[Enable building mmnormalize support @<:@default=no@:>@])], 922 | [case "${enableval}" in 923 | yes) enable_mmnormalize="yes" ;; 924 | no) enable_mmnormalize="no" ;; 925 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmnormalize) ;; 926 | esac], 927 | [enable_mmnormalize=no] 928 | ) 929 | if test "x$enable_mmnormalize" = "xyes"; then 930 | PKG_CHECK_MODULES(LIBLOGNORM, lognorm >= 1.1.2) 931 | 932 | save_CFLAGS="$CFLAGS" 933 | save_LIBS="$LIBS" 934 | 935 | CFLAGS="$CFLAGS $LIBLOGNORM_CFLAGS" 936 | LIBS="$LIBS $LIBLOGNORM_LIBS" 937 | 938 | AX_CHECK_DEFINED([[#include ]],LOGNORM_REGEX_SUPPORTED,[lognorm_regex_supported="yes"],) 939 | 940 | CFLAGS="$save_CFLAGS" 941 | LIBS="$save_LIBS" 942 | fi 943 | AM_CONDITIONAL(LOGNORM_REGEX_SUPPORTED, test x$lognorm_regex_supported = xyes) 944 | AM_CONDITIONAL(ENABLE_MMNORMALIZE, test x$enable_mmnormalize = xyes) 945 | 946 | # mmnjsonparse 947 | AC_ARG_ENABLE(mmjsonparse, 948 | [AS_HELP_STRING([--enable-mmjsonparse],[Enable building mmjsonparse support @<:@default=no@:>@])], 949 | [case "${enableval}" in 950 | yes) enable_mmjsonparse="yes" ;; 951 | no) enable_mmjsonparse="no" ;; 952 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmjsonparse) ;; 953 | esac], 954 | [enable_mmjsonparse=no] 955 | ) 956 | AM_CONDITIONAL(ENABLE_MMJSONPARSE, test x$enable_mmjsonparse = xyes) 957 | 958 | #mmgrok 959 | AC_ARG_ENABLE(mmgrok, 960 | [AS_HELP_STRING([--enable-mmgrok],[Enable building mmgrok support @<:@default=no@:>@])], 961 | [case "${enableval}" in 962 | yes) enable_mmgrok="yes" ;; 963 | no) enable_mmgrok="no" ;; 964 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmgrok) ;; 965 | esac], 966 | [enable_mmgrok=no] 967 | ) 968 | AM_CONDITIONAL(ENABLE_MMGROK, test x$enable_mmgrok = xyes) 969 | 970 | # mmaudit 971 | AC_ARG_ENABLE(mmaudit, 972 | [AS_HELP_STRING([--enable-mmaudit],[Enable building mmaudit support @<:@default=no@:>@])], 973 | [case "${enableval}" in 974 | yes) enable_mmaudit="yes" ;; 975 | no) enable_mmaudit="no" ;; 976 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmaudit) ;; 977 | esac], 978 | [enable_mmaudit=no] 979 | ) 980 | AM_CONDITIONAL(ENABLE_MMAUDIT, test x$enable_mmaudit = xyes) 981 | 982 | 983 | # mmanon 984 | AC_ARG_ENABLE(mmanon, 985 | [AS_HELP_STRING([--enable-mmanon],[Enable building mmanon support @<:@default=no@:>@])], 986 | [case "${enableval}" in 987 | yes) enable_mmanon="yes" ;; 988 | no) enable_mmanon="no" ;; 989 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmanon) ;; 990 | esac], 991 | [enable_mmanon=no] 992 | ) 993 | AM_CONDITIONAL(ENABLE_MMANON, test x$enable_mmanon = xyes) 994 | 995 | 996 | # mmutf8fix 997 | AC_ARG_ENABLE(mmutf8fix, 998 | [AS_HELP_STRING([--enable-mmutf8fix],[Enable building mmutf8fix support @<:@default=no@:>@])], 999 | [case "${enableval}" in 1000 | yes) enable_mmutf8fix="yes" ;; 1001 | no) enable_mmutf8fix="no" ;; 1002 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmutf8fix) ;; 1003 | esac], 1004 | [enable_mmutf8fix=no] 1005 | ) 1006 | AM_CONDITIONAL(ENABLE_MMUTF8FIX, test x$enable_mmutf8fix = xyes) 1007 | 1008 | 1009 | # mmcount 1010 | AC_ARG_ENABLE(mmcount, 1011 | [AS_HELP_STRING([--enable-mmcount],[Enable message counting @<:@default=no@:>@])], 1012 | [case "${enableval}" in 1013 | yes) enable_mmcount="yes" ;; 1014 | no) enable_mmcount="no" ;; 1015 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmcount) ;; 1016 | esac], 1017 | [enable_mmcount=no] 1018 | ) 1019 | AM_CONDITIONAL(ENABLE_MMCOUNT, test x$enable_mmcount = xyes) 1020 | 1021 | 1022 | # mmsequence 1023 | AC_ARG_ENABLE(mmsequence, 1024 | [AS_HELP_STRING([--enable-mmsequence],[Enable sequence generator @<:@default=no@:>@])], 1025 | [case "${enableval}" in 1026 | yes) enable_mmsequence="yes" ;; 1027 | no) enable_mmsequence="no" ;; 1028 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmsequence) ;; 1029 | esac], 1030 | [enable_mmsequence=no] 1031 | ) 1032 | AM_CONDITIONAL(ENABLE_MMSEQUENCE, test x$enable_mmsequence = xyes) 1033 | 1034 | 1035 | # mmfields 1036 | AC_ARG_ENABLE(mmfields, 1037 | [AS_HELP_STRING([--enable-mmfields],[Enable building mmfields support @<:@default=no@:>@])], 1038 | [case "${enableval}" in 1039 | yes) enable_mmfields="yes" ;; 1040 | no) enable_mmfields="no" ;; 1041 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmfields) ;; 1042 | esac], 1043 | [enable_mmfields=no] 1044 | ) 1045 | AM_CONDITIONAL(ENABLE_MMFIELDS, test x$enable_mmfields = xyes) 1046 | 1047 | # mmpstrucdata 1048 | AC_ARG_ENABLE(mmpstrucdata, 1049 | [AS_HELP_STRING([--enable-mmpstrucdata],[Enable building mmpstrucdata support @<:@default=no@:>@])], 1050 | [case "${enableval}" in 1051 | yes) enable_mmpstrucdata="yes" ;; 1052 | no) enable_mmpstrucdata="no" ;; 1053 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmpstrucdata) ;; 1054 | esac], 1055 | [enable_mmpstrucdata=no] 1056 | ) 1057 | AM_CONDITIONAL(ENABLE_MMPSTRUCDATA, test x$enable_mmpstrucdata = xyes) 1058 | 1059 | 1060 | # mmrfc5424addhmac 1061 | AC_ARG_ENABLE(mmrfc5424addhmac, 1062 | [AS_HELP_STRING([--enable-mmrfc5424addhmac],[Enable building mmrfc5424addhmac support @<:@default=no@:>@])], 1063 | [case "${enableval}" in 1064 | yes) enable_mmrfc5424addhmac="yes" ;; 1065 | no) enable_mmrfc5424addhmac="no" ;; 1066 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmrfc5424addhmac) ;; 1067 | esac], 1068 | [enable_mmrfc5424addhmac=no] 1069 | ) 1070 | if test "x$enable_mmrfc5424addhmac" = "xyes"; then 1071 | PKG_CHECK_MODULES(OPENSSL, openssl >= 0.9.7) 1072 | #AC_CHECK_LIB([crypto],[CRYPTO_new_ex_data], [], [AC_MSG_ERROR([OpenSSL libraries required])]) 1073 | #AC_CHECK_LIB([ssl],[SSL_library_init], [], [AC_MSG_ERROR([OpenSSL libraries required])]) 1074 | #AC_CHECK_HEADERS([openssl/crypto.h openssl/x509.h openssl/pem.h openssl/ssl.h openssl/err.h],[],[AC_MSG_ERROR([OpenSSL headers required])]) 1075 | fi 1076 | AM_CONDITIONAL(ENABLE_MMRFC5424ADDHMAC, test x$enable_mmrfc5424addhmac = xyes) 1077 | 1078 | 1079 | # RELP support 1080 | AC_ARG_ENABLE(relp, 1081 | [AS_HELP_STRING([--enable-relp],[Enable RELP support @<:@default=no@:>@])], 1082 | [case "${enableval}" in 1083 | yes) enable_relp="yes" ;; 1084 | no) enable_relp="no" ;; 1085 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-relp) ;; 1086 | esac], 1087 | [enable_relp=no] 1088 | ) 1089 | if test "x$enable_relp" = "xyes"; then 1090 | PKG_CHECK_MODULES(RELP, relp >= 1.2.5) 1091 | fi 1092 | AM_CONDITIONAL(ENABLE_RELP, test x$enable_relp = xyes) 1093 | 1094 | 1095 | # GuardTime support 1096 | AC_ARG_ENABLE(guardtime, 1097 | [AS_HELP_STRING([--enable-guardtime],[Enable log file signing support (via GuardTime) @<:@default=no@:>@])], 1098 | [case "${enableval}" in 1099 | yes) enable_guardtime="yes" ;; 1100 | no) enable_guardtime="no" ;; 1101 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-guardtime) ;; 1102 | esac], 1103 | [enable_guardtime=no] 1104 | ) 1105 | if test "x$enable_guardtime" = "xyes"; then 1106 | PKG_CHECK_MODULES(GUARDTIME, libgt >= 0.3.1) 1107 | fi 1108 | AM_CONDITIONAL(ENABLE_GUARDTIME, test x$enable_guardtime = xyes) 1109 | 1110 | 1111 | # GuardTime KSI support 1112 | AC_ARG_ENABLE(gt-ksi, 1113 | [AS_HELP_STRING([--enable-gt-ksi],[Enable log file signing support via GuardTime KSI @<:@default=no@:>@])], 1114 | [case "${enableval}" in 1115 | yes) enable_gt_ksi="yes" ;; 1116 | no) enable_gt_ksi="no" ;; 1117 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-gt-ksi) ;; 1118 | esac], 1119 | [enable_gt_ksi=no] 1120 | ) 1121 | if test "x$enable_gt_ksi" = "xyes"; then 1122 | PKG_CHECK_MODULES(GT_KSI, libksi >= 3.2.2.0) 1123 | PKG_CHECK_MODULES(GT_KSI, libksi < 3.3.0.0) 1124 | fi 1125 | AM_CONDITIONAL(ENABLE_GT_KSI, test x$enable_gt_ksi = xyes) 1126 | 1127 | 1128 | # liblogging-stdlog support 1129 | AC_ARG_ENABLE(liblogging-stdlog, 1130 | [AS_HELP_STRING([--enable-liblogging-stdlog],[Enable liblogging-stdlog support @<:@default=yes@:>@])], 1131 | [case "${enableval}" in 1132 | yes) enable_liblogging_stdlog="yes" ;; 1133 | no) enable_liblogging_stdlog="no" ;; 1134 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-liblogging-stdlog) ;; 1135 | esac], 1136 | [enable_liblogging_stdlog=yes] 1137 | ) 1138 | if test "x$enable_liblogging_stdlog" = "xyes"; then 1139 | PKG_CHECK_MODULES(LIBLOGGING_STDLOG, liblogging-stdlog >= 1.0.3, 1140 | AC_DEFINE(HAVE_LIBLOGGING_STDLOG, 1, [Define to 1 if liblogging-stdlog is available.]) 1141 | ) 1142 | fi 1143 | AM_CONDITIONAL(ENABLE_LIBLOGGING_STDLOG, test x$enable_liblogging_stdlog = xyes) 1144 | 1145 | 1146 | # RFC 3195 support 1147 | AC_ARG_ENABLE(rfc3195, 1148 | [AS_HELP_STRING([--enable-rfc3195],[Enable RFC3195 support @<:@default=no@:>@])], 1149 | [case "${enableval}" in 1150 | yes) enable_rfc3195="yes" ;; 1151 | no) enable_rfc3195="no" ;; 1152 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-rfc3195) ;; 1153 | esac], 1154 | [enable_rfc3195=no] 1155 | ) 1156 | if test "x$enable_rfc3195" = "xyes"; then 1157 | PKG_CHECK_MODULES(LIBLOGGING, liblogging-rfc3195 >= 1.0.1) 1158 | fi 1159 | AM_CONDITIONAL(ENABLE_RFC3195, test x$enable_rfc3195 = xyes) 1160 | 1161 | 1162 | # enable/disable the testbench (e.g. because some important parts 1163 | # are missing) 1164 | AC_ARG_ENABLE(testbench, 1165 | [AS_HELP_STRING([--enable-testbench],[testbench enabled @<:@default=no@:>@])], 1166 | [case "${enableval}" in 1167 | yes) enable_testbench="yes" ;; 1168 | no) enable_testbench="no" ;; 1169 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-testbench) ;; 1170 | esac], 1171 | [enable_testbench=no] 1172 | ) 1173 | AM_CONDITIONAL(ENABLE_TESTBENCH, test x$enable_testbench = xyes) 1174 | if test "x$enable_testbench" = "xyes"; then 1175 | if test "x$enable_imdiag" != "xyes"; then 1176 | AC_MSG_ERROR("--enable-testbench requires --enable-imdiag") 1177 | fi 1178 | fi 1179 | 1180 | 1181 | # valgrind-testbench 1182 | AC_ARG_WITH([valgrind_testbench], 1183 | [AS_HELP_STRING([--without-valgrind-testbench], [Don't use valgrind in testbench])] 1184 | ) 1185 | 1186 | if test "x$with_valgrind_testbench" != "xno"; then 1187 | AC_CHECK_PROG(VALGRIND, [valgrind], [valgrind], [no]) 1188 | 1189 | if test "x$enable_testbench" = "xyes" && test "x$VALGRIND" = "xno"; then 1190 | if test "x$with_valgrind_testbench" = "xyes"; then 1191 | AC_MSG_ERROR([valgrind is missing but forced with --with-valgrind-testbench. Either install valgrind or remove the option!]) 1192 | else 1193 | AC_MSG_WARN([valgrind is missing -- testbench won't use valgrind!]) 1194 | fi 1195 | else 1196 | AC_MSG_NOTICE([testbench will use valgrind]) 1197 | fi 1198 | else 1199 | AC_MSG_NOTICE([testbench won't use valgrind due to set --without-valgrind-testbench option]) 1200 | fi 1201 | AM_CONDITIONAL([HAVE_VALGRIND], [test "x$with_valgrind_testbench" != "xno" && test "x$VALGRIND" != "xno"]) 1202 | 1203 | 1204 | # settings for the file input module 1205 | AC_ARG_ENABLE(imfile, 1206 | [AS_HELP_STRING([--enable-imfile],[file input module enabled @<:@default=no@:>@])], 1207 | [case "${enableval}" in 1208 | yes) enable_imfile="yes" ;; 1209 | no) enable_imfile="no" ;; 1210 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-imfile) ;; 1211 | esac], 1212 | [enable_imfile=no] 1213 | ) 1214 | AM_CONDITIONAL(ENABLE_IMFILE, test x$enable_imfile = xyes) 1215 | 1216 | 1217 | # settings for the door input module (under solaris, thus default off) 1218 | AC_ARG_ENABLE(imsolaris, 1219 | [AS_HELP_STRING([--enable-imsolaris],[solaris input module enabled @<:@default=no@:>@])], 1220 | [case "${enableval}" in 1221 | yes) enable_imsolaris="yes" ;; 1222 | no) enable_imsolaris="no" ;; 1223 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-imsolaris) ;; 1224 | esac], 1225 | [enable_imsolaris=no] 1226 | ) 1227 | AM_CONDITIONAL(ENABLE_IMSOLARIS, test x$enable_imsolaris = xyes) 1228 | 1229 | # settings for the ptcp input module 1230 | AC_ARG_ENABLE(imptcp, 1231 | [AS_HELP_STRING([--enable-imptcp],[plain tcp input module enabled @<:@default=no@:>@])], 1232 | [case "${enableval}" in 1233 | yes) enable_imptcp="yes" ;; 1234 | no) enable_imptcp="no" ;; 1235 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-imptcp) ;; 1236 | esac], 1237 | [enable_imptcp=no] 1238 | ) 1239 | AM_CONDITIONAL(ENABLE_IMPTCP, test x$enable_imptcp = xyes) 1240 | 1241 | 1242 | # settings for the pstats input module 1243 | AC_ARG_ENABLE(impstats, 1244 | [AS_HELP_STRING([--enable-impstats],[periodic statistics module enabled @<:@default=no@:>@])], 1245 | [case "${enableval}" in 1246 | yes) enable_impstats="yes" ;; 1247 | no) enable_impstats="no" ;; 1248 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-impstats) ;; 1249 | esac], 1250 | [enable_impstats=no] 1251 | ) 1252 | AM_CONDITIONAL(ENABLE_IMPSTATS, test x$enable_impstats = xyes) 1253 | 1254 | 1255 | # settings for the omprog output module 1256 | AC_ARG_ENABLE(omprog, 1257 | [AS_HELP_STRING([--enable-omprog],[Compiles omprog module @<:@default=no@:>@])], 1258 | [case "${enableval}" in 1259 | yes) enable_omprog="yes" ;; 1260 | no) enable_omprog="no" ;; 1261 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omprog) ;; 1262 | esac], 1263 | [enable_omprog=no] 1264 | ) 1265 | AM_CONDITIONAL(ENABLE_OMPROG, test x$enable_omprog = xyes) 1266 | 1267 | 1268 | # settings for omudpspoof 1269 | AC_ARG_ENABLE(omudpspoof, 1270 | [AS_HELP_STRING([--enable-omudpspoof],[Compiles omudpspoof module @<:@default=no@:>@])], 1271 | [case "${enableval}" in 1272 | yes) enable_omudpspoof="yes" ;; 1273 | no) enable_omudpspoof="no" ;; 1274 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omudpspoof) ;; 1275 | esac], 1276 | [enable_omudpspoof=no] 1277 | ) 1278 | 1279 | if test "x$enable_omudpspoof" = "xyes"; then 1280 | AC_CHECK_HEADERS( 1281 | [libnet.h],, 1282 | [AC_MSG_FAILURE([libnet is missing])] 1283 | ) 1284 | AC_CHECK_LIB( 1285 | [net], 1286 | [libnet_init], 1287 | [UDPSPOOF_CFLAGS="" 1288 | UDPSPOOF_LIBS="-lnet" 1289 | ], 1290 | [AC_MSG_FAILURE([libnet is missing])] 1291 | ) 1292 | fi 1293 | AM_CONDITIONAL(ENABLE_OMUDPSPOOF, test x$enable_omudpspoof = xyes) 1294 | AC_SUBST(UDPSPOOF_CFLAGS) 1295 | AC_SUBST(UDPSPOOF_LIBS) 1296 | 1297 | 1298 | # settings for omstdout 1299 | AC_ARG_ENABLE(omstdout, 1300 | [AS_HELP_STRING([--enable-omstdout],[Compiles stdout module @<:@default=no@:>@])], 1301 | [case "${enableval}" in 1302 | yes) enable_omstdout="yes" ;; 1303 | no) enable_omstdout="no" ;; 1304 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omstdout) ;; 1305 | esac], 1306 | [enable_omstdout=no] 1307 | ) 1308 | AM_CONDITIONAL(ENABLE_OMSTDOUT, test x$enable_omstdout = xyes) 1309 | 1310 | # settings for omjournal 1311 | AC_ARG_ENABLE(omjournal, 1312 | [AS_HELP_STRING([--enable-omjournal],[Compiles omjournal @<:@default=no@:>@])], 1313 | [case "${enableval}" in 1314 | yes) enable_omjournal="yes" ;; 1315 | no) enable_omjournal="no" ;; 1316 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omjournal) ;; 1317 | esac], 1318 | [enable_omjournal=no] 1319 | ) 1320 | if test "x$enable_omjournal" = "xyes"; then 1321 | PKG_CHECK_MODULES([LIBSYSTEMD_JOURNAL], [libsystemd >= 209] ,, [ 1322 | PKG_CHECK_MODULES([LIBSYSTEMD_JOURNAL], [libsystemd-journal >= 197]) 1323 | ]) 1324 | fi 1325 | AM_CONDITIONAL(ENABLE_OMJOURNAL, test x$enable_omjournal = xyes) 1326 | 1327 | 1328 | # settings for pmlastmsg 1329 | AC_ARG_ENABLE(pmlastmsg, 1330 | [AS_HELP_STRING([--enable-pmlastmsg],[Compiles lastmsg parser module @<:@default=no@:>@])], 1331 | [case "${enableval}" in 1332 | yes) enable_pmlastmsg="yes" ;; 1333 | no) enable_pmlastmsg="no" ;; 1334 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-pmlastmsg) ;; 1335 | esac], 1336 | [enable_pmlastmsg=no] 1337 | ) 1338 | AM_CONDITIONAL(ENABLE_PMLASTMSG, test x$enable_pmlastmsg = xyes) 1339 | 1340 | 1341 | # settings for pmcisconames 1342 | AC_ARG_ENABLE(pmcisconames, 1343 | [AS_HELP_STRING([--enable-pmcisconames],[Compiles cisconames parser module @<:@default=no@:>@])], 1344 | [case "${enableval}" in 1345 | yes) enable_pmcisconames="yes" ;; 1346 | no) enable_pmcisconames="no" ;; 1347 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-pmcisconames) ;; 1348 | esac], 1349 | [enable_pmcisconames=no] 1350 | ) 1351 | AM_CONDITIONAL(ENABLE_PMCISCONAMES, test x$enable_pmcisconames = xyes) 1352 | 1353 | 1354 | # settings for pmciscoios 1355 | AC_ARG_ENABLE(pmciscoios, 1356 | [AS_HELP_STRING([--enable-pmciscoios],[Compiles ciscoios parser module @<:@default=no@:>@])], 1357 | [case "${enableval}" in 1358 | yes) enable_pmciscoios="yes" ;; 1359 | no) enable_pmciscoios="no" ;; 1360 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-pmciscoios) ;; 1361 | esac], 1362 | [enable_pmciscoios=no] 1363 | ) 1364 | AM_CONDITIONAL(ENABLE_PMCISCOIOS, test x$enable_pmciscoios = xyes) 1365 | 1366 | 1367 | # settings for pmaixforwardedfrom 1368 | AC_ARG_ENABLE(pmaixforwardedfrom, 1369 | [AS_HELP_STRING([--enable-pmaixforwardedfrom],[Compiles aixforwardedfrom parser module @<:@default=no@:>@])], 1370 | [case "${enableval}" in 1371 | yes) enable_pmaixforwardedfrom="yes" ;; 1372 | no) enable_pmaixforwardedfrom="no" ;; 1373 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-pmaixforwardedfrom) ;; 1374 | esac], 1375 | [enable_pmaixforwardedfrom=no] 1376 | ) 1377 | AM_CONDITIONAL(ENABLE_PMAIXFORWARDEDFROM, test x$enable_pmaixforwardedfrom = xyes) 1378 | 1379 | 1380 | # settings for pmsnare 1381 | AC_ARG_ENABLE(pmsnare, 1382 | [AS_HELP_STRING([--enable-pmsnare],[Compiles snare parser module @<:@default=no@:>@])], 1383 | [case "${enableval}" in 1384 | yes) enable_pmsnare="yes" ;; 1385 | no) enable_pmsnare="no" ;; 1386 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-pmsnare) ;; 1387 | esac], 1388 | [enable_pmsnare=no] 1389 | ) 1390 | AM_CONDITIONAL(ENABLE_PMSNARE, test x$enable_pmsnare = xyes) 1391 | 1392 | 1393 | # settings for omruleset 1394 | AC_ARG_ENABLE(omruleset, 1395 | [AS_HELP_STRING([--enable-omruleset],[Compiles ruleset forwarding module @<:@default=no@:>@])], 1396 | [case "${enableval}" in 1397 | yes) enable_omruleset="yes" ;; 1398 | no) enable_omruleset="no" ;; 1399 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omruleset) ;; 1400 | esac], 1401 | [enable_omruleset=no] 1402 | ) 1403 | AM_CONDITIONAL(ENABLE_OMRULESET, test x$enable_omruleset = xyes) 1404 | 1405 | 1406 | # settings for omuxsock 1407 | AC_ARG_ENABLE(omuxsock, 1408 | [AS_HELP_STRING([--enable-omuxsock],[Compiles omuxsock module @<:@default=no@:>@])], 1409 | [case "${enableval}" in 1410 | yes) enable_omuxsock="yes" ;; 1411 | no) enable_omuxsock="no" ;; 1412 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omuxsock) ;; 1413 | esac], 1414 | [enable_omuxsock=no] 1415 | ) 1416 | AM_CONDITIONAL(ENABLE_OMUXSOCK, test x$enable_omuxsock = xyes) 1417 | 1418 | 1419 | # settings for mmsnmptrapd message modification module 1420 | AC_ARG_ENABLE(mmsnmptrapd, 1421 | [AS_HELP_STRING([--enable-mmsnmptrapd],[Compiles mmsnmptrapd module @<:@default=no@:>@])], 1422 | [case "${enableval}" in 1423 | yes) enable_mmsnmptrapd="yes" ;; 1424 | no) enable_mmsnmptrapd="no" ;; 1425 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmsnmptrapd) ;; 1426 | esac], 1427 | [enable_mmsnmptrapd=no] 1428 | ) 1429 | AM_CONDITIONAL(ENABLE_MMSNMPTRAPD, test x$enable_mmsnmptrapd = xyes) 1430 | 1431 | 1432 | # settings for the omhdfs; 1433 | AC_ARG_ENABLE(omhdfs, 1434 | [AS_HELP_STRING([--enable-omhdfs],[Compiles omhdfs module @<:@default=no@:>@])], 1435 | [case "${enableval}" in 1436 | yes) enable_omhdfs="yes" ;; 1437 | no) enable_omhdfs="no" ;; 1438 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omhdfs) ;; 1439 | esac], 1440 | [enable_omhdfs=no] 1441 | ) 1442 | if test "x$enable_omhdfs"; then 1443 | AC_CHECK_HEADERS([hdfs.h hadoop/hdfs.h]) 1444 | fi 1445 | AM_CONDITIONAL(ENABLE_OMHDFS, test x$enable_omhdfs = xyes) 1446 | 1447 | 1448 | # support for omkafka 1449 | AC_ARG_ENABLE(omkafka, 1450 | [AS_HELP_STRING([--enable-omkafka],[Compiles omkafka module @<:@default=no@:>@])], 1451 | [case "${enableval}" in 1452 | yes) enable_omkafka="yes" ;; 1453 | no) enable_omkafka="no" ;; 1454 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omkafka) ;; 1455 | esac], 1456 | [enable_omkafka=no] 1457 | ) 1458 | if test "x$enable_omkafka"; then 1459 | #PKG_CHECK_MODULES(LIBRDKAFKA, librdkafka) 1460 | AC_CHECK_HEADERS([librdkafka/rdkafka.h]) 1461 | fi 1462 | AM_CONDITIONAL(ENABLE_OMKAFKA, test x$enable_omkafka = xyes) 1463 | 1464 | 1465 | #MONGODB SUPPORT 1466 | 1467 | AC_ARG_ENABLE(ommongodb, 1468 | [AS_HELP_STRING([--enable-ommongodb],[Compiles ommongodb module @<:@default=no@:>@])], 1469 | [case "${enableval}" in 1470 | yes) enable_ommongodb="yes" ;; 1471 | no) enable_ommongodb="no" ;; 1472 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-ommongodb) ;; 1473 | esac], 1474 | [enable_ommongodb=no] 1475 | ) 1476 | if test "x$enable_ommongodb" = "xyes"; then 1477 | PKG_CHECK_MODULES(LIBMONGO_CLIENT, libmongo-client >= 0.1.4) 1478 | fi 1479 | AM_CONDITIONAL(ENABLE_OMMONGODB, test x$enable_ommongodb = xyes) 1480 | # end of mongodb code 1481 | 1482 | # BEGIN ZMQ3 INPUT SUPPORT 1483 | AC_ARG_ENABLE(imzmq3, 1484 | [AS_HELP_STRING([--enable-imzmq3],[Compiles imzmq3 output module @<:@default=no@:>@])], 1485 | [case "${enableval}" in 1486 | yes) enable_imzmq3="yes" ;; 1487 | no) enable_imzmq3="no" ;; 1488 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-imzmq3) ;; 1489 | esac], 1490 | [enable_imzmq3=no] 1491 | ) 1492 | if test "x$enable_imzmq3" = "xyes"; then 1493 | PKG_CHECK_MODULES(CZMQ, libczmq >= 1.1.0) 1494 | fi 1495 | AM_CONDITIONAL(ENABLE_IMZMQ3, test x$enable_imzmq3 = xyes) 1496 | 1497 | # END ZMQ3 INPUT SUPPORT 1498 | 1499 | # BEGIN CZMQ INPUT SUPPORT 1500 | AC_ARG_ENABLE(imczmq, 1501 | [AS_HELP_STRING([--enable-imczmq],[Compiles imczmq output module @<:@default=no@:>@])], 1502 | [case "${enableval}" in 1503 | yes) enable_imczmq="yes" ;; 1504 | no) enable_imczmq="no" ;; 1505 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-imczmq) ;; 1506 | esac], 1507 | [enable_imczmq=no] 1508 | ) 1509 | if test "x$enable_imczmq" = "xyes"; then 1510 | PKG_CHECK_MODULES(CZMQ, libczmq >= 3.0.0) 1511 | fi 1512 | AM_CONDITIONAL(ENABLE_IMCZMQ, test x$enable_imczmq = xyes) 1513 | 1514 | # END CZMQ INPUT 1515 | 1516 | # BEGIN ZMQ3 OUTPUT SUPPORT 1517 | AC_ARG_ENABLE(omzmq3, 1518 | [AS_HELP_STRING([--enable-omzmq3],[Compiles omzmq3 output module @<:@default=no@:>@])], 1519 | [case "${enableval}" in 1520 | yes) enable_omzmq3="yes" ;; 1521 | no) enable_omzmq3="no" ;; 1522 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omzmq3) ;; 1523 | esac], 1524 | [enable_omzmq3=no] 1525 | ) 1526 | if test "x$enable_omzmq3" = "xyes"; then 1527 | PKG_CHECK_MODULES(CZMQ, libczmq >= 1.1.0) 1528 | fi 1529 | AM_CONDITIONAL(ENABLE_OMZMQ3, test x$enable_omzmq3 = xyes) 1530 | 1531 | # END ZMQ3 SUPPORT 1532 | 1533 | # BEGIN CZMQ OUTPUT SUPPORT 1534 | AC_ARG_ENABLE(omczmq, 1535 | [AS_HELP_STRING([--enable-omczmq],[Compiles omczmq output module @<:@default=no@:>@])], 1536 | [case "${enableval}" in 1537 | yes) enable_omczmq="yes" ;; 1538 | no) enable_omczmq="no" ;; 1539 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omzmq3) ;; 1540 | esac], 1541 | [enable_omczmq=no] 1542 | ) 1543 | if test "x$enable_omczmq" = "xyes"; then 1544 | PKG_CHECK_MODULES(CZMQ, libczmq >= 3.0.0) 1545 | fi 1546 | AM_CONDITIONAL(ENABLE_OMCZMQ, test x$enable_omczmq = xyes) 1547 | 1548 | # END CZMQ SUPPORT 1549 | 1550 | 1551 | # BEGIN RABBITMQ OUTPUT SUPPORT 1552 | 1553 | AC_ARG_ENABLE(omrabbitmq, 1554 | [AS_HELP_STRING([--enable-omrabbitmq],[Compiles omrabbitmq output module @<:@default=no@:>@])], 1555 | [case "${enableval}" in 1556 | yes) enable_omrabbitmq="yes" ;; 1557 | no) enable_omrabbitmq="no" ;; 1558 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omrabbitmq) ;; 1559 | esac], 1560 | [enable_omrabbitmq=no] 1561 | ) 1562 | if test "x$enable_omrabbitmq" = "xyes"; then 1563 | PKG_CHECK_MODULES(RABBITMQ, librabbitmq >= 0.2.0) 1564 | AC_SUBST(RABBITMQ_CFLAGS) 1565 | AC_SUBST(RABBITMQ_LIBS) 1566 | fi 1567 | AM_CONDITIONAL(ENABLE_OMRABBITMQ, test x$enable_omrabbitmq = xyes) 1568 | 1569 | # END RABBITMQ SUPPORT 1570 | 1571 | # HIREDIS SUPPORT 1572 | 1573 | AC_ARG_ENABLE(omhiredis, 1574 | [AS_HELP_STRING([--enable-omhiredis],[Compiles omhiredis template module @<:@default=no@:>@])], 1575 | [case "${enableval}" in 1576 | yes) enable_omhiredis="yes" ;; 1577 | no) enable_omhiredis="no" ;; 1578 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omhiredis) ;; 1579 | esac], 1580 | [enable_omhiredis=no] 1581 | ) 1582 | # 1583 | if test "x$enable_omhiredis" = "xyes"; then 1584 | PKG_CHECK_MODULES(HIREDIS, hiredis >= 0.10.1) 1585 | fi 1586 | AM_CONDITIONAL(ENABLE_OMHIREDIS, test x$enable_omhiredis = xyes) 1587 | 1588 | # END HIREDIS SUPPORT 1589 | 1590 | 1591 | # HTTPFS SUPPORT 1592 | 1593 | AC_ARG_ENABLE(omhttpfs, 1594 | [AS_HELP_STRING([--enable-omhttpfs],[Compiles omhttpfs template module @<:@default=no@:>@])], 1595 | [case "${enableval}" in 1596 | yes) enable_omhttpfs="yes" ;; 1597 | no) enable_omhttpfs="no" ;; 1598 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-omhttpfs) ;; 1599 | esac], 1600 | [enable_omhttpfs=no] 1601 | ) 1602 | 1603 | if test "x$enable_omhttpfs" = "xyes"; then 1604 | AC_CHECK_HEADERS([curl/curl.h]) 1605 | PKG_CHECK_MODULES([CURL], [libcurl]) 1606 | LT_LIB_M 1607 | #PKG_CHECK_MODULES(HTTPFS, curl >= 7.0.0) 1608 | fi 1609 | AM_CONDITIONAL(ENABLE_OMHTTPFS, test x$enable_omhttpfs = xyes) 1610 | 1611 | # END HTTPFS SUPPORT 1612 | 1613 | # man pages 1614 | AC_CHECKING([if required man pages already exist]) 1615 | have_to_generate_man_pages="no" 1616 | AC_ARG_ENABLE(generate-man-pages, 1617 | [AS_HELP_STRING([--enable-generate-man-pages],[Generate man pages from source @<:@default=no@:>@])], 1618 | [case "${enableval}" in 1619 | yes) have_to_generate_man_pages="yes" ;; 1620 | no) have_to_generate_man_pages="no" ;; 1621 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-generate-man-pages) ;; 1622 | esac], 1623 | [have_to_generate_man_pages=no] 1624 | ) 1625 | 1626 | 1627 | # This provides a work-around to use "make distcheck" by disabling 1628 | # some tests that do have problems with the distcheck environment. 1629 | AC_ARG_ENABLE(distcheck-workaround, 1630 | [AS_HELP_STRING([--enable-distcheck-workaround],[enable to use make distcheck by disabling some tests that do not support the distcheck environment @<:@default=no@:>@])], 1631 | [case "${enableval}" in 1632 | yes) enable_distcheck_workaround="yes" ;; 1633 | no) enable_distcheck_workaround="no" ;; 1634 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-distcheck_workaround) ;; 1635 | esac], 1636 | [enable_distcheck_workaround="no"] 1637 | ) 1638 | AM_CONDITIONAL(ENABLE_DISTCHECK_WORKAROUND, test x$enable_distcheck_workaround = xyes) 1639 | 1640 | 1641 | # Running from git source? 1642 | in_git_src=no 1643 | AS_IF([test -d "$srcdir"/.git && ! test -f "$srcdir"/.tarball-version], [in_git_src=yes]) 1644 | 1645 | if test "x$in_git_src" = "xyes"; then 1646 | AC_MSG_NOTICE([Running from git source]) 1647 | 1648 | have_to_generate_man_pages=yes 1649 | 1650 | if test "x$LEX" != "xflex"; then 1651 | AC_MSG_ERROR([flex program is needed to build rsyslog, please install flex.]) 1652 | fi 1653 | 1654 | if test "x$YACC" = "xyacc"; then 1655 | # AC_PROG_YACC only checks for yacc replacements, not for yacc itself 1656 | AC_CHECK_PROG([YACC_FOUND], [yacc], [yes], [no]) 1657 | if test "x$YACC_FOUND" = "xno"; then 1658 | AC_MSG_ERROR([A yacc program is needed to build rsyslog, please install bison.]) 1659 | fi 1660 | fi 1661 | else 1662 | AC_MSG_NOTICE([Not running from git source]) 1663 | fi 1664 | 1665 | AM_CONDITIONAL(ENABLE_GENERATE_MAN_PAGES, test x$have_to_generate_man_pages = xyes) 1666 | 1667 | # rst2man 1668 | AC_CHECK_PROGS([RST2MAN], [rst2man rst2man.py], [false]) 1669 | if test "x$have_to_generate_man_pages" = "xyes" && test "x$RST2MAN" = "xfalse"; then 1670 | AC_MSG_ERROR([rst2man is required when building from git source or --enable-generate-man-pages option was set, please install python-docutils.]) 1671 | fi 1672 | 1673 | 1674 | AC_CONFIG_FILES([Makefile \ 1675 | runtime/Makefile \ 1676 | compat/Makefile \ 1677 | grammar/Makefile \ 1678 | tools/Makefile \ 1679 | plugins/imudp/Makefile \ 1680 | plugins/imtcp/Makefile \ 1681 | plugins/im3195/Makefile \ 1682 | plugins/imgssapi/Makefile \ 1683 | plugins/imuxsock/Makefile \ 1684 | plugins/imjournal/Makefile \ 1685 | plugins/immark/Makefile \ 1686 | plugins/imklog/Makefile \ 1687 | plugins/omhdfs/Makefile \ 1688 | plugins/omkafka/Makefile \ 1689 | plugins/omprog/Makefile \ 1690 | plugins/mmexternal/Makefile \ 1691 | plugins/omstdout/Makefile \ 1692 | plugins/omjournal/Makefile \ 1693 | plugins/pmciscoios/Makefile \ 1694 | plugins/omruleset/Makefile \ 1695 | plugins/omuxsock/Makefile \ 1696 | plugins/imfile/Makefile \ 1697 | plugins/imsolaris/Makefile \ 1698 | plugins/imptcp/Makefile \ 1699 | plugins/impstats/Makefile \ 1700 | plugins/imrelp/Makefile \ 1701 | plugins/imdiag/Makefile \ 1702 | plugins/omtesting/Makefile \ 1703 | plugins/omgssapi/Makefile \ 1704 | plugins/ommysql/Makefile \ 1705 | plugins/ompgsql/Makefile \ 1706 | plugins/omrelp/Makefile \ 1707 | plugins/omlibdbi/Makefile \ 1708 | plugins/ommail/Makefile \ 1709 | plugins/omsnmp/Makefile \ 1710 | plugins/omudpspoof/Makefile \ 1711 | plugins/ommongodb/Makefile \ 1712 | plugins/mmnormalize/Makefile \ 1713 | plugins/mmjsonparse/Makefile \ 1714 | plugins/mmaudit/Makefile \ 1715 | plugins/mmanon/Makefile \ 1716 | plugins/mmutf8fix/Makefile \ 1717 | plugins/mmfields/Makefile \ 1718 | plugins/mmpstrucdata/Makefile \ 1719 | plugins/mmgrok/Makefile \ 1720 | plugins/omelasticsearch/Makefile \ 1721 | plugins/mmsnmptrapd/Makefile \ 1722 | plugins/pmlastmsg/Makefile \ 1723 | contrib/pmsnare/Makefile \ 1724 | contrib/pmaixforwardedfrom/Makefile \ 1725 | contrib/omhiredis/Makefile \ 1726 | contrib/omrabbitmq/Makefile \ 1727 | contrib/imkmsg/Makefile \ 1728 | contrib/mmcount/Makefile \ 1729 | contrib/omzmq3/Makefile \ 1730 | contrib/omczmq/Makefile \ 1731 | contrib/imzmq3/Makefile \ 1732 | contrib/imczmq/Makefile \ 1733 | contrib/mmsequence/Makefile \ 1734 | contrib/mmrfc5424addhmac/Makefile \ 1735 | contrib/pmcisconames/Makefile \ 1736 | contrib/omhttpfs/Makefile \ 1737 | tests/Makefile]) 1738 | AC_OUTPUT 1739 | 1740 | echo "****************************************************" 1741 | echo "rsyslog will be compiled with the following settings:" 1742 | echo 1743 | echo " Large file support enabled: $enable_largefile" 1744 | echo " Networking support enabled: $enable_inet" 1745 | echo " Regular expressions support enabled: $enable_regexp" 1746 | echo " rsyslog runtime will be built: $enable_rsyslogrt" 1747 | echo " rsyslogd will be built: $enable_rsyslogd" 1748 | echo " have to generate man pages: $have_to_generate_man_pages" 1749 | echo " Unlimited select() support enabled: $enable_unlimited_select" 1750 | echo " uuid support enabled: $enable_uuid" 1751 | echo " Log file signing support: $enable_guardtime" 1752 | echo " Log file signing support via KSI: $enable_gt_ksi" 1753 | echo " Log file encryption support: $enable_libgcrypt" 1754 | echo " anonymization support enabled: $enable_mmanon" 1755 | echo " message counting support enabled: $enable_mmcount" 1756 | echo " mmfields enabled: $enable_mmfields" 1757 | echo " liblogging-stdlog support enabled: $enable_liblogging_stdlog" 1758 | echo 1759 | echo "---{ input plugins }---" 1760 | echo " Klog functionality enabled: $enable_klog ($os_type)" 1761 | echo " /dev/kmsg functionality enabled: $enable_kmsg" 1762 | echo " plain tcp input module enabled: $enable_imptcp" 1763 | echo " imdiag enabled: $enable_imdiag" 1764 | echo " file input module enabled: $enable_imfile" 1765 | echo " Solaris input module enabled: $enable_imsolaris" 1766 | echo " periodic statistics module enabled: $enable_impstats" 1767 | echo " imzmq3 input module enabled: $enable_imzmq3" 1768 | echo " imczmq input module enabled: $enable_imczmq" 1769 | echo " imjournal input module enabled: $enable_imjournal" 1770 | echo 1771 | echo "---{ output plugins }---" 1772 | echo " Mail support enabled: $enable_mail" 1773 | echo " omkafka module will be compiled: $enable_omkafka" 1774 | echo " omprog module will be compiled: $enable_omprog" 1775 | echo " omstdout module will be compiled: $enable_omstdout" 1776 | echo " omjournal module will be compiled: $enable_omjournal" 1777 | echo " omhdfs module will be compiled: $enable_omhdfs" 1778 | echo " omelasticsearch module will be compiled: $enable_elasticsearch" 1779 | echo " omruleset module will be compiled: $enable_omruleset" 1780 | echo " omudpspoof module will be compiled: $enable_omudpspoof" 1781 | echo " omuxsock module will be compiled: $enable_omuxsock" 1782 | echo " omzmq3 module will be compiled: $enable_omzmq3" 1783 | echo " omczmq module will be compiled: $enable_omczmq" 1784 | echo " omrabbitmq module will be compiled: $enable_omrabbitmq" 1785 | echo " omhttpfs module will be compiled: $enable_omhttpfs" 1786 | echo 1787 | echo "---{ parser modules }---" 1788 | echo " pmlastmsg module will be compiled: $enable_pmlastmsg" 1789 | echo " pmcisconames module will be compiled: $enable_pmcisconames" 1790 | echo " pmciscoios module will be compiled: $enable_pmciscoios" 1791 | echo " pmaixforwardedfrom module w.be compiled: $enable_pmaixforwardedfrom" 1792 | echo " pmsnare module will be compiled: $enable_pmsnare" 1793 | echo 1794 | echo "---{ message modification modules }---" 1795 | echo " mmnormalize module will be compiled: $enable_mmnormalize" 1796 | echo " mmjsonparse module will be compiled: $enable_mmjsonparse" 1797 | echo " mmjaduit module will be compiled: $enable_mmaudit" 1798 | echo " mmsnmptrapd module will be compiled: $enable_mmsnmptrapd" 1799 | echo " mmutf8fix enabled: $enable_mmutf8fix" 1800 | echo " mmgrok enabled: $enable_mmgrok" 1801 | echo " mmrfc5424addhmac enabled: $enable_mmrfc5424addhmac" 1802 | echo " mmpstrucdata enabled: $enable_mmpstrucdata" 1803 | echo " mmsequence enabled: $enable_mmsequence" 1804 | echo 1805 | echo "---{ database support }---" 1806 | echo " MySql support enabled: $enable_mysql" 1807 | echo " libdbi support enabled: $enable_libdbi" 1808 | echo " PostgreSQL support enabled: $enable_pgsql" 1809 | echo " mongodb support enabled: $enable_ommongodb" 1810 | echo " hiredis support enabled: $enable_omhiredis" 1811 | echo 1812 | echo "---{ protocol support }---" 1813 | echo " GnuTLS network stream driver enabled: $enable_gnutls" 1814 | echo " GSSAPI Kerberos 5 support enabled: $enable_gssapi_krb5" 1815 | echo " RELP support enabled: $enable_relp" 1816 | echo " SNMP support enabled: $enable_snmp" 1817 | echo 1818 | echo "---{ debugging support }---" 1819 | echo " Testbench enabled: $enable_testbench" 1820 | echo " Extended Testbench enabled: $enable_extended_tests" 1821 | echo " MySQL Tests enabled: $enable_mysql_tests" 1822 | echo " Debug mode enabled: $enable_debug" 1823 | echo " Runtime Instrumentation enabled: $enable_rtinst" 1824 | echo " (total) debugless mode enabled: $enable_debugless" 1825 | echo " Diagnostic tools enabled: $enable_diagtools" 1826 | echo " End-User tools enabled: $enable_usertools" 1827 | echo " Enhanced memory checking enabled: $enable_memcheck" 1828 | echo " Valgrind support settings enabled: $enable_valgrind" 1829 | echo 1830 | -------------------------------------------------------------------------------- /src/contrib/mmgrok/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglib_LTLIBRARIES = mmgrok.la 2 | 3 | mmgrok_la_SOURCES = mmgrok.c 4 | mmgrok_la_CPPFLAGS = $(RSRT_CFLAGS) $(PTHREADS_CFLAGS) 5 | mmgrok_la_LDFLAGS = -module -avoid-version 6 | mmgrok_la_LIBADD = -lglib-2.0 -lgrok -ljson-c 7 | 8 | EXTRA_DIST = 9 | -------------------------------------------------------------------------------- /src/contrib/mmgrok/mmgrok.c: -------------------------------------------------------------------------------- 1 | /* mmgrok.c 2 | * Grok the message is parsed into a structured json data inside JSON. 3 | */ 4 | #include "config.h" 5 | #include "rsyslog.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "conf.h" 19 | #include "syslogd-types.h" 20 | #include "template.h" 21 | #include "module-template.h" 22 | #include "errmsg.h" 23 | #include "cfsysline.h" 24 | #include "dirty.h" 25 | 26 | MODULE_TYPE_OUTPUT 27 | MODULE_TYPE_NOKEEP 28 | MODULE_CNFNAME("mmgrok"); 29 | 30 | static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal); 31 | 32 | DEFobjCurrIf(errmsg); 33 | DEF_OMOD_STATIC_DATA 34 | 35 | typedef struct result_s{ 36 | char *key; 37 | int key_len; 38 | const char *value; 39 | int value_len; 40 | char *type; 41 | }result_t; 42 | 43 | /* config variables */ 44 | typedef struct _instanceData 45 | { 46 | char *pszPatternDir; 47 | char *pszMatch; 48 | char *pszSource; 49 | char *pszTarget;/* as a json root for store parse json data */ 50 | msg_t *pmsg; /* store origin messages*/ 51 | }instanceData; 52 | 53 | typedef struct wrkrInstanceData{ 54 | instanceData *pData; 55 | }wrkrInstanceData_t; 56 | 57 | struct modConfData_s{ 58 | rsconf_t *pConf;/* our overall config object */ 59 | }; 60 | 61 | static modConfData_t *loadModConf = NULL; 62 | static modConfData_t *runModConf = NULL; 63 | 64 | /* action (instance) paramters */ 65 | static struct cnfparamdescr actpdescr[]={ 66 | {"patterndir",eCmdHdlrString,0}, 67 | {"match",eCmdHdlrString,0}, 68 | {"source",eCmdHdlrString,0}, 69 | {"target",eCmdHdlrString,0}, 70 | }; 71 | 72 | static struct cnfparamblk actpblk = 73 | { 74 | CNFPARAMBLK_VERSION, 75 | sizeof(actpdescr)/sizeof(struct cnfparamdescr), 76 | actpdescr 77 | }; 78 | 79 | BEGINbeginCnfLoad 80 | CODESTARTbeginCnfLoad 81 | loadModConf = pModConf; 82 | pModConf->pConf = pConf; 83 | ENDbeginCnfLoad 84 | 85 | BEGINendCnfLoad 86 | CODESTARTendCnfLoad 87 | ENDendCnfLoad 88 | 89 | BEGINcheckCnf 90 | CODESTARTcheckCnf 91 | ENDcheckCnf 92 | 93 | BEGINactivateCnf 94 | CODESTARTactivateCnf 95 | runModConf = pModConf; 96 | ENDactivateCnf 97 | 98 | BEGINfreeCnf 99 | CODESTARTfreeCnf 100 | ENDfreeCnf 101 | 102 | BEGINcreateInstance 103 | CODESTARTcreateInstance 104 | ENDcreateInstance 105 | 106 | BEGINcreateWrkrInstance 107 | CODESTARTcreateWrkrInstance 108 | ENDcreateWrkrInstance 109 | 110 | BEGINisCompatibleWithFeature 111 | CODESTARTisCompatibleWithFeature 112 | ENDisCompatibleWithFeature 113 | 114 | BEGINfreeInstance 115 | CODESTARTfreeInstance 116 | free(pData->pszPatternDir); 117 | free(pData->pszMatch); 118 | free(pData->pszSource); 119 | free(pData->pszTarget); 120 | ENDfreeInstance 121 | 122 | BEGINfreeWrkrInstance 123 | CODESTARTfreeWrkrInstance 124 | ENDfreeWrkrInstance 125 | 126 | 127 | static inline void setInstParamDefaults(instanceData *pData) 128 | { 129 | pData->pszPatternDir= NULL; 130 | pData->pszMatch = NULL; 131 | pData->pszSource = NULL; 132 | pData->pszTarget = NULL; 133 | pData->pmsg = NULL; 134 | } 135 | 136 | 137 | BEGINnewActInst 138 | struct cnfparamvals *pvals; 139 | int i; 140 | CODESTARTnewActInst 141 | DBGPRINTF("newActInst (mmgrok)\n"); 142 | if((pvals = nvlstGetParams(lst, &actpblk, NULL)) == NULL) { 143 | ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS); 144 | } 145 | 146 | CODE_STD_STRING_REQUESTnewActInst(1) 147 | CHKiRet(OMSRsetEntry(*ppOMSR, 0, NULL, OMSR_TPL_AS_MSG)); 148 | CHKiRet(createInstance(&pData)); 149 | setInstParamDefaults(pData); 150 | 151 | for(i = 0 ; i < actpblk.nParams ; ++i) { 152 | if(!pvals[i].bUsed) 153 | continue; 154 | if(!strcmp(actpblk.descr[i].name, "patterndir")) { 155 | pData->pszPatternDir= es_str2cstr(pvals[i].val.d.estr, NULL); 156 | continue; 157 | } 158 | else if(!strcmp(actpblk.descr[i].name, "match")) { 159 | pData->pszMatch = es_str2cstr(pvals[i].val.d.estr, NULL); 160 | continue; 161 | } 162 | else if(!strcmp(actpblk.descr[i].name, "source")) { 163 | pData->pszSource= es_str2cstr(pvals[i].val.d.estr, NULL); 164 | continue; 165 | } 166 | else if(!strcmp(actpblk.descr[i].name,"target")) 167 | { 168 | pData->pszTarget=es_str2cstr(pvals[i].val.d.estr,NULL); 169 | continue; 170 | } 171 | else{ 172 | DBGPRINTF("mmgrok: program error, non-handled " 173 | "param '%s'\n", actpblk.descr[i].name); 174 | } 175 | } 176 | if(pData->pszTarget == NULL) { 177 | CHKmalloc(pData->pszTarget = strdup("!")); 178 | } 179 | CODE_STD_FINALIZERnewActInst 180 | cnfparamvalsDestruct(pvals, &actpblk); 181 | ENDnewActInst 182 | 183 | BEGINdbgPrintInstInfo 184 | CODESTARTdbgPrintInstInfo 185 | DBGPRINTF("mmgrok\n"); 186 | ENDdbgPrintInstInfo 187 | 188 | BEGINtryResume 189 | CODESTARTtryResume 190 | ENDtryResume 191 | 192 | static inline grok_t *CreateGrok() 193 | { 194 | grok_t *grok = grok_new(); 195 | if(grok == NULL){ 196 | DBGPRINTF("mmgrok: create a grok faile!"); 197 | exit(1); 198 | } 199 | grok_init(grok); 200 | return grok; 201 | } 202 | 203 | /* the parseing is complate message into json */ 204 | static rsRetVal 205 | msg_to_json(GList *list,instanceData *pData) 206 | { 207 | GList *it= list; 208 | 209 | struct json_object *json; 210 | struct json_object *jval; 211 | 212 | DEFiRet; 213 | 214 | json = json_object_new_object(); 215 | if(json == NULL) 216 | { 217 | ABORT_FINALIZE(RS_RET_ERR); 218 | } 219 | for(;it;it= it->next) 220 | { 221 | char *key = (char *)malloc(sizeof(char *)*((result_t *)it->data)->key_len); 222 | sprintf(key,"%.*s",((result_t *)it->data)->key_len,((result_t *)it->data)->key); 223 | char *value = (char *)malloc(sizeof(char *)*((result_t *)it->data)->value_len); 224 | sprintf(value,"%.*s", ((result_t*)it->data)->value_len,((result_t*)it->data)->value); 225 | jval = json_object_new_string(value); 226 | json_object_object_add(json,key,jval); 227 | free(key); 228 | free(value); 229 | } 230 | msgAddJSON(pData->pmsg,(uchar*)pData->pszTarget,json,0,0); 231 | finalize_it: 232 | RETiRet; 233 | } 234 | 235 | /* store parse result ,use list in glib*/ 236 | static rsRetVal 237 | parse_result_store(const grok_match_t gm,instanceData *pData) 238 | { 239 | GList *re_list = NULL; 240 | char *pname; 241 | const char *pdata; 242 | int pname_len,pdata_len; 243 | bool is_append = true; 244 | 245 | char *key; 246 | char *type; 247 | DEFiRet; 248 | 249 | grok_match_walk_init(&gm); //grok API 250 | 251 | while(grok_match_walk_next(&gm,&pname,&pname_len,&pdata,&pdata_len) == 0) 252 | { 253 | /* parse key and value type from patterns */ 254 | key = strchr(pname,':'); 255 | 256 | if(key!=NULL) 257 | { 258 | int key_len; 259 | result_t *result = g_new0(result_t,1); 260 | key_len = pname_len - ((key+1) - pname); 261 | key = key+1; 262 | pname_len = key_len; 263 | type = strchr(key,':'); 264 | int type_len; 265 | if(type!=NULL) 266 | { 267 | key_len = (type - key); 268 | type = type+1; 269 | type_len = pname_len - key_len -1; 270 | sprintf(type,"%.*s",type_len,type); 271 | } 272 | else{type = "null";} 273 | /* store parse result into list */ 274 | result->key = key; 275 | result->key_len = key_len; 276 | result->value = pdata; 277 | result->value_len = pdata_len; 278 | result->type = type; 279 | /* the value of merger the same key*/ 280 | re_list = g_list_append(re_list,result); 281 | } 282 | } 283 | msg_to_json(re_list,pData); 284 | g_list_free(re_list); 285 | grok_match_walk_end(&gm); 286 | RETiRet; 287 | } 288 | 289 | /* motify message for per line */ 290 | static rsRetVal 291 | MotifyLine(char *line,grok_t *grok,instanceData *pData) 292 | { 293 | grok_match_t gm; 294 | DEFiRet; 295 | grok_patterns_import_from_file(grok,pData->pszPatternDir); 296 | int compile = grok_compile(grok,pData->pszMatch); 297 | if(compile!=GROK_OK) 298 | { 299 | DBGPRINTF("mmgrok: grok_compile faile!exit code: %d\n",compile); 300 | ABORT_FINALIZE(RS_RET_ERR); 301 | } 302 | int exe = grok_exec(grok,line,&gm); 303 | if(exe!=GROK_OK) 304 | { 305 | DBGPRINTF("mmgrok: grok_exec faile!exit code: %d\n",exe); 306 | ABORT_FINALIZE(RS_RET_ERR); 307 | } 308 | parse_result_store(gm,pData); 309 | finalize_it: 310 | RETiRet; 311 | } 312 | 313 | /* motify rsyslog messages */ 314 | static rsRetVal 315 | MotifyMessage(instanceData *pData) 316 | { 317 | DEFiRet; 318 | grok_t *grok = CreateGrok(); 319 | char *msg = strdup(pData->pszSource); 320 | char *line = NULL; 321 | line = strtok(msg,"\n"); 322 | while(line!=NULL) 323 | { 324 | MotifyLine(line,grok,pData); 325 | line = strtok(NULL,"\n"); 326 | } 327 | free(msg);msg=NULL; 328 | RETiRet; 329 | } 330 | 331 | 332 | BEGINdoAction 333 | msg_t *pMsg; 334 | uchar *buf; 335 | instanceData *pData; 336 | 337 | CODESTARTdoAction 338 | pData = pWrkrData->pData; 339 | pMsg = (msg_t*) ppString[0]; 340 | buf = getMSG(pMsg); 341 | pData->pmsg = pMsg; 342 | while(*buf && isspace(*buf)) { 343 | ++buf; 344 | } 345 | 346 | if(*buf == '\0' ) { 347 | DBGPRINTF("mmgrok: not msg for mmgrok!"); 348 | ABORT_FINALIZE(RS_RET_NO_CEE_MSG); 349 | } 350 | pData->pszSource = (char *)buf; 351 | CHKiRet(MotifyMessage(pData)); 352 | 353 | finalize_it: 354 | ENDdoAction 355 | 356 | BEGINparseSelectorAct 357 | CODESTARTparseSelectorAct 358 | CODE_STD_STRING_REQUESTparseSelectorAct(1) 359 | if(strncmp((char*) p, ":mmgrok:", sizeof(":mmgrok:") - 1)) { 360 | ABORT_FINALIZE(RS_RET_CONFLINE_UNPROCESSED); 361 | } 362 | 363 | p += sizeof(":mmgrok:") - 1; /* eat indicator sequence (-1 because of '\0'!) */ 364 | CHKiRet(createInstance(&pData)); 365 | 366 | if(*(p-1) == ';') 367 | --p; 368 | CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_TPL_AS_MSG, (uchar*) "RSYSLOG_FileFormat")); 369 | CODE_STD_FINALIZERparseSelectorAct 370 | ENDparseSelectorAct 371 | 372 | BEGINmodExit 373 | CODESTARTmodExit 374 | objRelease(errmsg, CORE_COMPONENT); 375 | ENDmodExit 376 | 377 | 378 | BEGINqueryEtryPt 379 | CODESTARTqueryEtryPt 380 | CODEqueryEtryPt_STD_OMOD_QUERIES 381 | CODEqueryEtryPt_STD_OMOD8_QUERIES 382 | CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES 383 | CODEqueryEtryPt_STD_CONF2_QUERIES 384 | ENDqueryEtryPt 385 | 386 | static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal) 387 | { 388 | DEFiRet; 389 | RETiRet; 390 | } 391 | 392 | BEGINmodInit() 393 | rsRetVal localRet; 394 | rsRetVal (*pomsrGetSupportedTplOpts)(unsigned long *pOpts); 395 | unsigned long opts; 396 | int bMsgPassingSupported; 397 | CODESTARTmodInit 398 | *ipIFVersProvided = CURR_MOD_IF_VERSION; 399 | CODEmodInit_QueryRegCFSLineHdlr 400 | DBGPRINTF("mmgrok: module compiled with rsyslog version %s.\n", VERSION); 401 | bMsgPassingSupported = 0; 402 | localRet = pHostQueryEtryPt((uchar*)"OMSRgetSupportedTplOpts", 403 | &pomsrGetSupportedTplOpts); 404 | if(localRet == RS_RET_OK) { 405 | CHKiRet((*pomsrGetSupportedTplOpts)(&opts)); 406 | if(opts & OMSR_TPL_AS_MSG) 407 | bMsgPassingSupported = 1; 408 | } else if(localRet != RS_RET_ENTRY_POINT_NOT_FOUND) { 409 | ABORT_FINALIZE(localRet); /* Something else went wrong, not acceptable */ 410 | } 411 | 412 | if(!bMsgPassingSupported) { 413 | DBGPRINTF("mmgrok: msg-passing is not supported by rsyslog core, " 414 | "can not continue.\n"); 415 | ABORT_FINALIZE(RS_RET_NO_MSG_PASSING); 416 | } 417 | 418 | CHKiRet(objUse(errmsg, CORE_COMPONENT)); 419 | 420 | CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, 421 | resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID)); 422 | ENDmodInit 423 | --------------------------------------------------------------------------------