Commit graph

281 commits

Author SHA1 Message Date
Johannes Schmidt
1b568ac50e Fix PerfdataWriterConnection segfaults on non-X86 architectures
The issue is that std::promise internally also used thread local
storage, in a call to `std::call_once` in `std::promise::set_value()`.
The theory is that since all paths in `Send()` run this `std::call_once`
routine and from then on, then Coroutine function looks like a normal
function, the compiler inlined `set_value()` and moved the common parts
of it to a common location for all paths before the suspension point in
WriteMessage(yc).

When finally the coroutine is resumes, it is likely that that happens
under a different thread, which still has `__once_callable` in
`std::call_once` set as `nullptr`, leading to the segmentation fault.

The fix is to not use std::promise across coroutine suspension points
and instead reimplement the functionality we required from it in a small
helper class `SyncResult` that does not require any thread local storag.
2026-04-29 13:29:36 +02:00
Johannes Schmidt
24034e49b2 Fix ineffective cancel() when stuck in perfdata writer handshake
On slow systems like our ARM64 Container Image build async_handshake()
can not be cancelled in one go but needs two cancels with a chance
to run the completion handler in between. The exact reason is unknown,
and this has been found through trial and error. The alternative would
have been a socket close() in case the connection is not fully established.
2026-04-29 12:47:17 +02:00
Johannes Schmidt
100206ff06 Fix a race-condition when perfdata writer is stuck in handshake
The issue occurs when ::Connect in `EnsureConnected()` returns after
`Disconnect()` has already set `m_Stopped` to true. By adding a check
and throwing an exception before entering `async_handshake()` the
behavior should now always be consistent.
2026-04-29 12:47:17 +02:00
Johannes Schmidt
03d3558621
Merge pull request #10799 from Icinga/fix-pdwc-tls-host-check
Fix host name verification for `PerfdataWriterConnection`
2026-04-22 11:22:27 +02:00
Yonas Habteab
bc5f01d0fc OTLPMetricsWriter: don't add queue stats as counter 2026-04-20 09:15:53 +02:00
Johannes Schmidt
f5be692d33 Correctly create AsioTlsStream with host argument
This was omitted by accident from the original PR, despite
being done in the original perfdata writer connection code.

Without setting this parameter, host name verification will be
disabled, which poses a security risk.
2026-04-17 10:08:20 +02:00
Yonas Habteab
e6c420e106 OTLP: Set enable_ha to true by default 2026-04-01 12:18:21 +02:00
Yonas Habteab
3f68eea1fd Reduce default flush_threshold to 16MiB
So that it doesn't cause `request body too large` errors when used with
the default OpenTelemetry Collector config that has `max_request_body_size`
set to `20MiB`.
2026-04-01 12:18:21 +02:00
Yonas Habteab
8bdfba8772 Allow users to provide additional resource attributes 2026-04-01 12:18:21 +02:00
Yonas Habteab
60fe45cd6e Add OTLPMetricsWriter 2026-04-01 12:18:21 +02:00
Johannes Schmidt
2108300cf8 Add warnings to deprecated features indicating removal in v2.18 2026-03-27 14:20:55 +01:00
Julian Brost
6592eae21d
Merge pull request #10668 from Icinga/perfdata-writers-connection-handling
Add PerfdatawriterConnection to handle network requests for Perfdata Writers
2026-03-17 15:10:57 +01:00
Johannes Schmidt
da2fc9df01 Use PerfdataWriterConnection in perfdata writers 2026-03-17 12:11:26 +01:00
Johannes Schmidt
2e2576c7c5 Add PerfdataWriterConnection class 2026-03-06 10:55:05 +01:00
Johannes Schmidt
240142bcbd Refactor OpenTsdbWriter to use a WorkQueue 2026-02-26 13:31:10 +01:00
Yonas Habteab
f934aa557b Don't expect Contet-Type header to exactly match application/json
InfluxDB seems to always include some other metadata in the `Content-Type`
header separated by semicolons like `application/json; charset=utf-8`,
and comparing the whole string with `application/json` will always fail,
resulting in almost always useless warnings without any helpful information
for the user what actually went wrong.
2026-02-25 15:55:55 +01:00
Yonas Habteab
91c7e60df8 Replace all existing copyright headers with SPDX headers
I've used the following command to replace the original copyright header
lines in a C-style comment block:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```

For files that use shell-style comments (#) like CMakeLists.txt, I've
used this command:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```

