mirror of https://github.com/Icinga/icinga2.git
Implement statistics for passive service checks.
This commit is contained in:
parent
1bbd9d629e
commit
2e78899347
|
@ -322,7 +322,8 @@ void CompatComponent::StatusTimerHandler(void)
|
|||
<< "\t" << "check_host_freshness=0" << "\n"
|
||||
<< "\t" << "enable_flap_detection=1" << "\n"
|
||||
<< "\t" << "enable_failure_prediction=0" << "\n"
|
||||
<< "\t" << "active_scheduled_service_check_stats=" << CIB::GetTaskStatistics(60) << "," << CIB::GetTaskStatistics(5 * 60) << "," << CIB::GetTaskStatistics(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" << "}" << "\n"
|
||||
<< "\n";
|
||||
|
||||
|
|
|
@ -71,8 +71,23 @@ void ReplicationComponent::ServiceStateChangeRequestHandler(const RequestMessage
|
|||
//Service::OnCheckResultReceived(service, params);
|
||||
//service->ApplyCheckResult(cr);
|
||||
|
||||
time_t now = static_cast<time_t>(Utility::GetTime());
|
||||
CIB::UpdateTaskStatistics(now, 1);
|
||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||
if (cr) {
|
||||
Value active = cr->Get("active");
|
||||
|
||||
time_t ts;
|
||||
Value schedule_end = cr->Get("schedule_end");
|
||||
|
||||
if (!schedule_end.IsEmpty())
|
||||
schedule_end = static_cast<time_t>(schedule_end);
|
||||
else
|
||||
schedule_end = static_cast<time_t>(Utility::GetTime());
|
||||
|
||||
if (active.IsEmpty() || static_cast<long>(active))
|
||||
CIB::UpdateActiveChecksStatistics(ts, 1);
|
||||
else
|
||||
CIB::UpdatePassiveChecksStatistics(ts, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void ReplicationComponent::EndpointConnectedHandler(const Endpoint::Ptr& endpoint)
|
||||
|
|
|
@ -452,6 +452,12 @@ void DynamicObject::FinishTx(void)
|
|||
m_CurrentTx = 0;
|
||||
}
|
||||
|
||||
void DynamicObject::FlushTx(void)
|
||||
{
|
||||
FinishTx();
|
||||
BeginTx();
|
||||
}
|
||||
|
||||
void DynamicObject::OnAttributeChanged(const String&, const Value&)
|
||||
{ }
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ public:
|
|||
static double GetCurrentTx(void);
|
||||
static void BeginTx(void);
|
||||
static void FinishTx(void);
|
||||
static void FlushTx(void);
|
||||
|
||||
protected:
|
||||
virtual void OnAttributeChanged(const String& name, const Value& oldValue);
|
||||
|
|
|
@ -21,14 +21,25 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
RingBuffer CIB::m_TaskStatistics(15 * 60);
|
||||
RingBuffer CIB::m_ActiveChecksStatistics(15 * 60);
|
||||
RingBuffer CIB::m_PassiveChecksStatistics(15 * 60);
|
||||
|
||||
void CIB::UpdateTaskStatistics(long tv, int num)
|
||||
void CIB::UpdateActiveChecksStatistics(long tv, int num)
|
||||
{
|
||||
m_TaskStatistics.InsertValue(tv, num);
|
||||
m_ActiveChecksStatistics.InsertValue(tv, num);
|
||||
}
|
||||
|
||||
int CIB::GetTaskStatistics(long timespan)
|
||||
int CIB::GetActiveChecksStatistics(long timespan)
|
||||
{
|
||||
return m_TaskStatistics.GetValues(timespan);
|
||||
return m_ActiveChecksStatistics.GetValues(timespan);
|
||||
}
|
||||
|
||||
void CIB::UpdatePassiveChecksStatistics(long tv, int num)
|
||||
{
|
||||
m_PassiveChecksStatistics.InsertValue(tv, num);
|
||||
}
|
||||
|
||||
int CIB::GetPassiveChecksStatistics(long timespan)
|
||||
{
|
||||
return m_PassiveChecksStatistics.GetValues(timespan);
|
||||
}
|
||||
|
|
|
@ -32,11 +32,15 @@ namespace icinga
|
|||
class I2_ICINGA_API CIB
|
||||
{
|
||||
public:
|
||||
static void UpdateTaskStatistics(long tv, int num);
|
||||
static int GetTaskStatistics(long timespan);
|
||||
static void UpdateActiveChecksStatistics(long tv, int num);
|
||||
static int GetActiveChecksStatistics(long timespan);
|
||||
|
||||
static void UpdatePassiveChecksStatistics(long tv, int num);
|
||||
static int GetPassiveChecksStatistics(long timespan);
|
||||
|
||||
private:
|
||||
static RingBuffer m_TaskStatistics;
|
||||
static RingBuffer m_ActiveChecksStatistics;
|
||||
static RingBuffer m_PassiveChecksStatistics;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ void ExternalCommand::ProcessServiceCheckResult(double time, const vector<String
|
|||
result->Set("schedule_end", time);
|
||||
result->Set("execution_start", time);
|
||||
result->Set("execution_end", time);
|
||||
result->Set("active", 0);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Processing passive check result for service '" + arguments[1] + "'");
|
||||
service->ProcessCheckResult(result);
|
||||
|
|
|
@ -678,6 +678,9 @@ void Service::CheckCompletedHandler(const Dictionary::Ptr& scheduleInfo,
|
|||
if (!result->Contains("execution_end"))
|
||||
result->Set("execution_end", scheduleInfo->Get("execution_end"));
|
||||
|
||||
if (!result->Contains("active"))
|
||||
result->Set("active", 1);
|
||||
|
||||
ProcessCheckResult(result);
|
||||
}
|
||||
} catch (const exception& ex) {
|
||||
|
@ -699,6 +702,10 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr)
|
|||
{
|
||||
ApplyCheckResult(cr);
|
||||
|
||||
/* flush the current transaction so other instances see the service's
|
||||
* new state when they receive the ServiceStateChange message */
|
||||
DynamicObject::FlushTx();
|
||||
|
||||
RequestMessage rm;
|
||||
rm.SetMethod("checker::ServiceStateChange");
|
||||
|
||||
|
|
Loading…
Reference in New Issue