749 Commits

Author SHA1 Message Date
Alexander A. Klimov
34844c146d Deduplicate and stabilize fragile filesystem transactions
by using AtomicFile so they ensure all or nothing of a file gets replaced.
2023-02-15 17:19:57 +01:00
Yonas Habteab
e29de04687 Avoid evaluating the same filter twice for the same target 2022-11-04 12:47:41 +01:00
Alexander A. Klimov
cc67510063 ApplyRule::RuleMap: reduce complexity, save unnecessary lookups 2022-11-04 12:47:41 +01:00
Alexander A. Klimov
09d810dbd9 VariableExpression#GetVariable(): return by const ref not to unnecessarily malloc() 2022-11-04 12:47:41 +01:00
Alexander A. Klimov
840bfb6be1 Unify storages of regular/targeted apply rules: std::vector<ApplyRule::Ptr> 2022-11-04 12:47:41 +01:00
Alexander A. Klimov
1935137a8d 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-11-04 12:47:41 +01:00
Alexander A. Klimov
80ee597b72 Allow intrusive pointers to ApplyRule 2022-11-04 12:47:41 +01:00
Alexander A. Klimov
cf3e02243e Remove unused ApplyRule#m_TargetType 2022-11-02 11:06:12 +01:00
Alexander A. Klimov
fcedb01d0d 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-11-02 11:06:12 +01:00
Alexander A. Klimov
7f50955674 ApplyRule::GetTargetTypes(): return by const ref not to malloc() 2022-11-02 11:00:47 +01:00
Yonas Habteab
bbca13d788 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-31 12:55:42 +01:00
Yonas Habteab
2adc0bd042 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-31 12:55:42 +01:00
Julian Brost
0ba703da13 Remove redundant call to Serialize() in ConfigItem::Commit()
The very same object is already serialized a few lines above, the result is
even stored in a variable, but that variable was not used before. Simply using
this variable results in a noticeable improvement of config validation times.
2022-06-15 10:57:03 +02:00
Yonas Habteab
178eb928e6 ConfigItem: Use atomic variables for notified and commited items count 2022-03-29 16:38:09 +02:00
Julian Brost
36ce7d961f Rename silent parameter of ConfigItem::ActivateItems()
As silent now no longer only controls the generation of log messages, a better
name is required. This changes its name, inverts its value to reflect the new
name and adds a documentation comment.
2021-06-21 16:07:36 +02:00
Julian Brost
05ca30a6a0 Write early log messages to the Windows Event Log
When Icinga 2 is started as a service, the early log messages generated
until the FileLogger object is activated are lost and make it really
hard to debug issues that (only) occur when Icinga 2 reloads.

With this commit, these early log messages are written to the Windows
Event Log.
2021-06-21 15:15:54 +02:00
Alexander Aleksandrovič Klimov
ef8619f76b
Merge pull request #8601 from Icinga/feature/replace-std-boost-bind-with-lambdas-7006
Feature: Replace std/boost::bind() with lambdas
2021-03-18 17:56:13 +01:00
Yonas Habteab
43ba2da39c Replace std/boost::bind() function with lambda expression 2021-03-10 16:29:40 +01:00
Alexander A. Klimov
c3388e9af6 Use std::mutex, not boost::mutex 2021-02-03 09:54:57 +01:00
Julian Brost
e727675aaf Remove incorrect assertion in ConfigItem::ActivateItems
There is an assertion that after activating items, all these items are
active, which sounds reasonable at first. However, with concurrent API
queries, some of these could already be deleted and therefore be
deactivated again.
2021-01-15 16:40:07 +01:00
Julian Brost
0c6abc817b Remove upq from ConfigItem::ActivateItems
Since commit d9010c7b9faaec137f3e195b370edbb406c37d76, ActivateItems no
longer uses the WorkQueue upq to perform tasks but instead performs
these locally. One instance of `upq.Join()`/`upq.HasExceptions()`
remained in the function, but I believe this was just missed when
removing the `upq.Enqueue()` call just before.

