mirror of https://github.com/Icinga/icinga2.git
Renamed retention.dat to icinga.state and made the path configurable.
This commit is contained in:
parent
6982656f2d
commit
5218a088c1
|
@ -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<String>& 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<String>& args)
|
|||
}
|
||||
|
||||
/* restore the previous program state */
|
||||
DynamicObject::RestoreObjects("retention.dat");
|
||||
DynamicObject::RestoreObjects(GetStatePath());
|
||||
|
||||
/* periodically dump the program state */
|
||||
m_RetentionTimer = boost::make_shared<Timer>();
|
||||
|
@ -203,8 +208,9 @@ int IcingaApplication::Main(const vector<String>& 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue