Skip to content
Permalink
Browse files

Report failed reload attempts for the icinga check

fixes #9060
fixes #9997
fixes #11129
  • Loading branch information...
gunnarbeutner committed May 11, 2016
1 parent 21d1ffa commit ff24863a72bba0d136995c48c423e90427322772
Showing with 26 additions and 2 deletions.
  1. +14 −1 lib/base/application.cpp
  2. +4 −0 lib/base/application.hpp
  3. +8 −1 lib/methods/icingachecktask.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<Application>::ValidateName(value, utils);
@@ -140,6 +140,9 @@ class I2_BASE_API Application : public ObjectImpl<Application> {
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 @@ class I2_BASE_API Application : public ObjectImpl<Application> {
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);
}

0 comments on commit ff24863

Please sign in to comment.
You can’t perform that action at this time.