mirror of https://github.com/Icinga/icinga2.git
Add global Enable{Host,Service}Checks. Update interfaces and external commands.
Fixes #6037 Fixes #5975
This commit is contained in:
parent
7be74c8141
commit
0dedd7cf19
|
@ -143,8 +143,16 @@ void CheckerComponent::CheckThreadProc(void)
|
|||
check = false;
|
||||
}
|
||||
|
||||
if (!checkable->GetEnableActiveChecks() || !IcingaApplication::GetInstance()->GetEnableChecks()) {
|
||||
Log(LogDebug, "checker", "Skipping check for object '" + checkable->GetName() + "': active checks are disabled");
|
||||
Host::Ptr host;
|
||||
Service::Ptr service;
|
||||
tie(host, service) = GetHostService(checkable);
|
||||
|
||||
if (!checkable->GetEnableActiveChecks() || (host && !service && !IcingaApplication::GetInstance()->GetEnableHostChecks())) {
|
||||
Log(LogDebug, "checker", "Skipping check for host '" + host->GetName() + "': active host checks are disabled");
|
||||
check = false;
|
||||
}
|
||||
if (!checkable->GetEnableActiveChecks() || (host && service && !IcingaApplication::GetInstance()->GetEnableServiceChecks())) {
|
||||
Log(LogDebug, "checker", "Skipping check for service '" + service->GetName() + "': active service checks are disabled");
|
||||
check = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1696,7 +1696,7 @@ bool ClusterListener::SupportsChecks(void)
|
|||
if (!type)
|
||||
return false;
|
||||
|
||||
return std::distance(type->GetObjects().first, type->GetObjects().second) > 0 && IcingaApplication::GetInstance()->GetEnableChecks();
|
||||
return std::distance(type->GetObjects().first, type->GetObjects().second) > 0 && (IcingaApplication::GetInstance()->GetEnableHostChecks() || IcingaApplication::GetInstance()->GetEnableServiceChecks());
|
||||
}
|
||||
|
||||
bool ClusterListener::SupportsNotifications(void)
|
||||
|
|
|
@ -735,10 +735,10 @@ void StatusDataWriter::StatusTimerHandler(void)
|
|||
"\t" "icinga_pid=" << Utility::GetPid() << "\n"
|
||||
"\t" "daemon_mode=1" "\n"
|
||||
"\t" "program_start=" << static_cast<long>(Application::GetStartTime()) << "\n"
|
||||
"\t" "active_service_checks_enabled=" << (IcingaApplication::GetInstance()->GetEnableChecks() ? 1 : 0) << "\n"
|
||||
"\t" "passive_service_checks_enabled=1" "\n"
|
||||
"\t" "active_host_checks_enabled=1" "\n"
|
||||
"\t" "active_host_checks_enabled=" << (IcingaApplication::GetInstance()->GetEnableHostChecks() ? 1 : 0) << "\n"
|
||||
"\t" "passive_host_checks_enabled=1" "\n"
|
||||
"\t" "active_service_checks_enabled=" << (IcingaApplication::GetInstance()->GetEnableServiceChecks() ? 1 : 0) << "\n"
|
||||
"\t" "passive_service_checks_enabled=1" "\n"
|
||||
"\t" "check_service_freshness=1" "\n"
|
||||
"\t" "check_host_freshness=1" "\n"
|
||||
"\t" "enable_notifications=" << (IcingaApplication::GetInstance()->GetEnableNotifications() ? 1 : 0) << "\n"
|
||||
|
|
|
@ -71,7 +71,7 @@ void StatusTable::AddColumns(Table *table, const String& prefix,
|
|||
table->AddColumn(prefix + "enable_notifications", Column(&StatusTable::EnableNotificationsAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "execute_service_checks", Column(&StatusTable::ExecuteServiceChecksAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "accept_passive_service_checks", Column(&Table::OneAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "execute_host_checks", Column(&Table::OneAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "execute_host_checks", Column(&StatusTable::ExecuteHostChecksAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "accept_passive_host_checks", Column(&Table::OneAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "enable_event_handlers", Column(&StatusTable::EnableEventHandlersAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "obsess_over_services", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
|
@ -159,7 +159,12 @@ Value StatusTable::EnableNotificationsAccessor(const Value&)
|
|||
|
||||
Value StatusTable::ExecuteServiceChecksAccessor(const Value&)
|
||||
{
|
||||
return (IcingaApplication::GetInstance()->GetEnableChecks() ? 1 : 0);
|
||||
return (IcingaApplication::GetInstance()->GetEnableServiceChecks() ? 1 : 0);
|
||||
}
|
||||
|
||||
Value StatusTable::ExecuteHostChecksAccessor(const Value&)
|
||||
{
|
||||
return (IcingaApplication::GetInstance()->GetEnableHostChecks() ? 1 : 0);
|
||||
}
|
||||
|
||||
Value StatusTable::EnableEventHandlersAccessor(const Value&)
|
||||
|
|
|
@ -54,6 +54,7 @@ protected:
|
|||
static Value NagiosPidAccessor(const Value& row);
|
||||
static Value EnableNotificationsAccessor(const Value& row);
|
||||
static Value ExecuteServiceChecksAccessor(const Value& row);
|
||||
static Value ExecuteHostChecksAccessor(const Value& row);
|
||||
static Value EnableEventHandlersAccessor(const Value& row);
|
||||
static Value EnableFlapDetectionAccessor(const Value& row);
|
||||
static Value ProcessPerformanceDataAccessor(const Value& row);
|
||||
|
|
|
@ -16,6 +16,7 @@ ApplicationType |**Read-write.** Contains the name of the Application type.
|
|||
EnableNotifications |**Read-write.** Whether notifications are globally enabled. Defaults to true.
|
||||
EnableEventHandlers |**Read-write.** Whether event handlers are globally enabled. Defaults to true.
|
||||
EnableFlapping |**Read-write.** Whether flap detection is globally enabled. Defaults to true.
|
||||
EnableChecks |**Read-write.** Whether active checks are globally enabled. Defaults to true.
|
||||
EnableHostChecks |**Read-write.** Whether active host checks are globally enabled. Defaults to true.
|
||||
EnableServiceChecks |**Read-write.** Whether active service checks are globally enabled. Defaults to true.
|
||||
EnablePerfdata |**Read-write.** Whether performance data processing is globally enabled. Defaults to true.
|
||||
UseVfork |**Read-write.** Whether to use vfork(). Only available on *NIX. Defaults to true.
|
||||
|
|
|
@ -96,7 +96,9 @@ void DbConnection::ProgramStatusHandler(void)
|
|||
query2.Fields->Set("daemon_mode", 1);
|
||||
query2.Fields->Set("last_command_check", DbValue::FromTimestamp(Utility::GetTime()));
|
||||
query2.Fields->Set("notifications_enabled", (IcingaApplication::GetInstance()->GetEnableNotifications() ? 1 : 0));
|
||||
query2.Fields->Set("active_service_checks_enabled", (IcingaApplication::GetInstance()->GetEnableChecks() ? 1 : 0));
|
||||
query2.Fields->Set("active_host_checks_enabled", (IcingaApplication::GetInstance()->GetEnableHostChecks() ? 1 : 0));
|
||||
query2.Fields->Set("passive_host_checks_enabled", 1);
|
||||
query2.Fields->Set("active_service_checks_enabled", (IcingaApplication::GetInstance()->GetEnableServiceChecks() ? 1 : 0));
|
||||
query2.Fields->Set("passive_service_checks_enabled", 1);
|
||||
query2.Fields->Set("event_handlers_enabled", (IcingaApplication::GetInstance()->GetEnableEventHandlers() ? 1 : 0));
|
||||
query2.Fields->Set("flap_detection_enabled", (IcingaApplication::GetInstance()->GetEnableFlapping() ? 1 : 0));
|
||||
|
|
|
@ -84,6 +84,17 @@ enum DependencyType
|
|||
DependencyNotification
|
||||
};
|
||||
|
||||
/**
|
||||
* Checkable Types
|
||||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
enum CheckableType
|
||||
{
|
||||
CheckableHost,
|
||||
CheckableService
|
||||
};
|
||||
|
||||
class CheckCommand;
|
||||
class EventCommand;
|
||||
class Dependency;
|
||||
|
|
|
@ -225,6 +225,8 @@ void ExternalCommandProcessor::Initialize(void)
|
|||
RegisterCommand("DISABLE_PERFORMANCE_DATA", &ExternalCommandProcessor::DisablePerformanceData);
|
||||
RegisterCommand("START_EXECUTING_SVC_CHECKS", &ExternalCommandProcessor::StartExecutingSvcChecks);
|
||||
RegisterCommand("STOP_EXECUTING_SVC_CHECKS", &ExternalCommandProcessor::StopExecutingSvcChecks);
|
||||
RegisterCommand("START_EXECUTING_HOST_CHECKS", &ExternalCommandProcessor::StartExecutingHostChecks);
|
||||
RegisterCommand("STOP_EXECUTING_HOST_CHECKS", &ExternalCommandProcessor::StopExecutingHostChecks);
|
||||
RegisterCommand("CHANGE_SVC_MODATTR", &ExternalCommandProcessor::ChangeSvcModattr, 3);
|
||||
RegisterCommand("CHANGE_HOST_MODATTR", &ExternalCommandProcessor::ChangeHostModattr, 2);
|
||||
RegisterCommand("CHANGE_NORMAL_SVC_CHECK_INTERVAL", &ExternalCommandProcessor::ChangeNormalSvcCheckInterval, 3);
|
||||
|
@ -1586,16 +1588,30 @@ void ExternalCommandProcessor::DisablePerformanceData(double time, const std::ve
|
|||
|
||||
void ExternalCommandProcessor::StartExecutingSvcChecks(double time, const std::vector<String>& arguments)
|
||||
{
|
||||
Log(LogInformation, "icinga", "Globally enabling checks.");
|
||||
Log(LogInformation, "icinga", "Globally enabling service checks.");
|
||||
|
||||
IcingaApplication::GetInstance()->SetEnableChecks(true);
|
||||
IcingaApplication::GetInstance()->SetEnableServiceChecks(true);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::StopExecutingSvcChecks(double time, const std::vector<String>& arguments)
|
||||
{
|
||||
Log(LogInformation, "icinga", "Globally disabling checks.");
|
||||
Log(LogInformation, "icinga", "Globally disabling service checks.");
|
||||
|
||||
IcingaApplication::GetInstance()->SetEnableChecks(false);
|
||||
IcingaApplication::GetInstance()->SetEnableServiceChecks(false);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::StartExecutingHostChecks(double time, const std::vector<String>& arguments)
|
||||
{
|
||||
Log(LogInformation, "icinga", "Globally enabling host checks.");
|
||||
|
||||
IcingaApplication::GetInstance()->SetEnableHostChecks(true);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::StopExecutingHostChecks(double time, const std::vector<String>& arguments)
|
||||
{
|
||||
Log(LogInformation, "icinga", "Globally disabling host checks.");
|
||||
|
||||
IcingaApplication::GetInstance()->SetEnableHostChecks(false);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::ChangeSvcModattr(double time, const std::vector<String>& arguments)
|
||||
|
|
|
@ -123,6 +123,8 @@ private:
|
|||
static void DisablePerformanceData(double time, const std::vector<String>& arguments);
|
||||
static void StartExecutingSvcChecks(double time, const std::vector<String>& arguments);
|
||||
static void StopExecutingSvcChecks(double time, const std::vector<String>& arguments);
|
||||
static void StartExecutingHostChecks(double time, const std::vector<String>& arguments);
|
||||
static void StopExecutingHostChecks(double time, const std::vector<String>& arguments);
|
||||
static void ChangeSvcModattr(double time, const std::vector<String>& arguments);
|
||||
static void ChangeHostModattr(double time, const std::vector<String>& arguments);
|
||||
static void ChangeNormalSvcCheckInterval(double time, const std::vector<String>& arguments);
|
||||
|
|
|
@ -41,7 +41,8 @@ void IcingaApplication::StaticInitialize(void)
|
|||
ScriptVariable::Set("EnableNotifications", true);
|
||||
ScriptVariable::Set("EnableEventHandlers", true);
|
||||
ScriptVariable::Set("EnableFlapping", true);
|
||||
ScriptVariable::Set("EnableChecks", true);
|
||||
ScriptVariable::Set("EnableHostChecks", true);
|
||||
ScriptVariable::Set("EnableServiceChecks", true);
|
||||
ScriptVariable::Set("EnablePerfdata", true);
|
||||
ScriptVariable::Set("NodeName", Utility::GetHostName());
|
||||
}
|
||||
|
@ -58,7 +59,8 @@ Value IcingaApplication::StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& per
|
|||
stats->Set("enable_notifications", icingaapplication->GetEnableNotifications());
|
||||
stats->Set("enable_event_handlers", icingaapplication->GetEnableEventHandlers());
|
||||
stats->Set("enable_flapping", icingaapplication->GetEnableFlapping());
|
||||
stats->Set("enable_checks", icingaapplication->GetEnableChecks());
|
||||
stats->Set("enable_host_checks", icingaapplication->GetEnableHostChecks());
|
||||
stats->Set("enable_service_checks", icingaapplication->GetEnableServiceChecks());
|
||||
stats->Set("enable_perfdata", icingaapplication->GetEnablePerfdata());
|
||||
stats->Set("pid", Utility::GetPid());
|
||||
stats->Set("program_start", Application::GetStartTime());
|
||||
|
@ -216,22 +218,40 @@ void IcingaApplication::ClearEnableFlapping(void)
|
|||
SetOverrideEnableFlapping(Empty);
|
||||
}
|
||||
|
||||
bool IcingaApplication::GetEnableChecks(void) const
|
||||
bool IcingaApplication::GetEnableHostChecks(void) const
|
||||
{
|
||||
if (!GetOverrideEnableChecks().IsEmpty())
|
||||
return GetOverrideEnableChecks();
|
||||
if (!GetOverrideEnableHostChecks().IsEmpty())
|
||||
return GetOverrideEnableHostChecks();
|
||||
else
|
||||
return ScriptVariable::Get("EnableChecks");
|
||||
return ScriptVariable::Get("EnableHostChecks");
|
||||
}
|
||||
|
||||
void IcingaApplication::SetEnableChecks(bool enabled)
|
||||
void IcingaApplication::SetEnableHostChecks(bool enabled)
|
||||
{
|
||||
SetOverrideEnableChecks(enabled);
|
||||
SetOverrideEnableHostChecks(enabled);
|
||||
}
|
||||
|
||||
void IcingaApplication::ClearEnableChecks(void)
|
||||
void IcingaApplication::ClearEnableHostChecks(void)
|
||||
{
|
||||
SetOverrideEnableChecks(Empty);
|
||||
SetOverrideEnableHostChecks(Empty);
|
||||
}
|
||||
|
||||
bool IcingaApplication::GetEnableServiceChecks(void) const
|
||||
{
|
||||
if (!GetOverrideEnableServiceChecks().IsEmpty())
|
||||
return GetOverrideEnableServiceChecks();
|
||||
else
|
||||
return ScriptVariable::Get("EnableServiceChecks");
|
||||
}
|
||||
|
||||
void IcingaApplication::SetEnableServiceChecks(bool enabled)
|
||||
{
|
||||
SetOverrideEnableServiceChecks(enabled);
|
||||
}
|
||||
|
||||
void IcingaApplication::ClearEnableServiceChecks(void)
|
||||
{
|
||||
SetOverrideEnableServiceChecks(Empty);
|
||||
}
|
||||
|
||||
bool IcingaApplication::GetEnablePerfdata(void) const
|
||||
|
|
|
@ -64,9 +64,12 @@ public:
|
|||
void SetEnableFlapping(bool enabled);
|
||||
void ClearEnableFlapping(void);
|
||||
|
||||
bool GetEnableChecks(void) const;
|
||||
void SetEnableChecks(bool enabled);
|
||||
void ClearEnableChecks(void);
|
||||
bool GetEnableHostChecks(void) const;
|
||||
void SetEnableHostChecks(bool enabled);
|
||||
void ClearEnableHostChecks(void);
|
||||
bool GetEnableServiceChecks(void) const;
|
||||
void SetEnableServiceChecks(bool enabled);
|
||||
void ClearEnableServiceChecks(void);
|
||||
|
||||
bool GetEnablePerfdata(void) const;
|
||||
void SetEnablePerfdata(bool enabled);
|
||||
|
|
|
@ -8,7 +8,8 @@ class IcingaApplication : Application
|
|||
[state, protected] Value override_enable_notifications;
|
||||
[state, protected] Value override_enable_event_handlers;
|
||||
[state, protected] Value override_enable_flapping;
|
||||
[state, protected] Value override_enable_checks;
|
||||
[state, protected] Value override_enable_host_checks;
|
||||
[state, protected] Value override_enable_service_checks;
|
||||
[state, protected] Value override_enable_perfdata;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
GET status
|
||||
Columns: accept_passive_host_checks accept_passive_service_checks execute_host_checks execute_service_checks
|
||||
ResponseHeader: fixed16
|
||||
|
Loading…
Reference in New Issue