Commit Graph

6095 Commits

Author SHA1 Message Date
Alexander A. Klimov 738662338f ApplyRule#GetFKVar(): return by const ref
to avoid malloc().
2022-11-08 12:45:21 +01:00
Julian Brost 98902b2ff0
Merge pull request #9545 from Icinga/targeted-apply-rules
Separately handle apply rules targetting only specific parent objects
2022-11-04 14:06:15 +01:00
Yonas Habteab a8d46e6d47 Use service short name for evaluating targeted service rules 2022-11-04 10:19:26 +01:00
Yonas Habteab 2610fb1285 Avoid evaluating the same filter twice for the same target 2022-11-04 10:15:22 +01: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 dacd6a206d VariableExpression#GetVariable(): return by const ref not to unnecessarily malloc() 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 fd7ac4e5ca Allow hashmaps of String 2022-10-21 10:28:41 +02:00
Alexander A. Klimov 449a3c14cf Allow intrusive pointers to ApplyRule 2022-10-21 10:28:41 +02:00
Julian Brost 987bb22397
Merge pull request #9543 from Icinga/apply-rules-lookup
Lookup apply rules faster by Type*, not String and by map instead of ==/!=
2022-10-21 09:53:35 +02:00
Alexander A. Klimov c7d656716f Remove unused ApplyRule#m_TargetType 2022-10-19 13:43:51 +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 90fe4e5bea ApplyRule::GetTargetTypes(): return by const ref not to malloc() 2022-10-19 13:43:51 +02:00
Julian Brost f2563cc890
Merge pull request #9542 from Icinga/context-evaluating-apply-rules-for-host
Construct string once, not unnecessarily N times
2022-10-17 19:57:09 +02:00
Alexander A. Klimov ce1a122618 Construct string once, not unnecessarily N times 2022-10-17 15:54:02 +02:00
Yonas Habteab 400117e2f6 ConfigItem: Don't add items to the new items vector before committing
This also improves the performance a bit, as we longer have to iterate over the items
and copy them into the new items vector.
2022-10-12 13:27:41 +02:00
Yonas Habteab f7298e85d2 ConfigItem: Fix infinite recursion caused by `ignore_on_error` when committing an item
When committing an item with `ignore_on_error` flag set fails, the `Commit()` method only returns `nullptr`
and the current item is not being dropped from `m_Items`. `CommittNewItems()` also doesn't check the return
value of `Commit()` but just continues and tries to commit all items from `m_Items` in recursive call. Since
this corrupt item is never removed from `m_Items`, it ends up in an endless recursion till it finally crashes.
2022-10-12 13:15:09 +02:00
Julian Brost 91cbb856fe
Merge pull request #9521 from Icinga/noop-log-msgs
Logger: don't render log messages which will be disposed anyway
2022-10-11 19:05:03 +02:00
Alexander Aleksandrovič Klimov 363f4d3fde
Merge pull request #9408 from Icinga/bugfix/match-api-permissions-against-join-relations
ObjectQueryHandler: Check user permissions on joined relations
2022-10-11 13:42:27 +02:00
Yonas Habteab a656444d78 RedisConnection: Don't log queries that are going to be discarded 2022-10-11 13:28:08 +02:00
Alexander A. Klimov 0fbb0332a6 Logger: don't render log messages which will be disposed anyway
by caching the total minimum log severity of all loggers in a
"global variable" and whether a message's severity is large enough for any of
the loggers in a per-message no-op flag.
2022-10-11 13:28:08 +02:00
Julian Brost 9be02e3f04
Merge pull request #9518 from Icinga/9481
StartUnixWorker(): watch forked child via waitpid(), not SIGCHLD handler
2022-10-10 14:36:52 +02:00
Yonas Habteab 72e6894bbb Evaluate permission filters also on all joined relations 2022-10-10 12:33:33 +02:00
Yonas Habteab 607f7ab5ca ObjectQueryHandler: Check user permissions on joined relations 2022-10-10 12:33:33 +02:00
Yonas Habteab 1bb2d65a8d FilterUtility: Outsource permission matching from CheckPermission() to a separate method 2022-10-10 12:33:33 +02:00
Julian Brost 465da17060
Merge pull request #9407 from Icinga/bugfix/don-not-allow-changing-object-relations-at-runtime
Don't allow to change object navigation fields at runtime
2022-10-10 12:27:57 +02:00
Alexander A. Klimov 61f7e029cb Replace two-variants enum with bool 2022-10-07 15:14:33 +02:00
Julian Brost 87a4925997
Merge pull request #9519 from Icinga/utf8cp
Utility::ValidateUTF8(): move a string instead of copying a vector
2022-10-07 10:21:37 +02:00
Julian Brost 2a4dc083ae
Merge pull request #9524 from Icinga/introduce-object-idx
Introduce object identifier attr
2022-10-07 10:19:59 +02:00
Julian Brost 0ed9c09a1d
Merge pull request #9513 from Icinga/9501
Icinga DB: on every check result update state only 1x, not 3x in a row
2022-10-07 10:18:56 +02:00
Yonas Habteab 85c77bd878 IcingaDB: Cache generated object hash 2022-09-12 17:23:06 +02:00
Yonas Habteab 07e60c1961 ConfigObject: Introduce new `icingadb_identifier` attr 2022-09-12 17:22:57 +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
Alexander A. Klimov a6b36a2d7b Utility::ValidateUTF8(): move a string instead of copying a vector
less malloc() = more speed

