Commit Graph

1696 Commits

Author SHA1 Message Date
Julian Brost eca8890d49
Merge pull request #9718 from Icinga/acknowledgement-sync-between-masters-are-not-working-9652
Checkable#ProcessCheckResult(): only clean up ack comments older than check result
2023-05-05 15:29:38 +02:00
Julian Brost af9d67b262
Merge pull request #9726 from Icinga/43624b
Remove -and notify- expired downtimes immediately, not every 60s II
2023-05-02 11:25:03 +02:00
Alexander A. Klimov 58b788cd51 Downtime#Start(): trigger flexible downtimes not earlier than fixed ones
the last state change could be a long time ago. If it's longer than
the new downtime's duration, the downtime expires immediately.

trigger time + duration < now
2023-04-18 16:55:32 +02:00
Alexander A. Klimov 0ac1cd1ecb Rename Downtime::DowntimesExpireTimerHandler()
to actually reflect its purpose.
2023-04-14 14:52:05 +02:00
Alexander A. Klimov 6adf2d19e4 Remove -and notify- expired downtimes immediately, not every 60s
Don't look for expired downtimes in a timer fired every 60s,
but fire one timer per downtime once at expire time.
2023-04-14 14:52:05 +02:00
Julian Brost 8228fae740
Merge pull request #8627 from WuerthPhoenix/bug/agent-cannot-update-executions-8616
Fix update execution message discarded. refs #8616
2023-04-13 19:29:49 +02:00
Julian Brost f505325ff9
Merge pull request #9445 from Icinga/9365
Disallow config modifications via API during reload
2023-04-13 17:11:58 +02:00
Mattia Codato c5c17928a6 Allow to exec command on endpoint where the checkable is not present but checkable has command_endpoint specified 2023-04-13 14:44:07 +02:00
Alexander A. Klimov 2ee776b5ab Disallow config modifications via API during reload
Once the new main process has read the config,
it misses subsequent modifications from the old process otherwise.
2023-04-12 14:45:40 +02:00
Julian Brost 50018c1d2b
Merge pull request #8218 from efuss/redundancy_group
Introduce redundancy groups for Dependency Objects
2023-04-05 18:49:58 +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
Alexander A. Klimov 35248b1b63 Code style 2023-04-03 13:39:08 +02:00
Alexander A. Klimov cc872dac1f Remove CheckResultReader which has been deprecated for 5 major versions 2023-04-03 11:39:21 +02:00
Alexander A. Klimov 6414fd19f5 Checkable#ProcessCheckResult(): only clean up ack comments older than check result
Normally if for some reason an ack comment still exists on a checkable not
acked anymore, still clean it up. But while replaying log config objects
incl. ack comments come before check results and acks. I.e. 1) ack comment,
2) DOWN check result and 3) ack. Not 1) DOWN check result, 2) ack and 3) ack
comment. So the checkable is temporarily not acked, but already has the ack
comment. In this case the DOWN check result which is older than the ack
comment shall not clean up the latter.
2023-03-03 15:48:34 +01:00
Alexander A. Klimov 4662d4477b Checkable#RemoveAckComments(): add optional comment entry time filter 2023-03-03 15:48:11 +01:00
Alexander A. Klimov dceb29c742 Checkable#RemoveCommentsByType(): remove redundant parameter 2023-03-03 11:53:02 +01:00
Mattia Codato 912fdb9700 Fix update execution message discarded
refs Icinga#8616
2023-03-02 17:50:39 +01:00
Alexander A. Klimov bbf2e80002 Remove StatusDataWriter which has been deprecated for 5 major versions 2023-03-01 17:16:28 +01:00
Edgar Fuß 20d7e1b5e6 Fix use of std::unordered_map::insert() as pointed out by Nathaniel Wesley Filardo in GitHup Pull Request #8999 2023-02-21 16:23:40 +01:00
Edgar Fuß 5bba609e60 Add missing #include 2023-02-21 16:23:40 +01:00
Edgar Fuß cfef9fdadc Introduce redundancy groups for Dependency Objects
Traditional behaviour was to regard all dependecies as cumulative (e.g., the parent considered unreachable if any one dependency is violated), commit ed58922389 made all dependencies regarded redundant (e.g., the parent considered unreachable only if all dependency are violated). This may lead to unrelated services (or even hosts vs. services) inadvertantly regarded to be redundant to each other.

