-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separately handle apply rules targetting only specific parent objects #9545
Conversation
Before/After
|
Julian, shall I
? |
I prefer 1. |
31b38e5
to
0a97f65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a list of all kinds of expressions this PR can optimize.
PING #9545 (comment) |
Well if evaluating the filter expression is not needed, why do it. Something like But to discuss this in detail, this would be helpful:
|
0a97f65
to
5076698
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add documentation comments to the other functions in applyrule-targeted.cpp
, this should make it way easier to follow that file.
5076698
to
fef832d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the use of inline
: I'm not sure why you're adding that keyword explicitly. As the functions are defined inside class definitions, they are inline
implicitly (https://en.cppreference.com/w/cpp/language/inline).
IMAO explicit is more expressive than implicit. |
fef832d
to
9acfb17
Compare
ddfcf84
to
9557694
Compare
9557694
to
9250d88
Compare
9250d88
to
9066849
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GH Actions want your attention.
9066849
to
74552cc
Compare
Forgot to also commit the changes in the header file 🙈 |
7b956ed
to
c57c6a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the point of your last push, is there anything new that this fixes?
c57c6a9
to
a8d46e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test config that hopefully covers most edge cases
object CheckCommand "dummy" { command = ["true"] }
object NotificationCommand "dummy" { command = ["true"] }
object Host "h" { check_command = "dummy" }
object User "u" {}
// ApplyRule::RegisterType("Service", { "Host" });
apply Service "s" {
log("applying Service " + name + " to Host " + host.name)
check_command = "dummy"
assign where host.name == "h"
assign where host.name == "h"
}
apply Service "s-warn" {
log("applying Service " + name + " to Host " + host.name)
check_command = "dummy"
assign where host.name == "404"
assign where host.name == "404"
}
apply Service "s-true" to Host {
log("applying Service " + name + " to Host " + host.name)
check_command = "dummy"
assign where true
}
apply Service "s-false" to Host {
log("applying Service " + name + " to Host " + host.name)
check_command = "dummy"
assign where false
}
// ApplyRule::RegisterType("Dependency", { "Host", "Service" });
apply Dependency "dep-host" to Host {
log("applying Dependency " + name + " to Host " + host.name)
parent_host_name = "h"
assign where host.name == "h"
assign where host.name == "h"
}
apply Dependency "dep-host-warn" to Host {
log("applying Dependency " + name + " to Host " + host.name)
parent_host_name = "h"
assign where host.name == "404"
assign where host.name == "404"
}
apply Dependency "dep-host-true" to Host {
log("applying Dependency " + name + " to Host " + host.name)
parent_host_name = "h"
assign where true
}
apply Dependency "dep-host-false" to Host {
log("applying Dependency " + name + " to Host " + host.name)
parent_host_name = "h"
assign where false
}
apply Dependency "dep-service" to Service {
log("applying Dependency " + name + " to Service " + host.name + "!" + service.name)
parent_host_name = "h"
assign where host.name == "h" && service.name == "s"
assign where host.name == "h" && service.name == "s"
}
apply Dependency "dep-service-warn" to Service {
log("applying Dependency " + name + " to Service " + host.name + "!" + service.name)
parent_host_name = "h"
assign where host.name == "404" && service.name == "s"
assign where host.name == "404" && service.name == "s"
}
apply Dependency "dep-service-true" to Service {
log("applying Dependency " + name + " to Service " + host.name + "!" + service.name)
parent_host_name = "h"
assign where true
}
apply Dependency "dep-service-false" to Service {
log("applying Dependency " + name + " to Service " + host.name + "!" + service.name)
parent_host_name = "h"
assign where false
}
// ApplyRule::RegisterType("Notification", { "Host", "Service" });
apply Notification "notify-host" to Host {
log("applying Notification " + name + " to Host " + host.name)
command = "dummy"
users = ["u"]
assign where host.name == "h"
assign where host.name == "h"
}
apply Notification "notify-host-warn" to Host {
log("applying Notification " + name + " to Host " + host.name)
command = "dummy"
users = ["u"]
assign where host.name == "404"
assign where host.name == "404"
}
apply Notification "notify-host-true" to Host {
log("applying Notification " + name + " to Host " + host.name)
command = "dummy"
users = ["u"]
assign where true
}
apply Notification "notify-host-false" to Host {
log("applying Notification " + name + " to Host " + host.name)
command = "dummy"
users = ["u"]
assign where false
}
apply Notification "notify-service" to Service {
log("applying Notification " + name + " to Service " + host.name + "!" + service.name)
command = "dummy"
users = ["u"]
assign where host.name == "h" && service.name == "s"
assign where host.name == "h" && service.name == "s"
}
apply Notification "notify-service-warn" to Service {
log("applying Notification " + name + " to Service " + host.name + "!" + service.name)
command = "dummy"
users = ["u"]
assign where host.name == "404" && service.name == "s"
assign where host.name == "404" && service.name == "s"
}
apply Notification "notify-service-true" to Service {
log("applying Notification " + name + " to Service " + host.name + "!" + service.name)
command = "dummy"
users = ["u"]
assign where true
}
apply Notification "notify-service-false" to Service {
log("applying Notification " + name + " to Service " + host.name + "!" + service.name)
command = "dummy"
users = ["u"]
assign where false
}
// ApplyRule::RegisterType("ScheduledDowntime", { "Host", "Service" });
apply ScheduledDowntime "dt-host" to Host {
log("applying ScheduledDowntime " + name + " to Host " + host.name)
author = "dummy"
comment = "dummy"
ranges = {}
assign where host.name == "h"
assign where host.name == "h"
}
apply ScheduledDowntime "dt-host-warn" to Host {
log("applying ScheduledDowntime " + name + " to Host " + host.name)
author = "dummy"
comment = "dummy"
ranges = {}
assign where host.name == "404"
assign where host.name == "404"
}
apply ScheduledDowntime "dt-host-true" to Host {
log("applying ScheduledDowntime " + name + " to Host " + host.name)
author = "dummy"
comment = "dummy"
ranges = {}
assign where true
}
apply ScheduledDowntime "dt-host-false" to Host {
log("applying ScheduledDowntime " + name + " to Host " + host.name)
author = "dummy"
comment = "dummy"
ranges = {}
assign where false
}
apply ScheduledDowntime "dt-service" to Service {
log("applying ScheduledDowntime " + name + " to Service " + host.name + "!" + service.name)
author = "dummy"
comment = "dummy"
ranges = {}
assign where host.name == "h" && service.name == "s"
assign where host.name == "h" && service.name == "s"
}
apply ScheduledDowntime "dt-service-warn" to Service {
log("applying ScheduledDowntime " + name + " to Service " + host.name + "!" + service.name)
author = "dummy"
comment = "dummy"
ranges = {}
assign where host.name == "404" && service.name == "s"
assign where host.name == "404" && service.name == "s"
}
apply ScheduledDowntime "dt-service-true" to Service {
log("applying ScheduledDowntime " + name + " to Service " + host.name + "!" + service.name)
author = "dummy"
comment = "dummy"
ranges = {}
assign where true
}
apply ScheduledDowntime "dt-service-false" to Service {
log("applying ScheduledDowntime " + name + " to Service " + host.name + "!" + service.name)
author = "dummy"
comment = "dummy"
ranges = {}
assign where false
}
not to unnecessarily run e.g. the filter assign where host.name=="example.com" for all hosts being not example.com.
ref/IP/42584
(PR 3/3)
Blocked by