Especially as JsonEncode() validates every single input string.
2022-09-09 10:50:42 +02:00
Alexander A. Klimov 22bfcf9ac5 icinga2 daemon: remove no-op SIGCHLD handling
1. Don't set a custom handler for SIGCHLD (in the umbrella process)
   as that handler doesn't actually handle SIGCHLD anymore
2. Don't reset the SIGCHLD handler (in the worker process)
   as there's nothing to reset anymore due to the above change
3. Don't block SIGCHLD across fork(2) as its handler doesn't change anymore
   due to the above changes
2022-09-07 12:12:09 +02:00
Alexander A. Klimov 3de714489c Remove unused UnixWorkerState::Failed 2022-09-07 12:08:33 +02:00
Alexander A. Klimov df9008bfc4 StartUnixWorker(): watch forked child via waitpid(), not SIGCHLD handler
Before:

On SIGCHLD from the forked worker the umbrella process sets a failure flag.
StartUnixWorker() recognises that and does waitpid(), failure message, etc..
On OpenBSD we can't tell the signal source, so we always set the failure flag.
That's not how our IPC shall work, that breaks the IPC sooner or later.

After:

No SIGCHLD handling and no failure flag setting.
Instead StartUnixWorker()'s wait loop uses waitpid(x,y,WNOHANG)
to avoid false positives while watching the forked worker.
2022-09-07 11:46:46 +02:00
Yonas Habteab 31785b48fd Expression: Decrease `frame.Depth` only when calling `IncreaseStackDepth()` succeeds
This ensures that `frame.Depth` is only decreased when preceding `frame.IncreaseStackDepth()` callee was successful.
This way, `frame.Depth` will have the same depth prior to and after evaluating a frame.
2022-09-07 09:41:16 +02:00
Alexander A. Klimov 5e9f95c007 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-09-06 10:10:14 +02:00
Julian Brost d3cca0e621
Merge pull request #9409 from Icinga/feature/disallow-empty-object-names
Disallow empty object names
2022-08-11 16:53:28 +02:00
Alexander A. Klimov a2362ebf17 IcingaDB::VersionChangedHandler(): don't handle not synced types
not to surprise (and crash) the Icinga DB daemon with unknown types.
2022-08-10 13:24:44 +02:00
Alexander A. Klimov 32871ca40c 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 11:40:53 +02:00
Alexander A. Klimov c9d6eecc7f Dump state file atomically not to corrupt it
by using fsync(2) before close(2) and rename(2).
2022-07-28 18:00:37 +02:00
Alexander A. Klimov 600fb0e3c2 Introduce AtomicFile 2022-07-28 18:00:37 +02:00
Julian Brost 913566cbfa Windows: output useful error message for syscall errors 2022-07-28 17:00:57 +02:00
Yonas Habteab 148f5b8416 ConfigObject: Mark object names as required
This prevents a user from creating an object without a valid name such as `"", null`.
2022-07-15 15:51:58 +02:00
Julian Brost a927ba39b7 Windows: only include critical messages in early log messages
The point of logging to the Windows Event Log was to catch errors that happen
before the full logging configuration has been loaded and enabled. Messages
like the number of loaded objects per type just cause noise in the log and
provide little benefit. Therefore raise the required log level at this stage.

Note that this commit removes the (never documented) ability to use the -x flag
to change the level. But doing so would require patching the command line of
the service in the registry anyways.
2022-07-14 14:07:56 +02:00
Julian Brost bd2118c4cd
Merge pull request #9420 from Icinga/IcingaDB-soft_state
Icinga DB: icinga:*:state: rename state to soft_state
2022-06-29 12:24:52 +02:00