Most importantly, applying the explicit "disable-host-service-checks" dependency described in the "Monitoring Basics" chapter will defeat all other dependencies.

This commit introduces a new "redundancy_group" attribute for dependencies.
Specifying a redundancy_group causes a dependency to be regarded as redundant only inside that redundancy group.
Dependencies lacking a redundancy_group attribute are regarded as essential for the parent.

This allows for both cumulative and redundant dependencies and even a combination (cumulation of redundancies, like SSH depeding on both LDAP and DNS to function, while operating redundant LDAP servers as well as redundant DNS resolvers).

This commit lacks changes to the tests.
2023-02-21 16:23:36 +01: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 A. Klimov b2b49caf61 Macros: support $env.ENV_VAR_NAME$
refs #6259
2023-02-10 17:21:29 +01:00
Alexander A. Klimov a309b4a415 ResolverSpec: add option not to resolve "$name$"
but only "$host.name$".
2023-02-06 16:39:17 +01:00
Alexander A. Klimov 5b63407d15 Forbid dependency cycles 2023-02-06 12:33:48 +01:00
Alexander A. Klimov 91901eafd8 Introduce EnvResolver
refs #6259
2023-02-06 11:25:25 +01:00
Julian Brost c51037725a
Merge pull request #9466 from Icinga/flush-temp-files
Deduplicate and stabilize fragile filesystem transactions
2023-02-02 16:29:11 +01:00
Alexander A. Klimov b92fe23469 Deduplicate and stabilize fragile filesystem transactions
by using AtomicFile so they ensure all or nothing of a file gets replaced.
2023-01-27 12:03:56 +01:00
Yonas Habteab 95cec9cba2 Don't mark a method as `virtual` in a `final` class 2023-01-26 09:10:38 +01:00
Julian Brost 24b57f0d3a Namespace: don't acquire shared locks on frozen namespaces
This makes freezing a namespace an irrevocable operation but in return allows
omitting further lock operations. This results in a performance improvement as
reading an atomic bool is faster than acquiring and releasing a shared lock.

ObjectLocks on namespaces remain untouched as these mostly affect write
operations which there should be none of after freezing (if there are some,
they will throw exceptions anyways).
2023-01-19 17:56:44 +01:00
Julian Brost 1c066fc02e Simplify NamespaceValue class hierarchy to one struct without member functions
This commit removes EmbeddedNamespaceValue and ConstEmbeddedNamespaceValue and
reduces NamespaceValue down to a simple struct without inheritance or member
functions. The code from these clases is inlined into the Namespace class. The
class hierarchy determining whether a value is const is moved to an attribute
of NamespaceValue.

This is done in preparation for changes to the locking in the Namespace class.
Currently, it relies on a recursive mutex. In the future, a shared mutex
(read/write lock) should be used instead, which cannot allow recursive locking
(without failing or risk deadlocking on lock upgrades). With this change, all
operations requiring a lock for one operation are within one function, no
recursive locking is not needed any more.
2023-01-19 17:55:11 +01:00
Julian Brost 0503ca1379 Initialize namespaces without using `overrideFrozen`
This commit adds a new initialization priority `FreezeNamespaces` that is run
last and moves all calls to `Namespace::Freeze()` there. This allows all other
initialization functions to still update namespaces without the use of the
`overrideFrozen` flag.

It also moves the initialization of `System.Platform*` and `System.Build*` to
an initialize function so that these can also be set without setting
`overrideFrozen`.

This is preparation for a following commit that will make the frozen flag in
namespaces finial, no longer allowing it to be overriden (freezing the
namespace will disable locking, so performing further updates would be unsafe).
2023-01-19 09:53:36 +01:00
Julian Brost 99bb687350 INITIALIZE_ONCE_WITH_PRIORITY: use enum for priority values
Change the type of the priority values from int to a new enum. By replacing the
magic int values throughout the code base with named values, there is now a
single place where all priority values are defined and you get an overview over
the initialization order.
2023-01-18 15:57:27 +01:00
Julian Brost fbb68dbcd0 Namespace: replace behavior classes with a bool
In essence, namespace behaviors acted as hooks for update operations on
namespaces. Two behaviors were implemented:

