304 Commits

Author SHA1 Message Date
Alexander A. Klimov
b2d975f916 IcingaDB#SendConfigDelete(): fix missing nullptr check before deref 2023-12-20 10:29:17 +01:00
Alexander A. Klimov
873988129f 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-12-20 10:29:17 +01:00
Alexander A. Klimov
0735966e23 IcingaDB::PrepareObject(): cut off (null) negative Notification#times.{begin,end} not to crash Go daemon
At least our PostgreSQL schema enforces positive values.
2023-07-03 17:08:40 +02:00
Alexander A. Klimov
04457f5f16 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-07-03 17:08:40 +02:00
Alexander A. Klimov
b7ecefb3c0 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-07-03 17:08:40 +02:00
Alexander A. Klimov
2f1732e7e6 IcingaDB::PrepareObject(): cut off (0) negative Command#timeout for Redis
not to crash the Go daemon which expects positive values there.
2023-07-03 17:08:40 +02:00
Alexander A. Klimov
766e28e1aa 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-07-03 17:08:40 +02:00
Alexander A. Klimov
f0176001fe 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-07-03 17:08:40 +02:00
Alexander A. Klimov
99350e6b27 Icinga DB feature: normalize *Command.arguments[*].{required,skip_key,repeat_key} to boolean
At the moment, the Icinga DB feature will use that value as-is and
serialize it to JSON, resulting in a crash in Icinga DB down the road
because it expects a boolean.
2023-07-03 17:08:40 +02:00
Yonas Habteab
a4de67d558 RedisConnection: Don't log queries that are going to be discarded 2022-10-26 11:55:10 +02:00
Alexander A. Klimov
2754895c11 Icinga DB: on every check result update state only 1x, not 3x in a row
Before (time: vertical, stack: horizontal):

* Checkable::ExecuteCheck
  * Checkable::UpdateNextCheck
    * IcingaDB::NextCheckChangedHandler
      * HSET icinga:host:state
      * HSET icinga:checksum:host:state
      * ZADD icinga:nextupdate:host
  * RandomCheckTask::ScriptFunc
    * Checkable::ProcessCheckResult
      * Checkable::UpdateNextCheck
        * IcingaDB::NextCheckChangedHandler
          * HSET icinga:host:state
          * HSET icinga:checksum:host:state
          * ZADD icinga:nextupdate:host
      * IcingaDB::NewCheckResultHandler
        * HSET icinga:host:state
        * HSET icinga:checksum:host:state
        * ZADD icinga:nextupdate:host
  * IcingaDB::StateChangeHandler
    * XADD icinga:runtime:state
    * IcingaDB::ForwardHistoryEntries
      * XADD icinga:history:stream:state

After:

* Checkable::ExecuteCheck
  * Checkable::UpdateNextCheck
  * RandomCheckTask::ScriptFunc
    * Checkable::ProcessCheckResult
      * Checkable::UpdateNextCheck
      * IcingaDB::NewCheckResultHandler
        * HSET icinga:host:state
        * HSET icinga:checksum:host:state
        * ZADD icinga:nextupdate:host
  * IcingaDB::StateChangeHandler
    * XADD icinga:runtime:state
    * IcingaDB::ForwardHistoryEntries
      * XADD icinga:history:stream:state

The first state + nextupdate (for overdue) update comes from next_check being
set to now + interval immediately before doing the actual check (not to trigger
it twice). This update is not only not important for the end user, but even
inappropriate. The end user SHALL see next_check being e.g. in -4s, not 5m, as
the check is running at the moment.

