mirror of https://github.com/Icinga/icinga2.git
Report failed reload attempts for the icinga check
fixes #9060 fixes #9997 fixes #11129
This commit is contained in:
parent
0b95be7b99
commit
1ad4d9cd27
|
@ -62,6 +62,7 @@ char **Application::m_ArgV;
|
|||
double Application::m_StartTime;
|
||||
double Application::m_MainTime;
|
||||
bool Application::m_ScriptDebuggerEnabled = false;
|
||||
double Application::m_LastReloadFailed;
|
||||
|
||||
/**
|
||||
* Constructor for the Application class.
|
||||
|
@ -330,8 +331,10 @@ void Application::OnShutdown(void)
|
|||
|
||||
static void ReloadProcessCallbackInternal(const ProcessResult& pr)
|
||||
{
|
||||
if (pr.ExitStatus != 0)
|
||||
if (pr.ExitStatus != 0) {
|
||||
Application::SetLastReloadFailed(Utility::GetTime());
|
||||
Log(LogCritical, "Application", "Found error in config: reloading aborted");
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else
|
||||
Application::Exit(7); /* keep this exit code in sync with icinga-app */
|
||||
|
@ -1387,6 +1390,16 @@ void Application::SetScriptDebuggerEnabled(bool enabled)
|
|||
m_ScriptDebuggerEnabled = enabled;
|
||||
}
|
||||
|
||||
double Application::GetLastReloadFailed(void)
|
||||
{
|
||||
return m_LastReloadFailed;
|
||||
}
|
||||
|
||||
void Application::SetLastReloadFailed(double ts)
|
||||
{
|
||||
m_LastReloadFailed = ts;
|
||||
}
|
||||
|
||||
void Application::ValidateName(const String& value, const ValidationUtils& utils)
|
||||
{
|
||||
ObjectImpl<Application>::ValidateName(value, utils);
|
||||
|
|
|
@ -140,6 +140,9 @@ public:
|
|||
static bool GetScriptDebuggerEnabled(void);
|
||||
static void SetScriptDebuggerEnabled(bool enabled);
|
||||
|
||||
static double GetLastReloadFailed(void);
|
||||
static void SetLastReloadFailed(double ts);
|
||||
|
||||
static void DisplayInfoMessage(std::ostream& os, bool skipVersion = false);
|
||||
|
||||
protected:
|
||||
|
@ -172,6 +175,7 @@ private:
|
|||
static double m_StartTime;
|
||||
static double m_MainTime;
|
||||
static bool m_ScriptDebuggerEnabled;
|
||||
static double m_LastReloadFailed;
|
||||
|
||||
#ifndef _WIN32
|
||||
static void SigIntTermHandler(int signum);
|
||||
|
|
|
@ -100,7 +100,14 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResul
|
|||
cr->SetOutput("Icinga 2 has been running for " + Utility::FormatDuration(uptime) +
|
||||
". Version: " + Application::GetAppVersion());
|
||||
cr->SetPerformanceData(perfdata);
|
||||
cr->SetState(ServiceOK);
|
||||
|
||||
double lastReloadFailed = Application::GetLastReloadFailed();
|
||||
|
||||
if (lastReloadFailed > 0) {
|
||||
cr->SetOutput(cr->GetOutput() + "; Last reload attempt failed at " + Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", lastReloadFailed));
|
||||
cr->SetState(ServiceWarning);
|
||||
} else
|
||||
cr->SetState(ServiceOK);
|
||||
|
||||
service->ProcessCheckResult(cr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue