mirror of https://github.com/Icinga/icinga2.git
parent
153a8b24fe
commit
aa82ef7c06
|
@ -139,7 +139,7 @@ Dictionary::Ptr CompatUtility::GetHostConfigAttributes(const Host::Ptr& host)
|
||||||
notification_options.push_back("s");
|
notification_options.push_back("s");
|
||||||
}
|
}
|
||||||
|
|
||||||
service_attr = CompatUtility::GetServiceConfigAttributes(service, CompatTypeService);
|
service_attr = CompatUtility::GetServiceConfigAttributes(service);
|
||||||
|
|
||||||
attr->Set("check_period", service_attr->Get("check_period"));
|
attr->Set("check_period", service_attr->Get("check_period"));
|
||||||
attr->Set("check_interval", service_attr->Get("check_interval"));
|
attr->Set("check_interval", service_attr->Get("check_interval"));
|
||||||
|
@ -295,7 +295,7 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr CompatUtility::GetServiceConfigAttributes(const Service::Ptr& service, CompatObjectType type)
|
Dictionary::Ptr CompatUtility::GetServiceConfigAttributes(const Service::Ptr& service)
|
||||||
{
|
{
|
||||||
Dictionary::Ptr attr = boost::make_shared<Dictionary>();
|
Dictionary::Ptr attr = boost::make_shared<Dictionary>();
|
||||||
|
|
||||||
|
@ -353,47 +353,22 @@ Dictionary::Ptr CompatUtility::GetServiceConfigAttributes(const Service::Ptr& se
|
||||||
Dictionary::Ptr macros;
|
Dictionary::Ptr macros;
|
||||||
std::vector<String> notification_options;
|
std::vector<String> notification_options;
|
||||||
|
|
||||||
if (type == CompatTypeHost) {
|
/* dicts */
|
||||||
|
custom = service->GetCustom();
|
||||||
|
macros = service->GetMacros();
|
||||||
|
|
||||||
/* dicts */
|
/* notification state filters */
|
||||||
custom = host->GetCustom();
|
if (notification_state_filter & (1<<StateWarning)) {
|
||||||
macros = host->GetMacros();
|
attr->Set("notify_on_warning", 1);
|
||||||
|
notification_options.push_back("w");
|
||||||
/* alias */
|
|
||||||
if (!host->GetDisplayName().IsEmpty())
|
|
||||||
attr->Set("alias", host->GetName());
|
|
||||||
else
|
|
||||||
attr->Set("alias", host->GetDisplayName());
|
|
||||||
|
|
||||||
/* notification state filters */
|
|
||||||
if (notification_state_filter & (1<<StateWarning) ||
|
|
||||||
notification_state_filter & (1<<StateCritical)) {
|
|
||||||
attr->Set("notify_on_down", 1);
|
|
||||||
notification_options.push_back("d");
|
|
||||||
}
|
|
||||||
if (notification_state_filter & (1<<StateUncheckable)) {
|
|
||||||
attr->Set("notify_on_unreachable", 1);
|
|
||||||
notification_options.push_back("u");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
if (notification_state_filter & (1<<StateUnknown)) {
|
||||||
/* dicts */
|
attr->Set("notify_on_unknown", 1);
|
||||||
custom = service->GetCustom();
|
notification_options.push_back("u");
|
||||||
macros = service->GetMacros();
|
}
|
||||||
|
if (notification_state_filter & (1<<StateCritical)) {
|
||||||
/* notification state filters */
|
attr->Set("notify_on_critical", 1);
|
||||||
if (notification_state_filter & (1<<StateWarning)) {
|
notification_options.push_back("c");
|
||||||
attr->Set("notify_on_warning", 1);
|
|
||||||
notification_options.push_back("w");
|
|
||||||
}
|
|
||||||
if (notification_state_filter & (1<<StateUnknown)) {
|
|
||||||
attr->Set("notify_on_unknown", 1);
|
|
||||||
notification_options.push_back("u");
|
|
||||||
}
|
|
||||||
if (notification_state_filter & (1<<StateCritical)) {
|
|
||||||
attr->Set("notify_on_critical", 1);
|
|
||||||
notification_options.push_back("c");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* notification type filters */
|
/* notification type filters */
|
||||||
|
@ -434,14 +409,6 @@ Dictionary::Ptr CompatUtility::GetServiceConfigAttributes(const Service::Ptr& se
|
||||||
attr->Set("check_command", check_command_str);
|
attr->Set("check_command", check_command_str);
|
||||||
attr->Set("event_handler", event_command_str);
|
attr->Set("event_handler", event_command_str);
|
||||||
|
|
||||||
/* macros attr */
|
|
||||||
if (macros) {
|
|
||||||
if (type == CompatTypeHost) {
|
|
||||||
attr->Set("address", macros->Get("address"));
|
|
||||||
attr->Set("address6", macros->Get("address6"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* custom attr */
|
/* custom attr */
|
||||||
if (custom) {
|
if (custom) {
|
||||||
attr->Set("notes", custom->Get("notes"));
|
attr->Set("notes", custom->Get("notes"));
|
||||||
|
@ -449,34 +416,6 @@ Dictionary::Ptr CompatUtility::GetServiceConfigAttributes(const Service::Ptr& se
|
||||||
attr->Set("action_url", custom->Get("action_url"));
|
attr->Set("action_url", custom->Get("action_url"));
|
||||||
attr->Set("icon_image", custom->Get("icon_image"));
|
attr->Set("icon_image", custom->Get("icon_image"));
|
||||||
attr->Set("icon_image_alt", custom->Get("icon_image_alt"));
|
attr->Set("icon_image_alt", custom->Get("icon_image_alt"));
|
||||||
|
|
||||||
if (type == CompatTypeHost) {
|
|
||||||
attr->Set("statusmap_image", custom->Get("statusmap_image"));
|
|
||||||
attr->Set("2d_coords", custom->Get("2d_coords"));
|
|
||||||
|
|
||||||
if (!custom->Get("2d_coords").IsEmpty()) {
|
|
||||||
std::vector<String> tokens;
|
|
||||||
String coords = custom->Get("2d_coords");
|
|
||||||
boost::algorithm::split(tokens, coords, boost::is_any_of(","));
|
|
||||||
if (tokens.size() == 2) {
|
|
||||||
attr->Set("have_2d_coords", 1);
|
|
||||||
attr->Set("x_2d", tokens[0]);
|
|
||||||
attr->Set("y_2d", tokens[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
attr->Set("have_2d_coords", 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
attr->Set("have_2d_coords", 0);
|
|
||||||
|
|
||||||
/* deprecated in 1.x, but empty */
|
|
||||||
attr->Set("vrml_image", Empty);
|
|
||||||
attr->Set("3d_coords", Empty);
|
|
||||||
attr->Set("have_3d_coords", 0);
|
|
||||||
attr->Set("x_3d", Empty);
|
|
||||||
attr->Set("y_3d", Empty);
|
|
||||||
attr->Set("z_3d", Empty);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return attr;
|
return attr;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
static Dictionary::Ptr GetHostConfigAttributes(const Host::Ptr& host);
|
static Dictionary::Ptr GetHostConfigAttributes(const Host::Ptr& host);
|
||||||
|
|
||||||
static Dictionary::Ptr GetServiceStatusAttributes(const Service::Ptr& service, CompatObjectType type);
|
static Dictionary::Ptr GetServiceStatusAttributes(const Service::Ptr& service, CompatObjectType type);
|
||||||
static Dictionary::Ptr GetServiceConfigAttributes(const Service::Ptr& service, CompatObjectType type);
|
static Dictionary::Ptr GetServiceConfigAttributes(const Service::Ptr& service);
|
||||||
|
|
||||||
static Dictionary::Ptr GetCommandConfigAttributes(const Command::Ptr& command);
|
static Dictionary::Ptr GetCommandConfigAttributes(const Command::Ptr& command);
|
||||||
static String EscapeString(const String& str);
|
static String EscapeString(const String& str);
|
||||||
|
|
|
@ -49,7 +49,7 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields(void) const
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(service);
|
ObjectLock olock(service);
|
||||||
attrs = CompatUtility::GetServiceConfigAttributes(service, CompatTypeService);
|
attrs = CompatUtility::GetServiceConfigAttributes(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
fields->Set("host_object_id", host);
|
fields->Set("host_object_id", host);
|
||||||
|
|
Loading…
Reference in New Issue