This commit removes the corresponding parameter and updates all call
sites accordingly.
2021-01-13 15:19:55 +01:00
Alexander A. Klimov
530d84ae3b Make ConfigCompiler#m_LexBuffer a String
... to reduce malloc()s.
2020-01-21 13:38:59 +01:00
Alexander A. Klimov
9be3b60f76 DSL: allow ()use(x)=>x and ()use(x)=>{return x} 2019-12-03 11:19:34 +01:00
Alexander A. Klimov
5c347ef7bd DSL: introduce x?y:z 2019-11-15 13:38:01 +01:00
Alexander Aleksandrovič Klimov
3804f4edcc I like to move it, move it 2019-10-28 13:46:33 +01:00
Michael Friedrich
e0ef5fe9de
Merge pull request #7458 from Icinga/feature/config-parser-cleanup
Config parser: introduce optional_newlines
2019-10-22 17:29:59 +02:00
Michael Friedrich
6103f53c5b
Merge pull request #7541 from Icinga/bugfix/heredoc-eof
Config lexer: complain on EOF in heredocs, i.e. {{{abc<EOF>
2019-10-22 17:19:27 +02:00
Alexander A. Klimov
768044a754 Replace std::shared_ptr<NamespaceValue> with NamespaceValue::Ptr
refs #7361
2019-10-21 17:10:51 +02:00
Alexander A. Klimov
aa4cad7482 Replace std::shared_ptr<Expression> with Expression::Ptr
refs #7361
2019-10-21 17:10:51 +02:00
Michael Friedrich
3e6fc9bfa1
Merge pull request #7457 from Icinga/feature/config-parser-malloc
Config parser: save some memory allocations
2019-10-17 17:19:30 +02:00
Alexander A. Klimov
672f497c3a Config lexer: complain on EOF in heredocs, i.e. {{{abc<EOF> 2019-09-26 13:10:19 +02:00
Alexander A. Klimov
b4e3736e31 WarnOnImplicitlySetGlobalVar(): warn only on sins inside actual DSL code 2019-09-23 15:09:57 +02:00
Alexander A. Klimov
360cb50c9e Config parser: inline arraysep 2019-08-29 14:06:01 +02:00
Alexander A. Klimov
fd88ac2f83 Config parser: introduce optional_newlines 2019-08-29 14:05:58 +02:00
Alexander A. Klimov
203482a675 Config parser: save some memory allocations 2019-08-29 10:54:54 +02:00
Alexander A. Klimov
429080ee1c DSL: warn on x=y if x is a global variable 2019-08-27 13:30:02 +02:00
Michael Friedrich
c30edd0a34 Fix message origin for runtime created config object (create/delete events) 2019-08-13 15:05:47 +02:00
Michael Friedrich
0d25ae0e08 Quality: Prefer BOOST_{,UN}LIKELY gcc optimizer macros over our own
Our macro collides with Boost::DateTime and the gregorian classes
and I don't see any reason why we shouldn't use Boost::Config
being already there.
2019-07-09 13:20:53 +02:00
Michael Friedrich
0438c866f8
Merge pull request #7102 from Icinga/feature/boost-fs-7101
Replace self-written filesystem ops with boost.filesystem
2019-04-25 15:53:55 +02:00
Alexander A. Klimov
5a17722c1f Replace _unlink() + rename() with boost::filesystem::rename()
refs #7101
2019-04-25 09:53:02 +02:00
Alexander A. Klimov
ba842403ce Fix circular #include
refs #6985
2019-04-25 08:25:28 +02:00
Michael Friedrich
37b715baf1 Replace a few more copyright strings 2019-02-25 16:30:40 +01:00
Michael Friedrich
458f997a18 Replace Copyright header with a short version, part II 2019-02-25 15:09:36 +01:00
Michael Friedrich
d14a88235d Replace Copyright header with a short version, part I
CLion -> replace in path
2019-02-25 14:48:22 +01:00
Michael Friedrich
3ad911a57c Fix indent in configcompiler.cpp 2019-02-15 12:24:49 +01:00
Michael Friedrich
3cb2c1d143 icinga.com: Update everything else 2018-10-18 09:50:53 +02:00
Michael Friedrich
dea5ec614e icinga.com: Update CMakeLists.txt 2018-10-18 09:35:18 +02:00
Michael Friedrich
dab53448bc icinga.com: Update *.{h,c}pp 2018-10-18 09:27:04 +02:00
Michael Friedrich
85e161ea1e Silence config compiler logging for runtime created objects
This is especially problematic with many single creation requests,
e.g. many downtimes created via Icinga Web 2 & the REST API.

In addition to the config compiler messages, apply rule matches are
also in there which are removed by this patch.
2018-10-09 16:41:17 +02:00
Michael Friedrich
1c2a59bf63
Merge pull request #6591 from Icinga/bugfix/lto-builds-static-initialize-namespaces
Fix static initializer priority for namespaces in LTO builds
2018-09-04 16:54:30 +02:00