<< "\t" << "check_service_freshness=0" << "\n"
<< "\t" << "check_host_freshness=0" << "\n"
<< "\t" << "enable_notifications=1" << "\n"
- << "\t" << "enable_flap_detection=0" << "\n"
+ << "\t" << "enable_flap_detection=1" << "\n"
<< "\t" << "enable_failure_prediction=0" << "\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"
}
}
}
+
+void ExternalCommandProcessor::EnableHostFlapping(double, const std::vector<String>& arguments)
+{
+ if (arguments.size() < 1)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 argument."));
+
+ Host::Ptr host = Host::GetByName(arguments[0]);
+
+ Log(LogInformation, "icinga", "Enabling flapping detection for host '" + arguments[0] + "'");
+ Service::Ptr hc = host->GetHostCheckService();
+
+ if (!hc)
+ return;
+
+ {
+ ObjectLock olock(hc);
+
+ hc->SetEnableFlapping(true);
+ }
+}
+
+void ExternalCommandProcessor::DisableHostFlapping(double, const std::vector<String>& arguments)
+{
+ if (arguments.size() < 1)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 1 argument."));
+
+ Host::Ptr host = Host::GetByName(arguments[0]);
+
+ Log(LogInformation, "icinga", "Disabling flapping detection for host '" + arguments[0] + "'");
+ Service::Ptr hc = host->GetHostCheckService();
+
+ if (!hc)
+ return;
+
+ {
+ ObjectLock olock(hc);
+
+ hc->SetEnableFlapping(false);
+ }
+}
+
+void ExternalCommandProcessor::EnableSvcFlapping(double, const std::vector<String>& arguments)
+{
+ if (arguments.size() < 2)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 2 arguments."));
+
+ Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+
+ Log(LogInformation, "icinga", "Enabling flapping detection for service '" + arguments[1] + "'");
+
+ {
+ ObjectLock olock(service);
+
+ service->SetEnableFlapping(true);
+ }
+}
+
+void ExternalCommandProcessor::DisableSvcFlapping(double, const std::vector<String>& arguments)
+{
+ if (arguments.size() < 2)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 2 arguments."));
+
+ Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+
+ Log(LogInformation, "icinga", "Disabling flapping detection for service '" + arguments[1] + "'");
+
+ {
+ ObjectLock olock(service);
+
+ service->SetEnableFlapping(false);
+ }
+}
\ No newline at end of file
static void EnableHostgroupPassiveHostChecks(double, const std::vector<String>& arguments);
static void EnableServicegroupHostChecks(double, const std::vector<String>& arguments);
static void EnableServicegroupPassiveHostChecks(double, const std::vector<String>& arguments);
+ static void EnableSvcFlapping(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 DisableHostFlapping(double time, const std::vector<String>& arguments);
};
}
#define FLAPPING_INTERVAL (30 * 60)
+bool Service::GetEnableFlapping(void) const
+{
+ if (m_EnableFlapping.IsEmpty())
+ return true;
+ else
+ return m_EnableFlapping;
+
+}
+
+void Service::SetEnableFlapping(bool enabled)
+{
+ m_EnableFlapping = enabled ? 1 : 0;
+ Touch("enable_flapping");
+}
+
void Service::UpdateFlappingStatus(bool stateChange)
{
double ts, now;
RegisterAttribute("flapping_counter", Attribute_Replicated, &m_FlappingCounter);
RegisterAttribute("flapping_lastchange", Attribute_Replicated, &m_FlappingLastChange);
RegisterAttribute("flapping_threshold", Attribute_Config, &m_FlappingThreshold);
+ RegisterAttribute("enable_flapping", Attribute_Config, &m_EnableFlapping);
SetSchedulingOffset(rand());
}
shared_ptr<EventCommand> GetEventCommand(void) const;
/* Flapping Detection */
+ bool GetEnableFlapping(void) const;
+ void SetEnableFlapping(bool enabled);
+
bool IsFlapping(void) const;
void UpdateFlappingStatus(bool stateChange);
Attribute<String> m_EventCommand;
/* Flapping */
+ Attribute<bool> m_EnableFlapping;
Attribute<long> m_FlappingCounter;
Attribute<double> m_FlappingLastChange;
Attribute<double> m_FlappingThreshold;