- `NamespaceBehavior`: allows the update operation unless it acts on a value
  that itself was explicitly marked as constant.
- `ConstNamespaceBehavior`: initially allows insert operations but marks the
  individual values as const. Additionally provides a `Freeze()` member
  function. After this was called, updates are rejected unless a special
  `overrideFrozen` flag is set explicitly.

This marvel of object-oriented programming can be replaced with a simple bool.
This commit basically replaces `Namespace::m_Behavior` with
`Namespace::m_ConstValues` and inlines the behavior functions where they were
called. While doing so, the code was slightly simplified by assuming that
`m_ConstValues` is true if `m_Frozen` is true. This is similar to what the API
allowed in the old code as you could only freeze a `ConstNamespaceBehavior`.
However, this PR moves the `Freeze()` member function and the related
`m_Freeze` member variable to the `Namespace` class. So now the API allows any
namespace to be frozen. The new code also makes sense with the previously
mentioned simplification: a `Namespace` with `m_ConstValues = false` can be
modified without restrictions until `Freeze()` is called. When this is done, it
becomes read-only.

The changes outside of `namespace.*` just adapt the code to the slightly
changed API.
2022-12-09 09:25:46 +01:00
Alexander A. Klimov 83021f8231 CONTEXT: use << everywhere to unify usages 2022-11-30 11:06:51 +01:00
Alexander A. Klimov b82814fb29 CONTEXT: lazily evaluate frames to only actually assemble when needed 2022-11-30 11:06:45 +01:00
Julian Brost a958a735d7
Merge pull request #9555 from Icinga/ApplyRule-GetDebugInfo
ApplyRule#GetDebugInfo(): return by const ref to avoid malloc()
2022-11-16 13:35:04 +01:00
Yonas Habteab a8d46e6d47 Use service short name for evaluating targeted service rules 2022-11-04 10:19:26 +01:00
Alexander A. Klimov 27a559c5fe ApplyRule#GetDebugInfo(): return by const ref to avoid malloc() 2022-10-28 15:33:44 +02:00
Alexander A. Klimov a698b9c3da ApplyRule::RuleMap: reduce complexity, save unnecessary lookups 2022-10-28 14:27:53 +02:00
Alexander A. Klimov a907c2ac9a Targeted apply rules: don't unnecessarily eval filter 2022-10-28 14:27:53 +02:00
Alexander A. Klimov 038a5e8ef6 Unify storages of regular/targeted apply rules: std::vector<ApplyRule::Ptr> 2022-10-28 14:27:53 +02:00
Alexander A. Klimov a56ad38ad3 Separately handle apply rules targetting only specific parent objects
not to unnecessarily run e.g. the filter assign where host.name=="example.com"
for all hosts being not example.com.
2022-10-28 14:27:53 +02:00
Alexander A. Klimov d468d7993c Lookup apply rules faster by Type*, not String and by map instead of ==/!=
1. The lookup of apply rules per source type now implies
   no String(const char*) (no malloc()) and just pointer (uint64) comparisions
2. Apply rules are now also grouped by target type via a nested map, that obsoletes
   checking the target type while iterating over all rules per source type
2022-10-19 13:43:51 +02:00
Alexander A. Klimov ce1a122618 Construct string once, not unnecessarily N times 2022-10-17 15:54:02 +02:00
Yonas Habteab 28c29c1fbc Don't allow to change object parent,host/service_name at runtime 2022-09-09 18:26:28 +02:00
Julian Brost 3220fecd4c
Merge pull request #7919 from Icinga/feature/parameter-delimiters-check-execution-6277
Introduce Command#arguments[].separator
2022-05-23 13:23:36 +02:00
Alexander A. Klimov 069c3968d9 Introduce Command#arguments[].sep
... for letting check commands produce argv like --key=value,
not just --key value.

refs #6277
2022-05-11 17:50:12 +02:00
Julian Brost 4184dcd62c
Merge pull request #9354 from WuerthPhoenix/feature/return-correct-status-in-process-check-result-api
Return correct status codes in process-check-result API
2022-05-05 15:30:09 +02:00