mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
Merge pull request #8990 from Icinga/bugfix/downtime-all-services-on-child-hosts
Fix scheduling of downtimes for all services on child hosts
This commit is contained in:
commit
31c564182a
@ -1448,6 +1448,9 @@ Send a `POST` request to the URL endpoint `/v1/actions/remove-downtime`.
|
|||||||
|
|
||||||
In addition to these parameters a [filter](12-icinga2-api.md#icinga2-api-filters) must be provided. The valid types for this action are `Host`, `Service` and `Downtime`.
|
In addition to these parameters a [filter](12-icinga2-api.md#icinga2-api-filters) must be provided. The valid types for this action are `Host`, `Service` and `Downtime`.
|
||||||
|
|
||||||
|
When removing a host downtime, service downtimes on this host are automatically deleted if they were created using
|
||||||
|
the `all_services` option. Other downtimes created using the `child_options` option are not affected.
|
||||||
|
|
||||||
Example for a simple filter using the `downtime` URL parameter:
|
Example for a simple filter using the `downtime` URL parameter:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -434,7 +434,21 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
|
|||||||
|
|
||||||
ArrayData childDowntimes;
|
ArrayData childDowntimes;
|
||||||
|
|
||||||
for (const Checkable::Ptr& child : checkable->GetAllChildren()) {
|
std::set<Checkable::Ptr> allChildren = checkable->GetAllChildren();
|
||||||
|
for (const Checkable::Ptr& child : allChildren) {
|
||||||
|
Host::Ptr childHost;
|
||||||
|
Service::Ptr childService;
|
||||||
|
tie(childHost, childService) = GetHostService(child);
|
||||||
|
|
||||||
|
if (allServices && childService &&
|
||||||
|
allChildren.find(static_pointer_cast<Checkable>(childHost)) != allChildren.end()) {
|
||||||
|
/* When scheduling downtimes for all service and all children, the current child is a service, and its
|
||||||
|
* host is also a child, skip it here. The downtime for this service will be scheduled below together
|
||||||
|
* with the downtimes of all services for that host. Scheduling it below ensures that the relation
|
||||||
|
* from the child service downtime to the child host downtime is set properly. */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Log(LogNotice, "ApiActions")
|
Log(LogNotice, "ApiActions")
|
||||||
<< "Scheduling downtime for child object " << child->GetName();
|
<< "Scheduling downtime for child object " << child->GetName();
|
||||||
|
|
||||||
@ -451,19 +465,15 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* For a host, also schedule all service downtimes if requested. */
|
/* For a host, also schedule all service downtimes if requested. */
|
||||||
Host::Ptr childHost;
|
|
||||||
Service::Ptr childService;
|
|
||||||
tie(childHost, childService) = GetHostService(child);
|
|
||||||
|
|
||||||
if (allServices && !childService) {
|
if (allServices && !childService) {
|
||||||
ArrayData childServiceDowntimes;
|
ArrayData childServiceDowntimes;
|
||||||
|
|
||||||
for (const Service::Ptr& hostService : host->GetServices()) {
|
for (const Service::Ptr& childService : childHost->GetServices()) {
|
||||||
Log(LogNotice, "ApiActions")
|
Log(LogNotice, "ApiActions")
|
||||||
<< "Creating downtime for service " << hostService->GetName() << " on child host " << host->GetName();
|
<< "Creating downtime for service " << childService->GetName() << " on child host " << childHost->GetName();
|
||||||
|
|
||||||
Downtime::Ptr serviceDowntime = Downtime::AddDowntime(hostService, author, comment, startTime, endTime,
|
Downtime::Ptr serviceDowntime = Downtime::AddDowntime(childService, author, comment, startTime, endTime,
|
||||||
fixed, triggerName, duration);
|
fixed, triggerName, duration, String(), String(), childDowntimeName);
|
||||||
String serviceDowntimeName = serviceDowntime->GetName();
|
String serviceDowntimeName = serviceDowntime->GetName();
|
||||||
|
|
||||||
childServiceDowntimes.push_back(new Dictionary({
|
childServiceDowntimes.push_back(new Dictionary({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user