mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 08:04:14 +02:00
Implement global attributes.
This commit is contained in:
parent
28bc5eab7d
commit
369d88b3c4
@ -18,6 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "checker/checkercomponent.h"
|
#include "checker/checkercomponent.h"
|
||||||
|
#include "icinga/icingaapplication.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/utility.h"
|
#include "base/utility.h"
|
||||||
@ -103,7 +104,7 @@ void CheckerComponent::CheckThreadProc(void)
|
|||||||
bool authoritative = service->HasAuthority("checker");
|
bool authoritative = service->HasAuthority("checker");
|
||||||
|
|
||||||
if (!forced) {
|
if (!forced) {
|
||||||
if (!service->GetEnableActiveChecks()) {
|
if (!service->GetEnableActiveChecks() || !IcingaApplication::GetInstance()->GetEnableChecks()) {
|
||||||
Log(LogDebug, "checker", "Skipping check for service '" + service->GetName() + "': active checks are disabled");
|
Log(LogDebug, "checker", "Skipping check for service '" + service->GetName() + "': active checks are disabled");
|
||||||
check = false;
|
check = false;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "cluster/clusterlistener.h"
|
#include "cluster/clusterlistener.h"
|
||||||
#include "cluster/endpoint.h"
|
#include "cluster/endpoint.h"
|
||||||
#include "icinga/domain.h"
|
#include "icinga/domain.h"
|
||||||
|
#include "icinga/icingaapplication.h"
|
||||||
#include "base/netstring.h"
|
#include "base/netstring.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
||||||
@ -1534,7 +1535,7 @@ bool ClusterListener::SupportsChecks(void)
|
|||||||
if (!type)
|
if (!type)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !type->GetObjects().empty();
|
return !type->GetObjects().empty() && IcingaApplication::GetInstance()->GetEnableChecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClusterListener::SupportsNotifications(void)
|
bool ClusterListener::SupportsNotifications(void)
|
||||||
@ -1544,7 +1545,7 @@ bool ClusterListener::SupportsNotifications(void)
|
|||||||
if (!type)
|
if (!type)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !type->GetObjects().empty();
|
return !type->GetObjects().empty() && IcingaApplication::GetInstance()->GetEnableNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClusterListener::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
void ClusterListener::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||||
|
@ -616,15 +616,16 @@ void StatusDataWriter::StatusTimerHandler(void)
|
|||||||
<< "\t" << "icinga_pid=" << Utility::GetPid() << "\n"
|
<< "\t" << "icinga_pid=" << Utility::GetPid() << "\n"
|
||||||
<< "\t" << "daemon_mode=1" << "\n"
|
<< "\t" << "daemon_mode=1" << "\n"
|
||||||
<< "\t" << "program_start=" << static_cast<long>(IcingaApplication::GetInstance()->GetStartTime()) << "\n"
|
<< "\t" << "program_start=" << static_cast<long>(IcingaApplication::GetInstance()->GetStartTime()) << "\n"
|
||||||
<< "\t" << "active_service_checks_enabled=1" << "\n"
|
<< "\t" << "active_service_checks_enabled=" << (IcingaApplication::GetInstance()->GetEnableChecks() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "passive_service_checks_enabled=1" << "\n"
|
<< "\t" << "passive_service_checks_enabled=1" << "\n"
|
||||||
<< "\t" << "active_host_checks_enabled=1" << "\n"
|
<< "\t" << "active_host_checks_enabled=1" << "\n"
|
||||||
<< "\t" << "passive_host_checks_enabled=1" << "\n"
|
<< "\t" << "passive_host_checks_enabled=1" << "\n"
|
||||||
<< "\t" << "check_service_freshness=0" << "\n"
|
<< "\t" << "check_service_freshness=1" << "\n"
|
||||||
<< "\t" << "check_host_freshness=0" << "\n"
|
<< "\t" << "check_host_freshness=1" << "\n"
|
||||||
<< "\t" << "enable_notifications=1" << "\n"
|
<< "\t" << "enable_notifications=" << (IcingaApplication::GetInstance()->GetEnableNotifications() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "enable_flap_detection=1" << "\n"
|
<< "\t" << "enable_flap_detection=" << (IcingaApplication::GetInstance()->GetEnableFlapping() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "enable_failure_prediction=0" << "\n"
|
<< "\t" << "enable_failure_prediction=0" << "\n"
|
||||||
|
<< "\t" << "process_performance_data=" << (IcingaApplication::GetInstance()->GetEnablePerfdata() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "active_scheduled_service_check_stats=" << CIB::GetActiveChecksStatistics(60) << "," << CIB::GetActiveChecksStatistics(5 * 60) << "," << CIB::GetActiveChecksStatistics(15 * 60) << "\n"
|
<< "\t" << "active_scheduled_service_check_stats=" << CIB::GetActiveChecksStatistics(60) << "," << CIB::GetActiveChecksStatistics(5 * 60) << "," << CIB::GetActiveChecksStatistics(15 * 60) << "\n"
|
||||||
<< "\t" << "passive_service_check_stats=" << CIB::GetPassiveChecksStatistics(60) << "," << CIB::GetPassiveChecksStatistics(5 * 60) << "," << CIB::GetPassiveChecksStatistics(15 * 60) << "\n"
|
<< "\t" << "passive_service_check_stats=" << CIB::GetPassiveChecksStatistics(60) << "," << CIB::GetPassiveChecksStatistics(5 * 60) << "," << CIB::GetPassiveChecksStatistics(15 * 60) << "\n"
|
||||||
<< "\t" << "next_downtime_id=" << Service::GetNextDowntimeID() << "\n"
|
<< "\t" << "next_downtime_id=" << Service::GetNextDowntimeID() << "\n"
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "icinga/hostgroup.h"
|
#include "icinga/hostgroup.h"
|
||||||
#include "icinga/servicegroup.h"
|
#include "icinga/servicegroup.h"
|
||||||
#include "icinga/pluginchecktask.h"
|
#include "icinga/pluginchecktask.h"
|
||||||
|
#include "icinga/icingaapplication.h"
|
||||||
#include "base/convert.h"
|
#include "base/convert.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
@ -169,6 +170,16 @@ void ExternalCommandProcessor::Initialize(void)
|
|||||||
RegisterCommand("ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS", &ExternalCommandProcessor::EnableHostgroupPassiveHostChecks);
|
RegisterCommand("ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS", &ExternalCommandProcessor::EnableHostgroupPassiveHostChecks);
|
||||||
RegisterCommand("ENABLE_SERVICEGROUP_HOST_CHECKS", &ExternalCommandProcessor::EnableServicegroupHostChecks);
|
RegisterCommand("ENABLE_SERVICEGROUP_HOST_CHECKS", &ExternalCommandProcessor::EnableServicegroupHostChecks);
|
||||||
RegisterCommand("ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS", &ExternalCommandProcessor::EnableServicegroupPassiveHostChecks);
|
RegisterCommand("ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS", &ExternalCommandProcessor::EnableServicegroupPassiveHostChecks);
|
||||||
|
RegisterCommand("ENABLE_NOTIFICATIONS", &ExternalCommandProcessor::EnableNotifications);
|
||||||
|
RegisterCommand("DISABLE_NOTIFICATIONS", &ExternalCommandProcessor::DisableNotifications);
|
||||||
|
RegisterCommand("ENABLE_FLAP_DETECTION", &ExternalCommandProcessor::EnableFlapDetection);
|
||||||
|
RegisterCommand("DISABLE_FLAP_DETECTION", &ExternalCommandProcessor::DisableFlapDetection);
|
||||||
|
RegisterCommand("ENABLE_EVENT_HANDLERS", &ExternalCommandProcessor::EnableEventHandlers);
|
||||||
|
RegisterCommand("DISABLE_EVENT_HANDLERS", &ExternalCommandProcessor::DisableEventHandlers);
|
||||||
|
RegisterCommand("ENABLE_PERFORMANCE_DATA", &ExternalCommandProcessor::EnablePerformanceData);
|
||||||
|
RegisterCommand("DISABLE_PERFORMANCE_DATA", &ExternalCommandProcessor::DisablePerformanceData);
|
||||||
|
RegisterCommand("START_EXECUTING_SVC_CHECKS", &ExternalCommandProcessor::StartExecutingSvcChecks);
|
||||||
|
RegisterCommand("STOP_EXECUTING_SVC_CHECKS", &ExternalCommandProcessor::StopExecutingSvcChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalCommandProcessor::RegisterCommand(const String& command, const ExternalCommandProcessor::Callback& callback)
|
void ExternalCommandProcessor::RegisterCommand(const String& command, const ExternalCommandProcessor::Callback& callback)
|
||||||
@ -1734,3 +1745,73 @@ void ExternalCommandProcessor::DisableSvcFlapping(double, const std::vector<Stri
|
|||||||
service->SetEnableFlapping(false);
|
service->SetEnableFlapping(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::EnableNotifications(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally enabling notifications.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnableNotifications(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::DisableNotifications(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally disabling notifications.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnableNotifications(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::EnableFlapDetection(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally enabling flap detection.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnableFlapping(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::DisableFlapDetection(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally disabling flap detection.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnableFlapping(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::EnableEventHandlers(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally enabling event handlers.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnableEventHandlers(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::DisableEventHandlers(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally disabling event handlers.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnableEventHandlers(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::EnablePerformanceData(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally enabling performance data processing.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnablePerfdata(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::DisablePerformanceData(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally disabling performance data processing.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnablePerfdata(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::StartExecutingSvcChecks(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally enabling checks.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnableChecks(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalCommandProcessor::StopExecutingSvcChecks(double time, const std::vector<String>& arguments)
|
||||||
|
{
|
||||||
|
Log(LogInformation, "icinga", "Globally disabling checks.");
|
||||||
|
|
||||||
|
IcingaApplication::GetInstance()->SetEnableChecks(false);
|
||||||
|
}
|
||||||
|
@ -121,6 +121,16 @@ private:
|
|||||||
static void DisableSvcFlapping(double time, const std::vector<String>& arguments);
|
static void DisableSvcFlapping(double time, const std::vector<String>& arguments);
|
||||||
static void EnableHostFlapping(double time, const std::vector<String>& arguments);
|
static void EnableHostFlapping(double time, const std::vector<String>& arguments);
|
||||||
static void DisableHostFlapping(double time, const std::vector<String>& arguments);
|
static void DisableHostFlapping(double time, const std::vector<String>& arguments);
|
||||||
|
static void EnableNotifications(double time, const std::vector<String>& arguments);
|
||||||
|
static void DisableNotifications(double time, const std::vector<String>& arguments);
|
||||||
|
static void EnableFlapDetection(double time, const std::vector<String>& arguments);
|
||||||
|
static void DisableFlapDetection(double time, const std::vector<String>& arguments);
|
||||||
|
static void EnableEventHandlers(double time, const std::vector<String>& arguments);
|
||||||
|
static void DisableEventHandlers(double time, const std::vector<String>& arguments);
|
||||||
|
static void EnablePerformanceData(double time, const std::vector<String>& arguments);
|
||||||
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,15 @@ REGISTER_TYPE(IcingaApplication);
|
|||||||
# define ICINGA_VERSION GIT_MESSAGE
|
# define ICINGA_VERSION GIT_MESSAGE
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
IcingaApplication::IcingaApplication(void)
|
||||||
|
{
|
||||||
|
m_EnableNotifications = true;
|
||||||
|
m_EnableEventHandlers = true;
|
||||||
|
m_EnableFlapping = true;
|
||||||
|
m_EnableChecks = true;
|
||||||
|
m_EnablePerfdata = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The entry point for the Icinga application.
|
* The entry point for the Icinga application.
|
||||||
*
|
*
|
||||||
@ -127,3 +136,145 @@ bool IcingaApplication::ResolveMacro(const String& macro, const Dictionary::Ptr&
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IcingaApplication::GetEnableNotifications(void) const
|
||||||
|
{
|
||||||
|
if (!m_OverrideEnableNotifications.IsEmpty())
|
||||||
|
return m_OverrideEnableNotifications;
|
||||||
|
else if (!m_EnableNotifications.IsEmpty())
|
||||||
|
return m_EnableNotifications;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::SetEnableNotifications(bool enabled)
|
||||||
|
{
|
||||||
|
m_OverrideEnableNotifications = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::ClearEnableNotifications(void)
|
||||||
|
{
|
||||||
|
m_OverrideEnableNotifications = Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IcingaApplication::GetEnableEventHandlers(void) const
|
||||||
|
{
|
||||||
|
if (!m_OverrideEnableEventHandlers.IsEmpty())
|
||||||
|
return m_OverrideEnableEventHandlers;
|
||||||
|
else if (!m_EnableEventHandlers.IsEmpty())
|
||||||
|
return m_EnableEventHandlers;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::SetEnableEventHandlers(bool enabled)
|
||||||
|
{
|
||||||
|
m_OverrideEnableEventHandlers = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::ClearEnableEventHandlers(void)
|
||||||
|
{
|
||||||
|
m_OverrideEnableEventHandlers = Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IcingaApplication::GetEnableFlapping(void) const
|
||||||
|
{
|
||||||
|
if (!m_OverrideEnableFlapping.IsEmpty())
|
||||||
|
return m_OverrideEnableFlapping;
|
||||||
|
else if (!m_EnableFlapping.IsEmpty())
|
||||||
|
return m_EnableFlapping;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::SetEnableFlapping(bool enabled)
|
||||||
|
{
|
||||||
|
m_OverrideEnableFlapping = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::ClearEnableFlapping(void)
|
||||||
|
{
|
||||||
|
m_OverrideEnableFlapping = Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IcingaApplication::GetEnableChecks(void) const
|
||||||
|
{
|
||||||
|
if (!m_OverrideEnableChecks.IsEmpty())
|
||||||
|
return m_OverrideEnableChecks;
|
||||||
|
else if (!m_EnableChecks.IsEmpty())
|
||||||
|
return m_EnableChecks;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::SetEnableChecks(bool enabled)
|
||||||
|
{
|
||||||
|
m_OverrideEnableChecks = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::ClearEnableChecks(void)
|
||||||
|
{
|
||||||
|
m_OverrideEnableChecks = Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IcingaApplication::GetEnablePerfdata(void) const
|
||||||
|
{
|
||||||
|
if (!m_OverrideEnablePerfdata.IsEmpty())
|
||||||
|
return m_OverrideEnablePerfdata;
|
||||||
|
else if (!m_EnablePerfdata.IsEmpty())
|
||||||
|
return m_EnablePerfdata;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::SetEnablePerfdata(bool enabled)
|
||||||
|
{
|
||||||
|
m_OverrideEnablePerfdata = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::ClearEnablePerfdata(void)
|
||||||
|
{
|
||||||
|
m_OverrideEnablePerfdata = Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||||
|
{
|
||||||
|
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||||
|
|
||||||
|
if (attributeTypes & Attribute_Config) {
|
||||||
|
bag->Set("enable_notifications", m_EnableNotifications);
|
||||||
|
bag->Set("enable_event_handlers", m_EnableEventHandlers);
|
||||||
|
bag->Set("enable_flapping", m_EnableFlapping);
|
||||||
|
bag->Set("enable_checks", m_EnableChecks);
|
||||||
|
bag->Set("enable_perfdata", m_EnablePerfdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attributeTypes & Attribute_State) {
|
||||||
|
bag->Set("override_enable_notifications", m_OverrideEnableNotifications);
|
||||||
|
bag->Set("override_enable_event_handlers", m_OverrideEnableEventHandlers);
|
||||||
|
bag->Set("override_enable_flapping", m_OverrideEnableFlapping);
|
||||||
|
bag->Set("override_enable_checks", m_OverrideEnableChecks);
|
||||||
|
bag->Set("override_enable_perfdata", m_OverrideEnablePerfdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
|
||||||
|
{
|
||||||
|
DynamicObject::InternalDeserialize(bag, attributeTypes);
|
||||||
|
|
||||||
|
if (attributeTypes & Attribute_Config) {
|
||||||
|
m_EnableNotifications = bag->Get("enable_notifications");
|
||||||
|
m_EnableEventHandlers = bag->Get("enable_event_handlers");
|
||||||
|
m_EnableFlapping = bag->Get("enable_flapping");
|
||||||
|
m_EnableChecks = bag->Get("enable_checks");
|
||||||
|
m_EnablePerfdata = bag->Get("enable_perfdata");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attributeTypes & Attribute_State) {
|
||||||
|
m_OverrideEnableNotifications = bag->Get("override_enable_notifications");
|
||||||
|
m_OverrideEnableEventHandlers = bag->Get("override_enable_event_handlers");
|
||||||
|
m_OverrideEnableFlapping = bag->Get("override_enable_flapping");
|
||||||
|
m_OverrideEnableChecks = bag->Get("override_enable_checks");
|
||||||
|
m_OverrideEnablePerfdata = bag->Get("override_enable_perfdata");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -38,6 +38,8 @@ public:
|
|||||||
DECLARE_PTR_TYPEDEFS(IcingaApplication);
|
DECLARE_PTR_TYPEDEFS(IcingaApplication);
|
||||||
DECLARE_TYPENAME(IcingaApplication);
|
DECLARE_TYPENAME(IcingaApplication);
|
||||||
|
|
||||||
|
IcingaApplication(void);
|
||||||
|
|
||||||
int Main(void);
|
int Main(void);
|
||||||
|
|
||||||
static IcingaApplication::Ptr GetInstance(void);
|
static IcingaApplication::Ptr GetInstance(void);
|
||||||
@ -49,9 +51,45 @@ public:
|
|||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
|
bool GetEnableNotifications(void) const;
|
||||||
|
void SetEnableNotifications(bool enabled);
|
||||||
|
void ClearEnableNotifications(void);
|
||||||
|
|
||||||
|
bool GetEnableEventHandlers(void) const;
|
||||||
|
void SetEnableEventHandlers(bool enabled);
|
||||||
|
void ClearEnableEventHandlers(void);
|
||||||
|
|
||||||
|
bool GetEnableFlapping(void) const;
|
||||||
|
void SetEnableFlapping(bool enabled);
|
||||||
|
void ClearEnableFlapping(void);
|
||||||
|
|
||||||
|
bool GetEnableChecks(void) const;
|
||||||
|
void SetEnableChecks(bool enabled);
|
||||||
|
void ClearEnableChecks(void);
|
||||||
|
|
||||||
|
bool GetEnablePerfdata(void) const;
|
||||||
|
void SetEnablePerfdata(bool enabled);
|
||||||
|
void ClearEnablePerfdata(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||||
|
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_StartTime;
|
double m_StartTime;
|
||||||
|
|
||||||
|
Value m_EnableNotifications;
|
||||||
|
Value m_EnableEventHandlers;
|
||||||
|
Value m_EnableFlapping;
|
||||||
|
Value m_EnableChecks;
|
||||||
|
Value m_EnablePerfdata;
|
||||||
|
|
||||||
|
Value m_OverrideEnableNotifications;
|
||||||
|
Value m_OverrideEnableEventHandlers;
|
||||||
|
Value m_OverrideEnableFlapping;
|
||||||
|
Value m_OverrideEnableChecks;
|
||||||
|
Value m_OverrideEnablePerfdata;
|
||||||
|
|
||||||
void DumpProgramState(void);
|
void DumpProgramState(void);
|
||||||
|
|
||||||
virtual void OnShutdown(void);
|
virtual void OnShutdown(void);
|
||||||
|
@ -84,6 +84,9 @@ double PerfdataWriter::GetRotationInterval(void) const
|
|||||||
|
|
||||||
void PerfdataWriter::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr)
|
void PerfdataWriter::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr)
|
||||||
{
|
{
|
||||||
|
if (!IcingaApplication::GetInstance()->GetEnablePerfdata())
|
||||||
|
return;
|
||||||
|
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
if (!host)
|
if (!host)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "icinga/service.h"
|
#include "icinga/service.h"
|
||||||
#include "icinga/eventcommand.h"
|
#include "icinga/eventcommand.h"
|
||||||
|
#include "icinga/icingaapplication.h"
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
@ -31,6 +32,9 @@ EventCommand::Ptr Service::GetEventCommand(void) const
|
|||||||
|
|
||||||
void Service::ExecuteEventHandler(void)
|
void Service::ExecuteEventHandler(void)
|
||||||
{
|
{
|
||||||
|
if (!IcingaApplication::GetInstance()->GetEnableEventHandlers())
|
||||||
|
return;
|
||||||
|
|
||||||
EventCommand::Ptr ec = GetEventCommand();
|
EventCommand::Ptr ec = GetEventCommand();
|
||||||
|
|
||||||
if (!ec)
|
if (!ec)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "icinga/service.h"
|
#include "icinga/service.h"
|
||||||
|
#include "icinga/icingaapplication.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
||||||
@ -110,7 +111,7 @@ void Service::UpdateFlappingStatus(bool stateChange)
|
|||||||
|
|
||||||
bool Service::IsFlapping(void) const
|
bool Service::IsFlapping(void) const
|
||||||
{
|
{
|
||||||
if (!GetEnableFlapping())
|
if (!GetEnableFlapping() || !IcingaApplication::GetInstance()->GetEnableFlapping())
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return GetFlappingCurrent() > GetFlappingThreshold();
|
return GetFlappingCurrent() > GetFlappingThreshold();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "icinga/service.h"
|
#include "icinga/service.h"
|
||||||
|
#include "icinga/icingaapplication.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
||||||
@ -51,7 +52,7 @@ void Service::SendNotifications(NotificationType type, const Dictionary::Ptr& cr
|
|||||||
{
|
{
|
||||||
bool force = GetForceNextNotification();
|
bool force = GetForceNextNotification();
|
||||||
|
|
||||||
if (!GetEnableNotifications()) {
|
if (!IcingaApplication::GetInstance()->GetEnableNotifications() || !GetEnableNotifications()) {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
Log(LogInformation, "icinga", "Notifications are disabled for service '" + GetName() + "'.");
|
Log(LogInformation, "icinga", "Notifications are disabled for service '" + GetName() + "'.");
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user