And for SQL files:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
2026-02-04 14:00:05 +01:00
Johannes Schmidt
6bd89821cd Fix -Wenum-compare warnings 2025-11-19 12:00:58 +01:00
Alexander A. Klimov
3d69a31043 Fix compiler warnings by removing unused variables 2025-10-17 09:56:46 +02:00
Julian Brost
1aa62d4bb9
Merge pull request #10420 from Icinga/bundled-perfdata-writers-fix
Serialize fields before queueing them to the workqueue
2025-06-17 10:17:27 +02:00
Alexander Aleksandrovič Klimov
ec2080dcc1
Merge pull request #9731 from Icinga/fix-compiler-warnings-by-copy-constructing-loop-variables-explicitly
Fix compiler warnings by (copy-)constructing loop variables explicitly or not at all
2025-05-21 14:26:47 +02:00
Alexander A. Klimov
22e75f08fa Fix compiler warnings by not unnecessarily (copy-)constructing loop variables 2025-05-21 11:36:32 +02:00
Yonas Habteab
cef6fb77e5 Serialize fields before queueing the event to the workqueue 2025-05-14 14:42:04 +02:00
Yonas Habteab
a589b87d6c Remove unused parameters 2025-05-13 15:31:29 +02:00
Yonas Habteab
2e19fce31d Remove some superfluous if statements
They're just useless, since a `CheckResult` handler is never going to be
called without a check result and a checkable can't exist without a
checkcommand.
2025-05-13 15:31:29 +02:00
Sebastian Grund
7d12c1a524 Add tags functionality to ElasticSearchWriter 2025-01-24 08:51:53 +01:00
Sebastian Grund
8c68c6e9d8
Add closing quotationmarks in Validator for influxdb writer config 2024-09-25 13:03:00 +02:00
Alexander A. Klimov
5c17465a19 OpenTsdbWriter#CheckResultHandler(): skip custom tags with empty values
refs #7724
2024-04-18 11:36:21 +02:00
Alexander Aleksandrovič Klimov
629038344b
OpenTsdbWriter#CheckResultHandler(): clarify log messages
Clarify which "host or service" an "Unable to resolve macro" debug log message refers to.
2024-02-22 10:34:35 +01:00
Alexander A. Klimov
cc9db3756f Revert "Influx DB: don't unneccessarily truncate timestamps to whole seconds"
This reverts commit eaa3cd83ad.
2024-01-16 12:19:48 +01:00
Alexander A. Klimov
fc5b1178c6 Revert "Remove no-op InfluxDB URL param"
This reverts commit 21f548d3c0.
2024-01-16 12:19:47 +01:00
Julian Brost
bba6a76f4a
Merge pull request #9853 from Icinga/GelfWriter-m_StreamMutex
GelfWriter: protect m_Stream via m_WorkQueue, not ObjectLock(this)
2023-09-07 11:46:38 +02:00
Alexander Aleksandrovič Klimov
e5d988a2fe
Merge pull request #7799 from Icinga/bugfix/file-end
Fix file endings
2023-08-25 11:06:19 +02:00
Alexander A. Klimov
4ee10a6c20 GelfWriter: protect m_Stream via m_WorkQueue, not ObjectLock(this)
On shutdown or HA re-connect ConfigObject#SetAuthority(false) is called which
does ObjectLock(this) and ConfigObject#Pause(). GelfWriter#Pause(), with the
above ObjectLock, calls m_WorkQueue.Join(). But items inside that also doing
ObjectLock(this) cause a deadlock.
2023-08-24 17:48:09 +02:00
Alexander A. Klimov
4c2e59a690 ElasticsearchWriter: switch to v7+ URL schema to support v8
and OpenSearch 2. This breaks the EOL v5 and v6.
2023-07-03 14:43:45 +02:00
Alexander Aleksandrovič Klimov
076eb59443
ElasticsearchWriter#Pause(): lock m_DataBufferMutex during Flush()
just to be sure regarding race conditions.
2023-06-30 14:57:18 +02:00
Alexander Aleksandrovič Klimov
d5e6ecec8a
ElasticsearchWriter#Pause(): call Flush() only once
The first Flush() is redundant and may access m_DataBuffer at the same time as some Flush() in m_WorkQueue (race condition) which isn't joined, yet.
2023-06-29 10:42:12 +02:00
Alexander A. Klimov
9376a311ea Fix file endings
git ls-files -z \
	|grep -zEe '^lib/' \
	|grep -zEe '\.[ch]pp$' \
	|xargs -0 perl -p0i -e 's/\n*(?!(?:.|\n))/\n/'
2023-05-17 18:05:13 +02:00
Alexander A. Klimov
ba7102cae3 Explicitly stop started timers and wait for them
before permitting their parent objects' destruction.
For the cases where the handlers have raw pointers to these objects.
2023-04-14 14:52:04 +02:00
Alexander A. Klimov
21b68455ce Use Timer::Create() instead of new Timer()
git ls-files -z |xargs -0 perl -pi -e 's/\bnew Timer\b/Timer::Create/g'

ex. in Timer::Create() itself.
2023-04-04 10:35:20 +02:00
Julian Brost
a84a0a3cee
Merge pull request #8302 from Icinga/bugfix/windows-systemroot-aliases-6259
Macros: support $env.ENV_VAR_NAME$
2023-02-20 13:09:15 +01:00
Alexander A. Klimov
f2974c07cf Centralise default icinga.* and env.* macros 2023-02-17 15:33:36 +01:00
Alexander Aleksandrovič Klimov
fd5350d588
Fix typo 2023-02-13 13:00:28 +01:00
Alexander A. Klimov
b2b49caf61 Macros: support $env.ENV_VAR_NAME$
refs #6259
2023-02-10 17:21:29 +01:00
Julian Brost
ad8868cab7
Merge pull request #9599 from Icinga/influx-ns
Influx DB: don't unneccessarily truncate timestamps to whole seconds
2023-01-26 17:44:50 +01:00
Alexander A. Klimov
21f548d3c0 Remove no-op InfluxDB URL param
precision=ns is the default.
2023-01-16 12:03:08 +01:00
Alexander A. Klimov
83021f8231 CONTEXT: use << everywhere to unify usages 2022-11-30 11:06:51 +01:00
Alexander A. Klimov
eaa3cd83ad Influx DB: don't unneccessarily truncate timestamps to whole seconds
Instead send timestamps with the highest possible precision (ns).
Useful for check intervals <1s.
2022-11-28 12:27:01 +01:00
Alexander Aleksandrovič Klimov
39d642af75
Merge pull request #9321 from Icinga/perfdata-resume-signal
Perfdata writers: disconnect handlers from signals in Pause()
2022-04-07 15:51:02 +02:00
Alexander A. Klimov
56933b8877 Perfdata writers: disconnect handlers from signals in Pause()
as they would be re-connected in Resume() (HA).

Before they were still connected during pause and connected X+1 times
after X split-brains (the same data was written X+1 times).
2022-04-06 13:09:26 +02:00