355 Commits

Author SHA1 Message Date
Alexander A. Klimov
cfc55322fb Change RedisConnection::Query::value_type from String to std::variant<const char*,String>
Especially our history messages contain lots of hardcoded C string literals "like this one". At runtime, they get translated to pointers to constant global memory, const char*. String malloc(3)s and copies these data every time. In contrast, std::variant<const char*,String> just stores the address if any. (Actually, const char* is wrapped by std::string_view to not compute its length every time.)
2025-04-07 14:59:28 +02:00
Alexander A. Klimov
7958048a72 Use RedisConnection::Quer* type aliases instead of (the equivalent std::vector)
This expresses what kind of vector it is and allows to easily change those types in the future.
2025-04-07 14:59:25 +02:00
Yonas Habteab
bc2c750551 IcingaDB: Don't stream runtime state updates to Redis 2025-03-26 10:48:37 +01:00
Julian Brost
065118bc22 Make DependencyGroup::State an enum
The previous struct used two bools to represent three useful states. Make this
more explicit by having these three states as an enum.
2025-03-19 16:28:00 +01:00
Yonas Habteab
945a79e37f IcingaDB: Don't send useless dependencies state updates 2025-03-19 16:28:00 +01:00
Yonas Habteab
da637c3741 IcingaDB: Always send dependencies state HSET updates to Redis 2025-03-19 16:28:00 +01:00
Yonas Habteab
7fbb8f7452 Evaluate dependency group state only for a specific child
Previously the dependency state was evaluated by picking the first
dependency object from the batched members. However, since the
dependency `disable_{checks,notifications` attributes aren't taken into
account when batching the members, the evaluated state may yield a wrong
result for some Checkables due to some random dependency from other
Checkable of that group that has the `disable_{checks,notifications`
attrs set. This commit forces the callers to always provide the child
Checkable the state is evaluated for and picks only the dependency
objects of that child Checkable.
2025-03-19 16:28:00 +01:00
Yonas Habteab
0ab50fd82d IcingaDB: Process dependencies runtime updates 2025-03-19 16:28:00 +01:00
Yonas Habteab
aed1bb6294 IcingaDB: Introduce ExecuteRedisTransaction() helper method 2025-03-19 16:28:00 +01:00
Yonas Habteab
db3f8dec27 IcingaDB: Sync dependencies initial states on config dump 2025-03-19 16:28:00 +01:00
Yonas Habteab
f502993eb4 IcingaDB: Sync dependencies states to Redis 2025-03-19 16:28:00 +01:00
Yonas Habteab
c6466ee0ea IcingaDB: Dump checkables dependencies config to redis correctly 2025-03-19 15:28:31 +01:00
Yonas Habteab
4bfaefadfa IcingaDB: Bump expected redis version to 6 2025-03-12 16:32:01 +01:00
Yonas Habteab
c02b9d74a9 IcingaDB: Send reachablity state updates for all children 2025-03-12 16:19:22 +01:00
Yonas Habteab
6321606671 IcingaDB: Sync affects_children as part of runtime state updates 2025-03-12 16:19:22 +01:00
Yonas Habteab
297b62d841 IcingaDB: Add affected_children to Host/Service Redis updates 2025-03-12 16:19:22 +01:00
Alvar Penning
ef93f945a2 IcingaDB: Start keeping track of Host/Service to Dependency relationship
This does not work in this state!
Trying to refresh Dependency if a Host or Service being member
of this Dependency has a state change.
2025-03-12 16:19:22 +01:00
Yonas Habteab
6ca0611f3d IcingaDB: Don't publish useless data to Redis
The Icinga DB daemon processes the data from the `IcingaApplication`
type only and Icinga DB Web also uses only those stats. However, before
this commit, Icinga DB published all kinds of useless stats to Redis
each second, like the number of (un)reachable hosts, services, and so
on, which is waste of CPU and some other resources. This commit reduces
the published data drastically to only those simple stats coming from
the `IcingaApplication` type.
2025-03-04 17:34:38 +01:00
Julian Brost
4ffe88e263
Merge pull request #9732 from Icinga/silence-compiler-warnings-in-code-we-don-t-maintain
Silence compiler warnings in code we don't maintain
2025-01-15 16:33:24 +01:00
Alexander A. Klimov
6195a457a7 Silence compiler warnings in code we don't maintain 2025-01-14 11:48:33 +01:00
Julian Brost
fb50e4b1f1
Merge pull request #10188 from Icinga/icingadb-heartbeat-both-responsible
IcingaDB Check: Multiple Responsible Instances
2025-01-13 11:56:19 +01:00
Alexander A. Klimov
27e0e236cb Move Timeout instances from heap to stack 2025-01-07 18:20:50 +01:00
Alexander A. Klimov
d77d7506f1 Don't call Timeout#Cancel() where Timeout#~Timeout() is called 2025-01-07 18:20:14 +01:00
Alexander A. Klimov
cb51649363 Timeout#Timeout(): drop unnecessary template parameters 2025-01-07 18:19:39 +01:00
Alexander A. Klimov
d2285bcf0e While using Timeout, don't unnecessarily keep the strand alive via smart pointer 2025-01-07 18:18:46 +01:00
Alexander A. Klimov
92ab913226 Timeout#Timeout(): don't pass yield_context to callback
It's not used. Also, the callback shall run completely at once. This ensures that it won't (continue to) run once another coroutine on the strand calls Timeout#Cancel().
2025-01-07 18:18:18 +01:00
Alvar Penning
0bbe7a9b2f
IcingaDB Check: Multiple Responsible Instances
By design, only one Icinga 2 instance should be responsible in the HA
context. If this promise is broken, the Icinga 2 IcingaDB check should
report it.

