diff --git a/lib/base/application.cpp b/lib/base/application.cpp index c9e2c7c33..77c610216 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -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::ValidateName(value, utils); diff --git a/lib/base/application.hpp b/lib/base/application.hpp index 2174d3e03..9e5bb3d14 100644 --- a/lib/base/application.hpp +++ b/lib/base/application.hpp @@ -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); diff --git a/lib/methods/icingachecktask.cpp b/lib/methods/icingachecktask.cpp index 9ce8797f0..89642a39d 100644 --- a/lib/methods/icingachecktask.cpp +++ b/lib/methods/icingachecktask.cpp @@ -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); }