DynamicObject::InternalSerialize(bag, attributeTypes);
if (attributeTypes & Attribute_Config) {
- bag->Set("local", m_Local);
bag->Set("host", m_Host);
bag->Set("port", m_Port);
}
DynamicObject::InternalDeserialize(bag, attributeTypes);
if (attributeTypes & Attribute_Config) {
- m_Local = bag->Get("local");
m_Host = bag->Get("host");
m_Port = bag->Get("port");
}
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
private:
- bool m_Local;
Dictionary::Ptr m_Subscriptions;
String m_Host;
String m_Port;
if (validateOnly)
return true;
- /* restore the previous program state */
- DynamicObject::RestoreObjects(Application::GetStatePath());
-
ConfigItem::ActivateItems();
ConfigItem::DiscardItems();
*/
enum AttributeType
{
- Attribute_Transient = 1,
-
- /* Unlike transient attributes local attributes are persisted
- * in the program state file. */
- Attribute_Local = 2,
-
- /* Attributes read from the config file are implicitly marked
- * as config attributes. */
- Attribute_Config = 4,
-
- /* Combination of all attribute types */
- Attribute_All = Attribute_Transient | Attribute_Local | Attribute_Config
+ Attribute_State = 1,
+ Attribute_Config = 2,
};
/**
return dynamic_pointer_cast<T>(object);
}
- static void DumpObjects(const String& filename, int attributeTypes = Attribute_Local);
- static void RestoreObjects(const String& filename, int attributeTypes = Attribute_Local);
+ static void DumpObjects(const String& filename, int attributeTypes = Attribute_State);
+ static void RestoreObjects(const String& filename, int attributeTypes = Attribute_State);
static void StopObjects(void);
Dictionary::Ptr GetCustom(void) const;
DynamicObject::Ptr object = factory();
- object->Deserialize(serializedUpdate, Attribute_All);
+ object->Deserialize(serializedUpdate, Attribute_Config);
return object;
}
{
StreamLogger::InternalSerialize(bag, attributeTypes);
- bag->Set("path", m_Path);
+ if (attributeTypes & Attribute_Config)
+ bag->Set("path", m_Path);
}
void FileLogger::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
{
DynamicObject::InternalSerialize(bag, attributeTypes);
- bag->Set("severity", m_Severity);
+ if (attributeTypes & Attribute_Config)
+ bag->Set("severity", m_Severity);
}
void Logger::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
{
DynamicObject::InternalSerialize(bag, attributeTypes);
- bag->Set("language", m_Language);
- bag->Set("code", m_Code);
+ if (attributeTypes & Attribute_Config) {
+ bag->Set("language", m_Language);
+ bag->Set("code", m_Code);
+ }
}
void Script::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
{
DynamicObject::InternalDeserialize(bag, attributeTypes);
- m_Language = bag->Get("language");
- m_Code = bag->Get("code");
-
+ if (attributeTypes & Attribute_Config) {
+ m_Language = bag->Get("language");
+ m_Code = bag->Get("code");
+ }
}
#include "config/configitem.h"
#include "config/configcompilercontext.h"
+#include "base/application.h"
#include "base/dynamictype.h"
#include "base/objectlock.h"
#include "base/logger_fwd.h"
objects.push_back(object);
}
+ /* restore the previous program state */
+ DynamicObject::RestoreObjects(Application::GetStatePath());
+
BOOST_FOREACH(const DynamicObject::Ptr& object, objects) {
Log(LogDebug, "config", "Activating object '" + object->GetName() + "' of type '" + object->GetType()->GetName() + "'");
object->Start();
type IcingaApplication {
%attribute string "pid_path",
- %attribute string "state_path",
%attribute dictionary "macros" {
%attribute string "*"
}
{
DynamicObject::InternalSerialize(bag, attributeTypes);
- bag->Set("notification_command", m_NotificationCommand);
- bag->Set("notification_interval", m_NotificationInterval);
- bag->Set("notification_period", m_NotificationPeriod);
- bag->Set("last_notification", m_LastNotification);
- bag->Set("next_notification", m_NextNotification);
- bag->Set("notification_number", m_NotificationNumber);
- bag->Set("macros", m_Macros);
- bag->Set("users", m_Users);
- bag->Set("groups", m_Groups);
- bag->Set("times", m_Times);
- bag->Set("notification_type_filter", m_NotificationTypeFilter);
- bag->Set("notification_state_filter", m_NotificationStateFilter);
- bag->Set("host_name", m_HostName);
- bag->Set("export_macros", m_ExportMacros);
- bag->Set("service", m_Service);
+ if (attributeTypes & Attribute_Config) {
+ bag->Set("notification_command", m_NotificationCommand);
+ bag->Set("notification_interval", m_NotificationInterval);
+ bag->Set("notification_period", m_NotificationPeriod);
+ bag->Set("macros", m_Macros);
+ bag->Set("users", m_Users);
+ bag->Set("groups", m_Groups);
+ bag->Set("times", m_Times);
+ bag->Set("notification_type_filter", m_NotificationTypeFilter);
+ bag->Set("notification_state_filter", m_NotificationStateFilter);
+ bag->Set("host_name", m_HostName);
+ bag->Set("export_macros", m_ExportMacros);
+ bag->Set("service", m_Service);
+ }
+
+ if (attributeTypes & Attribute_State) {
+ bag->Set("last_notification", m_LastNotification);
+ bag->Set("next_notification", m_NextNotification);
+ bag->Set("notification_number", m_NotificationNumber);
+ }
}
void Notification::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
{
DynamicObject::InternalDeserialize(bag, attributeTypes);
- m_NotificationCommand = bag->Get("notification_command");
- m_NotificationInterval = bag->Get("notification_interval");
- m_NotificationPeriod = bag->Get("notification_period");
- m_LastNotification = bag->Get("last_notification");
- m_NextNotification = bag->Get("next_notification");
- m_NotificationNumber = bag->Get("notification_number");
- m_Macros = bag->Get("macros");
- m_Users = bag->Get("users");
- m_Groups = bag->Get("groups");
- m_Times = bag->Get("times");
- m_NotificationTypeFilter = bag->Get("notification_type_filter");
- m_NotificationStateFilter = bag->Get("notification_state_filter");
- m_HostName = bag->Get("host_name");
- m_ExportMacros = bag->Get("export_macros");
- m_Service = bag->Get("service");
+ if (attributeTypes & Attribute_Config) {
+ m_NotificationCommand = bag->Get("notification_command");
+ m_NotificationInterval = bag->Get("notification_interval");
+ m_NotificationPeriod = bag->Get("notification_period");
+ m_Macros = bag->Get("macros");
+ m_Users = bag->Get("users");
+ m_Groups = bag->Get("groups");
+ m_Times = bag->Get("times");
+ m_NotificationTypeFilter = bag->Get("notification_type_filter");
+ m_NotificationStateFilter = bag->Get("notification_state_filter");
+ m_HostName = bag->Get("host_name");
+ m_ExportMacros = bag->Get("export_macros");
+ m_Service = bag->Get("service");
+ }
+
+ if (attributeTypes & Attribute_State) {
+ m_LastNotification = bag->Get("last_notification");
+ m_NextNotification = bag->Get("next_notification");
+ m_NotificationNumber = bag->Get("notification_number");
+ }
}
bag->Set("notifications", m_NotificationDescriptions);
}
- bag->Set("next_check", m_NextCheck);
- bag->Set("current_checker", m_CurrentChecker);
- bag->Set("check_attempt", m_CheckAttempt);
- bag->Set("state", m_State);
- bag->Set("state_type", m_StateType);
- bag->Set("last_state", m_LastState);
- bag->Set("last_hard_state", m_LastHardState);
- bag->Set("last_state_type", m_LastStateType);
- bag->Set("last_reachable", m_LastReachable);
- bag->Set("last_result", m_LastResult);
- bag->Set("last_state_change", m_LastStateChange);
- bag->Set("last_hard_state_change", m_LastHardStateChange);
- bag->Set("last_state_ok", m_LastStateOK);
- bag->Set("last_state_warning", m_LastStateWarning);
- bag->Set("last_state_critical", m_LastStateCritical);
- bag->Set("last_state_unknown", m_LastStateUnknown);
- bag->Set("last_state_unreachable", m_LastStateUnreachable);
- bag->Set("last_in_downtime", m_LastInDowntime);
- bag->Set("enable_active_checks", m_EnableActiveChecks);
- bag->Set("enable_passive_checks", m_EnablePassiveChecks);
- bag->Set("force_next_check", m_ForceNextCheck);
- bag->Set("acknowledgement", m_Acknowledgement);
- bag->Set("acknowledgement_expiry", m_AcknowledgementExpiry);
- bag->Set("comments", m_Comments);
- bag->Set("downtimes", m_Downtimes);
- bag->Set("enable_notifications", m_EnableNotifications);
- bag->Set("force_next_notification", m_ForceNextNotification);
- bag->Set("flapping_positive", m_FlappingPositive);
- bag->Set("flapping_negative", m_FlappingNegative);
- bag->Set("flapping_lastchange", m_FlappingLastChange);
- bag->Set("enable_flapping", m_EnableFlapping);
+ if (attributeTypes & Attribute_State) {
+ bag->Set("next_check", m_NextCheck);
+ bag->Set("current_checker", m_CurrentChecker);
+ bag->Set("check_attempt", m_CheckAttempt);
+ bag->Set("state", m_State);
+ bag->Set("state_type", m_StateType);
+ bag->Set("last_state", m_LastState);
+ bag->Set("last_hard_state", m_LastHardState);
+ bag->Set("last_state_type", m_LastStateType);
+ bag->Set("last_reachable", m_LastReachable);
+ bag->Set("last_result", m_LastResult);
+ bag->Set("last_state_change", m_LastStateChange);
+ bag->Set("last_hard_state_change", m_LastHardStateChange);
+ bag->Set("last_state_ok", m_LastStateOK);
+ bag->Set("last_state_warning", m_LastStateWarning);
+ bag->Set("last_state_critical", m_LastStateCritical);
+ bag->Set("last_state_unknown", m_LastStateUnknown);
+ bag->Set("last_state_unreachable", m_LastStateUnreachable);
+ bag->Set("last_in_downtime", m_LastInDowntime);
+ bag->Set("enable_active_checks", m_EnableActiveChecks);
+ bag->Set("enable_passive_checks", m_EnablePassiveChecks);
+ bag->Set("force_next_check", m_ForceNextCheck);
+ bag->Set("acknowledgement", m_Acknowledgement);
+ bag->Set("acknowledgement_expiry", m_AcknowledgementExpiry);
+ bag->Set("comments", m_Comments);
+ bag->Set("downtimes", m_Downtimes);
+ bag->Set("enable_notifications", m_EnableNotifications);
+ bag->Set("force_next_notification", m_ForceNextNotification);
+ bag->Set("flapping_positive", m_FlappingPositive);
+ bag->Set("flapping_negative", m_FlappingNegative);
+ bag->Set("flapping_lastchange", m_FlappingLastChange);
+ bag->Set("enable_flapping", m_EnableFlapping);
+ }
}
void Service::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
m_NotificationDescriptions = bag->Get("notifications");
}
- m_NextCheck = bag->Get("next_check");
- m_CurrentChecker = bag->Get("current_checker");
- m_CheckAttempt = bag->Get("check_attempt");
- m_State = bag->Get("state");
- m_StateType = bag->Get("state_type");
- m_LastState = bag->Get("last_state");
- m_LastHardState = bag->Get("last_hard_state");
- m_LastStateType = bag->Get("last_state_type");
- m_LastReachable = bag->Get("last_reachable");
- m_LastResult = bag->Get("last_result");
- m_LastStateChange = bag->Get("last_state_change");
- m_LastHardStateChange = bag->Get("last_hard_state_change");
- m_LastStateOK = bag->Get("last_state_ok");
- m_LastStateWarning = bag->Get("last_state_warning");
- m_LastStateCritical = bag->Get("last_state_critical");
- m_LastStateUnknown = bag->Get("last_state_unknown");
- m_LastStateUnreachable = bag->Get("last_state_unreachable");
- m_LastInDowntime = bag->Get("last_in_downtime");
- m_EnableActiveChecks = bag->Get("enable_active_checks");
- m_EnablePassiveChecks = bag->Get("enable_passive_checks");
- m_ForceNextCheck = bag->Get("force_next_check");
- m_Acknowledgement = bag->Get("acknowledgement");
- m_AcknowledgementExpiry = bag->Get("acknowledgement_expiry");
- m_Comments = bag->Get("comments");
- m_Downtimes = bag->Get("downtimes");
- m_EnableNotifications = bag->Get("enable_notifications");
- m_ForceNextNotification = bag->Get("force_next_notification");
- m_FlappingPositive = bag->Get("flapping_positive");
- m_FlappingNegative = bag->Get("flapping_negative");
- m_FlappingLastChange = bag->Get("flapping_lastchange");
- m_EnableFlapping = bag->Get("enable_flapping");
+ if (attributeTypes & Attribute_State) {
+ m_NextCheck = bag->Get("next_check");
+ m_CurrentChecker = bag->Get("current_checker");
+ m_CheckAttempt = bag->Get("check_attempt");
+ m_State = bag->Get("state");
+ m_StateType = bag->Get("state_type");
+ m_LastState = bag->Get("last_state");
+ m_LastHardState = bag->Get("last_hard_state");
+ m_LastStateType = bag->Get("last_state_type");
+ m_LastReachable = bag->Get("last_reachable");
+ m_LastResult = bag->Get("last_result");
+ m_LastStateChange = bag->Get("last_state_change");
+ m_LastHardStateChange = bag->Get("last_hard_state_change");
+ m_LastStateOK = bag->Get("last_state_ok");
+ m_LastStateWarning = bag->Get("last_state_warning");
+ m_LastStateCritical = bag->Get("last_state_critical");
+ m_LastStateUnknown = bag->Get("last_state_unknown");
+ m_LastStateUnreachable = bag->Get("last_state_unreachable");
+ m_LastInDowntime = bag->Get("last_in_downtime");
+ m_EnableActiveChecks = bag->Get("enable_active_checks");
+ m_EnablePassiveChecks = bag->Get("enable_passive_checks");
+ m_ForceNextCheck = bag->Get("force_next_check");
+ m_Acknowledgement = bag->Get("acknowledgement");
+ m_AcknowledgementExpiry = bag->Get("acknowledgement_expiry");
+ m_Comments = bag->Get("comments");
+ m_Downtimes = bag->Get("downtimes");
+ m_EnableNotifications = bag->Get("enable_notifications");
+ m_ForceNextNotification = bag->Get("force_next_notification");
+ m_FlappingPositive = bag->Get("flapping_positive");
+ m_FlappingNegative = bag->Get("flapping_negative");
+ m_FlappingLastChange = bag->Get("flapping_lastchange");
+ m_EnableFlapping = bag->Get("enable_flapping");
+ }
}
bag->Set("ranges", m_Ranges);
}
- bag->Set("valid_begin", m_ValidBegin);
- bag->Set("valid_end", m_ValidEnd);
- bag->Set("segments", m_Segments);
+ if (attributeTypes & Attribute_State) {
+ bag->Set("valid_begin", m_ValidBegin);
+ bag->Set("valid_end", m_ValidEnd);
+ bag->Set("segments", m_Segments);
+ }
}
void TimePeriod::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
m_Ranges = bag->Get("ranges");
}
- m_ValidBegin = bag->Get("valid_begin");
- m_ValidEnd = bag->Get("valid_end");
- m_Segments = bag->Get("segments");
+ if (attributeTypes & Attribute_State) {
+ m_ValidBegin = bag->Get("valid_begin");
+ m_ValidEnd = bag->Get("valid_end");
+ m_Segments = bag->Get("segments");
+ }
}
bag->Set("notification_state_filter", m_NotificationStateFilter);
}
- bag->Set("enable_notifications", m_EnableNotifications);
- bag->Set("last_notification", m_LastNotification);
+ if (attributeTypes & Attribute_State) {
+ bag->Set("enable_notifications", m_EnableNotifications);
+ bag->Set("last_notification", m_LastNotification);
+ }
}
void User::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
m_NotificationStateFilter = bag->Get("notification_state_filter");
}
- m_EnableNotifications = bag->Get("enable_notifications");
- m_LastNotification = bag->Get("last_notification");
+ if (attributeTypes & Attribute_State) {
+ m_EnableNotifications = bag->Get("enable_notifications");
+ m_LastNotification = bag->Get("last_notification");
+ }
}