The code did not check for invalid data in icingadb:telemetry:heartbeat.
With this change, it will go CRITICAL with a descriptive message and
report the actual number of icingadb_responsible_instances in the
performance data.
2024-11-15 12:56:45 +01:00
Julian Brost
67175c43c0
Merge pull request #10102 from Icinga/icingadb-redis-username
Icinga DB: Config no_user_modify and Support Redis username authentication
2024-11-12 17:04:20 +01:00
Alvar Penning
98f60fd78e
Icinga DB: Support Redis username authentication
The Redis ACL system was introduced with Redis 6.0. It introduced users
with precisely granular permissions. This change allows Icinga 2 to use
the Icinga DB feature against a Redis with an ACL user.

This was reflected in the documentation, next to the already
implemented, but undocumented Redis database.

Closes #9536.
2024-10-24 09:18:19 +02:00
Alvar Penning
57fab7f39e
Icinga DB: Config no_user_modify
Each configuration field of an IcingaDB Object was marked with
no_user_modify as modifications via the API would not result in an
actual change. While the Object would be updated, the internal Redis
connection would not be restarted, resulting in an unexpected behavior.

The missing db_index was added to the documentation.
2024-10-24 09:18:09 +02:00
Alexander A. Klimov
7a4ba59961 Remove redundant "Validation failed" prefix from ValidationError exceptions
ValidationError#ValidationError() already prefixes #m_What,
which #what() returns, with "Validation failed for object".
2024-10-23 13:06:12 +02:00
Alexander A. Klimov
dc4869c3aa IcingaDB::TimestampToMilliseconds(): limit output to four year digits
Too high timestamps may overflow uint64_t (and the YYYY format) and negative
ones don't fit into uint64_t. Those may crash our Go daemon.
2024-09-30 16:54:40 +02:00
Yonas Habteab
26f43b0b48 IcingaDB: Don't sync partially initialised objects 2024-09-11 14:08:27 +02:00
Alexander A. Klimov
f9adf18111 IcingaDB#SerializeState(): limit execution_time and latency to 2^32-1
not to write higher values into Redis than the Icinga DB schema can hold.
This fixes yet another potential Go daemon crash.
2024-05-15 12:55:41 +02:00
Alexander Aleksandrovič Klimov
6c03598678
Merge pull request #9896 from Icinga/provide-cancel_time-where-has_been_cancelled-may-be-1
Disallow triggering a cancelled downtime, but provide cancel_time in Icinga DB downtime history where has_been_cancelled may be 1
2023-12-20 10:03:09 +01:00
Alexander A. Klimov
7174dc864d IcingaDB#SendConfigDelete(): fix missing nullptr check before deref 2023-11-10 17:43:33 +01:00
Alexander A. Klimov
9aaa9901bd Icinga DB downtime history: provide cancel_time where has_been_cancelled may be 1
The table sla_history_downtime requires a downtime_end.
The Go daemon takes the cancel_time if has_been_cancelled is 1.
So we must supply a cancel_time whereever has_been_cancelled is 1.
Otherwise the Go daemon can't process some entries.
2023-11-08 15:22:39 +01: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
Julian Brost
a2926b8604
Merge pull request #9794 from Icinga/round-notification-times-begin-end-not-to-crash-go-daemon
IcingaDB::PrepareObject(): round Notification#times.{begin,end} not to crash Go daemon
2023-06-27 17:08:41 +02:00
Alexander A. Klimov
dccb678882 IcingaDB::PrepareObject(): cut off (null) negative Notification#times.{begin,end} not to crash Go daemon
At least our PostgreSQL schema enforces positive values.
2023-06-27 12:58:08 +02:00
Alexander A. Klimov
415b810abf IcingaDB::PrepareObject(): round Notification#times.{begin,end} not to crash Go daemon
The latter expects ints, not floats - not to mention strings.
Luckily Icinga already enforces numeric strings so that we can cast it to number.
2023-06-27 12:53:08 +02:00
Julian Brost
9cf519316e
Merge pull request #9805 from Icinga/checkcommand-timeout-0-crashes-icinga-db-daemon-9804
IcingaDB::PrepareObject(): cut off (0) negative Command#timeout for Redis
2023-06-27 10:45:02 +02:00
Julian Brost
c08d3beeb1
Merge pull request #9785 from Icinga/Al2Klimov-patch-8
Icinga DB: also write ConfigObject#original_attributes into Redis
2023-06-27 10:24:41 +02:00
Julian Brost
bd11bc2eb4
Merge pull request #9793 from Icinga/unmarshal-number-42-5-into-go-struct-field-notification-notification_interval
IcingaDB::PrepareObject(): round Notification#interval and limit it to >=0
2023-06-27 10:12:13 +02:00
Alexander A. Klimov
d641a3c799 IcingaDB::PrepareObject(): cut off (0) negative Command#timeout for Redis
not to crash the Go daemon which expects positive values there.
2023-06-26 15:36:47 +02:00
Alexander A. Klimov
273aa6f997 IcingaDB::PrepareObject(): round Notification#interval and limit it to >=0
otherwise, e.g. with -42.5, the Go daemon crashes. It expects uints there.
2023-06-19 12:46:40 +02:00
Alexander A. Klimov
9f08bad395 IcingaDB::PrepareObject(): convert non-null Checkable#check_timeout to number
and, in case of null, fall back to Checkable#check_command.timeout, just like
IcingaDB#SerializeState(). Otherwise the Go daemon crashes. It expects a number.
2023-06-15 12:29:42 +02:00
Alexander A. Klimov
385fe2fd76 Icinga DB: also write ConfigObject#original_attributes into Redis
for the case the Go daemon decides to sync them into DB.
2023-06-12 12:53:25 +02:00
Julian Brost
8a42c3bf18
Merge pull request #9775 from Icinga/icingadb-service-crashes-on-negative-downtime-duration-or-end-before-start-9774
Icinga DB: don't write negative Downtime durations into Redis
2023-05-31 11:37:42 +02:00
Alexander A. Klimov
75eaa81c06 Icinga DB: don't write negative Downtime durations into Redis
via `std::max(0, x)` not to crash the Go daemon which can't handle such.
2023-05-30 17:56:03 +02:00