The second one is just redundant as IcingaDB::NewCheckResultHandler (the third
one) is called anyway and will update state + nextupdate as well.
2022-10-26 11:55:10 +02:00
Alexander A. Klimov
ea4b819480 IcingaDB::VersionChangedHandler(): don't handle not synced types
not to surprise (and crash) the Icinga DB daemon with unknown types.
2022-08-10 17:04:29 +02:00
Alexander A. Klimov
ac57ed6cb4 IcingaDB::SendCustomVarsChanged(): don't delete custom vars of not synced types
not to surprise (and crash) the Icinga DB daemon with unknown types.
2022-08-10 17:04:29 +02:00
Alexander A. Klimov
b2245be53c Icinga DB: icinga:*:state: rename state to soft_state 2022-06-29 12:30:38 +02:00
Alexander Aleksandrovič Klimov
d35f823a96
Merge pull request #9419 from Icinga/feature/adjust-some-column-names-2.13
IcingaDB: Adjust some column names according to the DB schema
2022-06-28 22:00:00 +02:00
Alexander Aleksandrovič Klimov
8ff3f2aeb1
Merge pull request #9418 from Icinga/feature/icingadb-no-ca-error-message-2.13
Icinga DB: make error message more helpful if API isn't set up
2022-06-28 20:08:24 +02:00
Yonas Habteab
a9acb3c9d9 IcingaDB: Adjust some column names according to the DB schema 2022-06-28 16:46:52 +02:00
Julian Brost
0d0c2678d9 Icinga DB: make error message more helpful if API isn't set up 2022-06-28 15:57:42 +02:00
Julian Brost
ce814853c3 Icinga DB Check: don't check runtime update backlog during full sync 2022-06-28 15:35:34 +02:00
Julian Brost
0649a9dc06 Icinga DB Check: ignore suppressed queries in Redis backlog check
If some kind of query is not supposed to be processed at the moment, there is
little point in checking it. During a full dump, state updates are suppressed
(i.e. delayed), so when a dump takes very long, this would have resulted in a
false Redis backlog warning.
2022-06-28 15:35:34 +02:00
Julian Brost
9cfde09ea3 Icinga DB Check: include ongoing dumps in OK message
Also use the "current" and "full dump/sync" terminology in the other messages.
2022-06-28 15:35:34 +02:00
Julian Brost
679e13c686 Icinga DB Check: rename dump/sync related perfdata values
Scope all values using current/last instead of takes/took.
2022-06-28 15:35:34 +02:00
Julian Brost
a452d8c14d Icinga DB Check: add unit hints to all rates 2022-06-28 15:35:34 +02:00
Julian Brost
7593207c12 Icinga DB Check: update not connected message
The check makes no attempt to explicitly connect to Redis, it uses the
connection of the IcingaDB feature, so this message better describes the state
in this situation.
2022-06-28 15:35:34 +02:00
Julian Brost
899f5d1624 Icinga DB Check: fix race-condition with IcingaDB::Start()
IcingaDB::GetConnection() uses IcingaDB::m_Rcon which is only initialized in
IcingaDB::Start(), therefore add a nullptr check to the check command.
Additionally, as m_Rcon is potentially accessed concurrently, add a copy of the
value that is safe for concurrent use.
2022-06-28 15:35:34 +02:00
Julian Brost
7b16c85bc1 Icinga DB Check: remove markdown headings from output
icingadb-web shows multiple lines from the check output collapsed into a single
line. The lines containing just minuses make this look cluttered and making
making it a heading provides little to no benefit. Even when rendering markdown
in the check output at some point, having the lists labeled using normal
paragraphs would look just fine.
2022-06-28 15:35:34 +02:00
Julian Brost
6b6a70be80 Icinga DB Check: rename perfdata values
- Add icinga2_ and icingadb_ prefixes to make clear which component is
  responsible for the value.
- Rename heartbeat_lag to heartbeat_age, describes it better in my opinion and
  sound a bit less like something that should be as close to zero as possible.
- Rename redis_dump/database_sync into full_dump/full_sync as this is how these
  operations are refered to in log messages as well.
- Rename Redis backlog into Redis query backlog, makes it a bit clearer in my
  opinion.
- Rename runtime_backlog into runtime_update_backlog, as the component in
  Icinga DB is called that way and this naming is also exposed in log messages.
- Rename dump_config/state/history into config/state/history_dump, makes it
  sound more natural.
