mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
parent
951c61ed16
commit
cdd5c0a716
@ -24,6 +24,7 @@
|
||||
#include "icinga/host.h"
|
||||
#include "icinga/service.h"
|
||||
#include "icinga/notification.h"
|
||||
#include "icinga/dependency.h"
|
||||
#include "icinga/checkcommand.h"
|
||||
#include "icinga/eventcommand.h"
|
||||
#include "icinga/compatutility.h"
|
||||
@ -174,7 +175,7 @@ void HostDbObject::OnConfigUpdate(void)
|
||||
{
|
||||
Host::Ptr host = static_pointer_cast<Host>(GetObject());
|
||||
|
||||
/* parents, host dependencies */
|
||||
/* parents */
|
||||
BOOST_FOREACH(const Checkable::Ptr& checkable, host->GetParents()) {
|
||||
Host::Ptr parent = dynamic_pointer_cast<Host>(checkable);
|
||||
|
||||
@ -195,11 +196,28 @@ void HostDbObject::OnConfigUpdate(void)
|
||||
query1.Category = DbCatConfig;
|
||||
query1.Fields = fields1;
|
||||
OnQuery(query1);
|
||||
}
|
||||
|
||||
/* host dependencies */
|
||||
Log(LogDebug, "db_ido", "host dependencies for '" + host->GetName() + "'");
|
||||
|
||||
BOOST_FOREACH(const Dependency::Ptr& dep, host->GetDependencies()) {
|
||||
Checkable::Ptr parent = dep->GetParent();
|
||||
|
||||
if (!parent)
|
||||
continue;
|
||||
|
||||
int state_filter = dep->GetStateFilter();
|
||||
|
||||
Log(LogDebug, "db_ido", "parent host: " + parent->GetName());
|
||||
|
||||
/* host dependencies */
|
||||
Dictionary::Ptr fields2 = make_shared<Dictionary>();
|
||||
fields2->Set("host_object_id", parent);
|
||||
fields2->Set("dependent_host_object_id", host);
|
||||
fields2->Set("inherits_parent", 1);
|
||||
fields2->Set("timeperiod_object_id", dep->GetPeriod());
|
||||
fields2->Set("fail_on_up", (state_filter & StateFilterUp) ? 1 : 0);
|
||||
fields2->Set("fail_on_down", (state_filter & StateFilterDown) ? 1 : 0);
|
||||
fields2->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
|
||||
DbQuery query2;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "base/utility.h"
|
||||
#include "remote/endpoint.h"
|
||||
#include "icinga/notification.h"
|
||||
#include "icinga/dependency.h"
|
||||
#include "icinga/checkcommand.h"
|
||||
#include "icinga/eventcommand.h"
|
||||
#include "icinga/externalcommandprocessor.h"
|
||||
@ -176,26 +177,34 @@ void ServiceDbObject::OnConfigUpdate(void)
|
||||
/* service dependencies */
|
||||
Log(LogDebug, "db_ido", "service dependencies for '" + service->GetName() + "'");
|
||||
|
||||
BOOST_FOREACH(const Checkable::Ptr& checkable, service->GetParents()) {
|
||||
Service::Ptr parent = dynamic_pointer_cast<Service>(checkable);
|
||||
BOOST_FOREACH(const Dependency::Ptr& dep, service->GetDependencies()) {
|
||||
Checkable::Ptr parent = dep->GetParent();
|
||||
|
||||
if (!parent)
|
||||
continue;
|
||||
|
||||
Log(LogDebug, "db_ido", "service parents: " + parent->GetName());
|
||||
|
||||
/* service dependencies */
|
||||
Dictionary::Ptr fields1 = make_shared<Dictionary>();
|
||||
fields1->Set("service_object_id", parent);
|
||||
fields1->Set("dependent_service_object_id", service);
|
||||
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
int state_filter = dep->GetStateFilter();
|
||||
|
||||
DbQuery query1;
|
||||
query1.Table = GetType()->GetTable() + "dependencies";
|
||||
query1.Type = DbQueryInsert;
|
||||
/* service dependencies */
|
||||
Dictionary::Ptr fields1 = make_shared<Dictionary>();
|
||||
fields1->Set("service_object_id", parent);
|
||||
fields1->Set("dependent_service_object_id", service);
|
||||
fields1->Set("inherits_parent", 1);
|
||||
fields1->Set("timeperiod_object_id", dep->GetPeriod());
|
||||
fields1->Set("fail_on_ok", (state_filter & StateFilterOK) ? 1 : 0);
|
||||
fields1->Set("fail_on_warning", (state_filter & StateFilterWarning) ? 1 : 0);
|
||||
fields1->Set("fail_on_critical", (state_filter & StateFilterCritical) ? 1 : 0);
|
||||
fields1->Set("fail_on_unknown", (state_filter & StateFilterUnknown) ? 1 : 0);
|
||||
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
|
||||
DbQuery query1;
|
||||
query1.Table = GetType()->GetTable() + "dependencies";
|
||||
query1.Type = DbQueryInsert;
|
||||
query1.Category = DbCatConfig;
|
||||
query1.Fields = fields1;
|
||||
OnQuery(query1);
|
||||
query1.Fields = fields1;
|
||||
OnQuery(query1);
|
||||
}
|
||||
|
||||
/* service contacts, contactgroups */
|
||||
|
Loading…
x
Reference in New Issue
Block a user