From: Gunnar Beutner Date: Tue, 7 Aug 2012 07:44:36 +0000 (+0200) Subject: Renamed retention.dat to icinga.state and made the path configurable. X-Git-Tag: v0.0.1~157 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5218a088c1e72000a7e546424d80e448fe7fa4d1;p=icinga2 Renamed retention.dat to icinga.state and made the path configurable. --- diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index d8d829999..37336d48f 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -29,6 +29,7 @@ using namespace icinga; const String IcingaApplication::DefaultPidPath = "icinga.pid"; +const String IcingaApplication::DefaultStatePath = "icinga.state"; IcingaApplication::IcingaApplication(void) { } @@ -141,11 +142,15 @@ int IcingaApplication::Main(const vector& args) m_CAFile = icingaConfig->Get("ca"); m_Node = icingaConfig->Get("node"); m_Service = icingaConfig->Get("service"); - m_PidPath = icingaConfig->Get("pidpath"); + m_PidPath = icingaConfig->Get("pidpath"); if (m_PidPath.IsEmpty()) m_PidPath = DefaultPidPath; + m_StatePath = icingaConfig->Get("statepath"); + if (m_StatePath.IsEmpty()) + m_StatePath = DefaultStatePath; + m_Macros = icingaConfig->Get("macros"); String logpath = icingaConfig->Get("logpath"); @@ -185,7 +190,7 @@ int IcingaApplication::Main(const vector& args) } /* restore the previous program state */ - DynamicObject::RestoreObjects("retention.dat"); + DynamicObject::RestoreObjects(GetStatePath()); /* periodically dump the program state */ m_RetentionTimer = boost::make_shared(); @@ -203,8 +208,9 @@ int IcingaApplication::Main(const vector& args) } void IcingaApplication::DumpProgramState(void) { - DynamicObject::DumpObjects("retention.dat.tmp"); - rename("retention.dat.tmp", "retention.dat"); + String temp = GetStatePath() + ".tmp"; + DynamicObject::DumpObjects(temp); + rename(temp.CStr(), GetStatePath().CStr()); } IcingaApplication::Ptr IcingaApplication::GetInstance(void) @@ -237,6 +243,11 @@ String IcingaApplication::GetPidPath(void) const return m_PidPath; } +String IcingaApplication::GetStatePath(void) const +{ + return m_StatePath; +} + Dictionary::Ptr IcingaApplication::GetMacros(void) const { return m_Macros; diff --git a/icinga/icingaapplication.h b/icinga/icingaapplication.h index 15ef8cb0f..91947d997 100644 --- a/icinga/icingaapplication.h +++ b/icinga/icingaapplication.h @@ -45,11 +45,13 @@ public: String GetNode(void) const; String GetService(void) const; String GetPidPath(void) const; + String GetStatePath(void) const; Dictionary::Ptr GetMacros(void) const; double GetStartTime(void) const; static const String DefaultPidPath; + static const String DefaultStatePath; private: String m_CertificateFile; @@ -57,6 +59,7 @@ private: String m_Node; String m_Service; String m_PidPath; + String m_StatePath; Dictionary::Ptr m_Macros; double m_StartTime;