2022-06-28 15:35:34 +02:00
Julian Brost
81aef690d6 Icinga DB Check: rename variables from takes to duration
Sounds more natural in my opinion and I doubt that many users would get that
due to the difference between takes/took, this refers to ongoing dumps.
2022-06-28 15:35:34 +02:00
Julian Brost
782139995c Icinga DB Check: use more natural names for sync/cleanup metrics 2022-06-28 15:35:34 +02:00
Julian Brost
df1073b15c Icinga DB Check: report history and runtime update backlog separately
Probably makes little difference for an end-user, but for support and
development it's great to know which of the two is causing problems.
2022-06-28 15:35:34 +02:00
Julian Brost
ba67c102f3 Icinga DB Check: clearly state Icinga 2 Redis backlog
Should make it easier to understand that this refers to Redis queries issued by
Icinga 2.
2022-06-28 15:35:34 +02:00
Julian Brost
81feecf298 Icinga DB Check: replace nested calls to fmax() with std::max()
Improves readability, even more so after splitting it into separate lines.
2022-06-28 15:35:34 +02:00
Julian Brost
bb3ad133d0 Icinga DB Check: spell out "error" in perfdata 2022-06-28 15:35:34 +02:00
Julian Brost
3391a234b3 Icinga DB Check: fix error message on Redis query error
Not only XREAD queries are performed, so the previous error message was incorrect.
2022-06-28 15:35:34 +02:00
Julian Brost
153d5bae00 Icinga DB Check: remove unused includes 2022-06-28 15:35:34 +02:00
Julian Brost
2810350bc0 Icinga DB Check: rename keys in heartbeat stream
In both C++ and Go, the keys are only used as constant strings, so namespacing
them just adds clutter for the `general:*` keys, therefore remove it.
2022-06-28 15:35:34 +02:00
Julian Brost
dbc8995fc3 Icinga DB Check: remove *_1sec metrics
They add no additional information compared to the *_1min values as it's always
the same value divided by 60 anyways. Adding the actual value from the last
second makes little sense for realistic values of check_interval.
2022-06-28 15:35:34 +02:00
Julian Brost
437948c8f9 Icinga DB Check: read performance data string from Redis
Use the already existing format to pass performance data to Icinga 2 rather
than some new JSON structure. Has the additional benefit of doing more things
in Go than in C++.
2022-06-28 15:35:34 +02:00
Alexander A. Klimov
6eebc7868f Introduce Icinga DB check (like the IDO one) 2022-06-28 15:35:34 +02:00
Alexander A. Klimov
db249b1bde Remove Icinga DB perfdata from Icinga check
as the Icinga DB check already yields it.
2022-06-28 15:35:34 +02:00
Alexander A. Klimov
f9155a2d5f Introduce IcingaDB::AddKvsToMap() 2022-06-28 15:35:34 +02:00
Alexander A. Klimov
ce994d8135 RedisConnection::ReadRESP(): *-1\r\n is null, not [ ] 2022-06-28 15:35:34 +02:00
Alexander Aleksandrovič Klimov
9abc64e7d8
Merge pull request #9396 from Icinga/bugfix/icingadb-env-id-init-2.13
Icinga DB: initialize environment ID during config validation
2022-06-23 11:31:20 +02:00
Alexander Aleksandrovič Klimov
1d16c3a300
Merge pull request #9397 from Icinga/feature/parameter-delimiters-check-execution-6277-2.13
Introduce Command#arguments[].separator
2022-06-23 11:31:07 +02:00
Alexander Aleksandrovič Klimov
9eaa9c9f2e
Merge pull request #9398 from Icinga/bugfix/icingadb-command-arguments-null-2.13
IcingaDB: handle null (Empty) for value/set_if/separator in command arguments
2022-06-23 11:30:43 +02:00
Yonas Habteab
524235872c Bump Redis schema version to 5 2022-06-14 15:07:02 +02:00
Yonas Habteab
7e12927b8a IcingaDB: Add _name suffix to columns referring to name 2022-06-14 15:07:02 +02:00
Alexander A. Klimov
20ae49ad49 Introduce Command#arguments[].separator
... for letting check commands produce argv like --key=value,
not just --key value.

refs #6277
2022-06-14 15:04:09 +02:00
Julian Brost
46c33bedaf IcingaDB: handle null (Empty) for value/set_if/separator in command arguments
Icinga 2 treats null (Empty) as if the corresponding attribute is not
specified. However, without this commit, it would serialize the value as "null"
(i.e. type string), so that it ends up in the database as this string instead
of NULL. This commit adds handling for ValueEmpty so that is serialized as JSON
null value and ends up in the database as NULL.
2022-06-14 14:55:19 +02:00
Julian Brost
d28d18f75d Icinga DB: initialize environment ID during config validation
IcingaDB may receive callbacks from Boost signals before being fully started.
This resulted in situations where m_EnvironmentId was used before it was
initialized properly. This is fixed by initializing it earlier (during the
config validation stage). However, at this stage, it should not yet write to
disk, therefore, persisting the environment ID to disk is delayed until later
in the startup process.

Initializing at this stage has an extra benefit: if there is an error for some
reason (possibly corrupt icingadb.env file), this now shows up as a nice error
during config validation.

Additionally, this replaces the use of std::call_once with std::mutex due to
bug in libstdc++ (see inline comment for reference).
2022-06-14 14:09:48 +02:00