2019-02-25 15:09:36 +01:00
|
|
|
# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
|
2013-11-03 13:45:26 +01:00
|
|
|
|
2018-01-18 13:50:38 +01:00
|
|
|
mkclass_target(application.ti application-ti.cpp application-ti.hpp)
|
|
|
|
mkclass_target(configobject.ti configobject-ti.cpp configobject-ti.hpp)
|
2018-08-09 15:37:23 +02:00
|
|
|
mkclass_target(configuration.ti configuration-ti.cpp configuration-ti.hpp)
|
2018-01-18 13:50:38 +01:00
|
|
|
mkclass_target(datetime.ti datetime-ti.cpp datetime-ti.hpp)
|
|
|
|
mkclass_target(filelogger.ti filelogger-ti.cpp filelogger-ti.hpp)
|
|
|
|
mkclass_target(function.ti function-ti.cpp function-ti.hpp)
|
Add a JournaldLogger
As proposed in #8857, this adds a Logger subclass that writes structured
log messages via journald's native protocol by calling sd_journal_sendv.
The feature therefore depends on the systemd library. sd_journal_sendv is
available since the early days (systemd v38), so a version check is
probably superflous.
We add the following fields to each record:
- MESSAGE: The log message
- PRIORITY (aka severity): Numeric severity as in RFC5424 section 6.2.1
- SYSLOG_FACILITY: Numeric facility as in RFC5424 section 6.2.1
- SYSLOG_IDENTIFIER: If provided, use value from configuration.
Else use systemd's default behaior, which is to determine the field
by using libc's program_invocation_short_name, resulting in "icinga2".
- ICINGA2_FACILITY: Facility as in Log::Log(..., String facility, ...),
e.g. "ApiListener"
- some more fields are added automatically by systemd
Fields are stored indexed, so we can do fast queries for certain field
values. Example:
$ journalctl -t icinga2 ICINGA2_FACILITY=ApiListener -n 5
Syslog compatiblity is ratained because good old tag, severity and facility
is stored along, and systemd can forward to syslog daemons.
See also https://systemd.io/JOURNAL_NATIVE_PROTOCOL/.
2021-09-10 20:54:31 +02:00
|
|
|
mkclass_target(journaldlogger.ti journaldlogger-ti.cpp journaldlogger-ti.hpp)
|
2018-01-18 13:50:38 +01:00
|
|
|
mkclass_target(logger.ti logger-ti.cpp logger-ti.hpp)
|
|
|
|
mkclass_target(perfdatavalue.ti perfdatavalue-ti.cpp perfdatavalue-ti.hpp)
|
|
|
|
mkclass_target(streamlogger.ti streamlogger-ti.cpp streamlogger-ti.hpp)
|
|
|
|
mkclass_target(sysloglogger.ti sysloglogger-ti.cpp sysloglogger-ti.hpp)
|
2013-11-03 13:45:26 +01:00
|
|
|
|
2014-08-30 18:08:28 +02:00
|
|
|
set(base_SOURCES
|
2017-12-24 08:18:33 +01:00
|
|
|
i2-base.hpp
|
2018-08-10 10:15:41 +02:00
|
|
|
application.cpp application.hpp application-ti.hpp application-version.cpp application-environment.cpp
|
2017-12-24 08:18:33 +01:00
|
|
|
array.cpp array.hpp array-script.cpp
|
2019-07-16 11:28:20 +02:00
|
|
|
atomic.hpp
|
2022-07-21 17:53:08 +02:00
|
|
|
atomic-file.cpp atomic-file.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
base64.cpp base64.hpp
|
|
|
|
boolean.cpp boolean.hpp boolean-script.cpp
|
2022-01-19 16:28:07 +01:00
|
|
|
bulker.hpp
|
2018-01-18 13:50:38 +01:00
|
|
|
configobject.cpp configobject.hpp configobject-ti.hpp configobject-script.cpp
|
2017-12-24 08:18:33 +01:00
|
|
|
configtype.cpp configtype.hpp
|
2018-08-09 15:37:23 +02:00
|
|
|
configuration.cpp configuration.hpp configuration-ti.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
configwriter.cpp configwriter.hpp
|
|
|
|
console.cpp console.hpp
|
|
|
|
context.cpp context.hpp
|
|
|
|
convert.cpp convert.hpp
|
2018-01-18 13:50:38 +01:00
|
|
|
datetime.cpp datetime.hpp datetime-ti.hpp datetime-script.cpp
|
2017-12-24 08:18:33 +01:00
|
|
|
debug.hpp
|
|
|
|
debuginfo.cpp debuginfo.hpp
|
|
|
|
dependencygraph.cpp dependencygraph.hpp
|
|
|
|
dictionary.cpp dictionary.hpp dictionary-script.cpp
|
|
|
|
exception.cpp exception.hpp
|
|
|
|
fifo.cpp fifo.hpp
|
2018-01-18 13:50:38 +01:00
|
|
|
filelogger.cpp filelogger.hpp filelogger-ti.hpp
|
|
|
|
function.cpp function.hpp function-ti.hpp function-script.cpp functionwrapper.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
initialize.cpp initialize.hpp
|
2019-02-08 10:05:24 +01:00
|
|
|
io-engine.cpp io-engine.hpp
|
Add a JournaldLogger
As proposed in #8857, this adds a Logger subclass that writes structured
log messages via journald's native protocol by calling sd_journal_sendv.
The feature therefore depends on the systemd library. sd_journal_sendv is
available since the early days (systemd v38), so a version check is
probably superflous.
We add the following fields to each record:
- MESSAGE: The log message
- PRIORITY (aka severity): Numeric severity as in RFC5424 section 6.2.1
- SYSLOG_FACILITY: Numeric facility as in RFC5424 section 6.2.1
- SYSLOG_IDENTIFIER: If provided, use value from configuration.
Else use systemd's default behaior, which is to determine the field
by using libc's program_invocation_short_name, resulting in "icinga2".
- ICINGA2_FACILITY: Facility as in Log::Log(..., String facility, ...),
e.g. "ApiListener"
- some more fields are added automatically by systemd
Fields are stored indexed, so we can do fast queries for certain field
values. Example:
$ journalctl -t icinga2 ICINGA2_FACILITY=ApiListener -n 5
Syslog compatiblity is ratained because good old tag, severity and facility
is stored along, and systemd can forward to syslog daemons.
See also https://systemd.io/JOURNAL_NATIVE_PROTOCOL/.
2021-09-10 20:54:31 +02:00
|
|
|
journaldlogger.cpp journaldlogger.hpp journaldlogger-ti.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
json.cpp json.hpp json-script.cpp
|
2019-02-12 11:47:03 +01:00
|
|
|
lazy-init.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
library.cpp library.hpp
|
|
|
|
loader.cpp loader.hpp
|
2018-01-18 13:50:38 +01:00
|
|
|
logger.cpp logger.hpp logger-ti.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
math-script.cpp
|
|
|
|
netstring.cpp netstring.hpp
|
|
|
|
networkstream.cpp networkstream.hpp
|
2018-08-07 13:55:41 +02:00
|
|
|
namespace.cpp namespace.hpp namespace-script.cpp
|
2017-12-24 08:18:33 +01:00
|
|
|
number.cpp number.hpp number-script.cpp
|
|
|
|
object.cpp object.hpp object-script.cpp
|
|
|
|
objectlock.cpp objectlock.hpp
|
2018-06-05 15:01:43 +02:00
|
|
|
object-packer.cpp object-packer.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
objecttype.cpp objecttype.hpp
|
2018-01-18 13:50:38 +01:00
|
|
|
perfdatavalue.cpp perfdatavalue.hpp perfdatavalue-ti.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
primitivetype.cpp primitivetype.hpp
|
|
|
|
process.cpp process.hpp
|
2018-08-02 10:17:04 +02:00
|
|
|
reference.cpp reference.hpp reference-script.cpp
|
2017-12-24 08:18:33 +01:00
|
|
|
registry.hpp
|
|
|
|
ringbuffer.cpp ringbuffer.hpp
|
|
|
|
scriptframe.cpp scriptframe.hpp
|
|
|
|
scriptglobal.cpp scriptglobal.hpp
|
|
|
|
scriptutils.cpp scriptutils.hpp
|
|
|
|
serializer.cpp serializer.hpp
|
2019-07-25 13:51:24 +02:00
|
|
|
shared.hpp
|
2019-07-26 13:04:32 +02:00
|
|
|
shared-object.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
singleton.hpp
|
|
|
|
socket.cpp socket.hpp
|
|
|
|
stacktrace.cpp stacktrace.hpp
|
|
|
|
statsfunction.hpp
|
|
|
|
stdiostream.cpp stdiostream.hpp
|
|
|
|
stream.cpp stream.hpp
|
2018-01-18 13:50:38 +01:00
|
|
|
streamlogger.cpp streamlogger.hpp streamlogger-ti.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
string.cpp string.hpp string-script.cpp
|
2018-01-18 13:50:38 +01:00
|
|
|
sysloglogger.cpp sysloglogger.hpp sysloglogger-ti.hpp
|
2017-12-24 08:18:33 +01:00
|
|
|
tcpsocket.cpp tcpsocket.hpp
|
|
|
|
threadpool.cpp threadpool.hpp
|
|
|
|
timer.cpp timer.hpp
|
|
|
|
tlsstream.cpp tlsstream.hpp
|
|
|
|
tlsutility.cpp tlsutility.hpp
|
|
|
|
type.cpp type.hpp typetype-script.cpp
|
|
|
|
unix.hpp
|
|
|
|
unixsocket.cpp unixsocket.hpp
|
|
|
|
utility.cpp utility.hpp
|
|
|
|
value.cpp value.hpp value-operators.cpp
|
|
|
|
win32.hpp
|
|
|
|
workqueue.cpp workqueue.hpp
|
2013-11-03 13:45:26 +01:00
|
|
|
)
|
|
|
|
|
2021-04-08 11:23:26 +02:00
|
|
|
if(WIN32)
|
|
|
|
mkclass_target(windowseventloglogger.ti windowseventloglogger-ti.cpp windowseventloglogger-ti.hpp)
|
|
|
|
list(APPEND base_SOURCES windowseventloglogger.cpp windowseventloglogger.hpp windowseventloglogger-ti.hpp)
|
|
|
|
|
|
|
|
# Generate a DLL containing message definitions for the Windows Event Viewer.
|
|
|
|
# See also: https://docs.microsoft.com/en-us/windows/win32/eventlog/reporting-an-event
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT windowseventloglogger-provider.rc windowseventloglogger-provider.h
|
|
|
|
COMMAND mc ARGS -U ${CMAKE_CURRENT_SOURCE_DIR}/windowseventloglogger-provider.mc
|
|
|
|
DEPENDS windowseventloglogger-provider.mc
|
|
|
|
)
|
|
|
|
|
|
|
|
list(APPEND base_SOURCES windowseventloglogger-provider.h)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT windowseventloglogger-provider.res
|
|
|
|
COMMAND rc ARGS windowseventloglogger-provider.rc
|
|
|
|
DEPENDS windowseventloglogger-provider.rc
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(eventprovider MODULE windowseventloglogger-provider.res windowseventloglogger-provider.rc)
|
|
|
|
set_target_properties(eventprovider PROPERTIES LINKER_LANGUAGE CXX)
|
|
|
|
target_link_libraries(eventprovider PRIVATE -noentry)
|
|
|
|
|
|
|
|
install(TARGETS eventprovider LIBRARY DESTINATION ${CMAKE_INSTALL_SBINDIR})
|
|
|
|
endif()
|
|
|
|
|
2021-09-14 21:49:55 +02:00
|
|
|
set_property(
|
|
|
|
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/application-version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/journaldlogger.cpp
|
|
|
|
PROPERTY EXCLUDE_UNITY_BUILD TRUE
|
|
|
|
)
|
2014-11-20 09:59:39 +01:00
|
|
|
|
2014-08-30 18:08:28 +02:00
|
|
|
if(ICINGA2_UNITY_BUILD)
|
2018-01-19 09:18:52 +01:00
|
|
|
mkunity_target(base base base_SOURCES)
|
2014-08-30 18:08:28 +02:00
|
|
|
endif()
|
|
|
|
|
2018-02-27 15:54:58 +01:00
|
|
|
if(HAVE_SYSTEMD)
|
|
|
|
find_path(SYSTEMD_INCLUDE_DIR
|
|
|
|
NAMES systemd/sd-daemon.h
|
|
|
|
HINTS ${SYSTEMD_ROOT_DIR})
|
|
|
|
include_directories(${SYSTEMD_INCLUDE_DIR})
|
2021-09-14 21:49:55 +02:00
|
|
|
set_property(
|
|
|
|
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/journaldlogger.cpp
|
|
|
|
APPEND PROPERTY COMPILE_DEFINITIONS
|
|
|
|
SD_JOURNAL_SUPPRESS_LOCATION
|
|
|
|
)
|
2018-02-27 15:54:58 +01:00
|
|
|
endif()
|
|
|
|
|
2018-01-17 04:28:21 +01:00
|
|
|
add_library(base OBJECT ${base_SOURCES})
|
2014-04-14 03:02:33 +02:00
|
|
|
|
2013-11-03 13:45:26 +01:00
|
|
|
include_directories(${icinga2_SOURCE_DIR}/third-party/execvpe)
|
|
|
|
link_directories(${icinga2_BINARY_DIR}/third-party/execvpe)
|
|
|
|
|
|
|
|
include_directories(${icinga2_SOURCE_DIR}/third-party/mmatch)
|
|
|
|
link_directories(${icinga2_BINARY_DIR}/third-party/mmatch)
|
|
|
|
|
2015-02-13 21:02:48 +01:00
|
|
|
include_directories(${icinga2_SOURCE_DIR}/third-party/socketpair)
|
|
|
|
link_directories(${icinga2_BINARY_DIR}/third-party/socketpair)
|
|
|
|
|
2013-11-03 13:45:26 +01:00
|
|
|
set_target_properties (
|
|
|
|
base PROPERTIES
|
|
|
|
FOLDER Lib
|
|
|
|
)
|
|
|
|
|
2018-07-31 11:59:09 +02:00
|
|
|
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CACHEDIR}\")")
|
|
|
|
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_LOGDIR}/crash\")")
|
2014-12-19 09:45:35 +01:00
|
|
|
|
2015-02-02 09:58:38 +01:00
|
|
|
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
|