mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
parent
0e4c00805c
commit
6f92a62953
@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
#include "methods/icingachecktask.h"
|
#include "methods/icingachecktask.h"
|
||||||
#include "icinga/cib.h"
|
#include "icinga/cib.h"
|
||||||
|
#include "icinga/service.h"
|
||||||
#include "base/application.h"
|
#include "base/application.h"
|
||||||
#include "base/utility.h"
|
#include "base/utility.h"
|
||||||
#include "base/scriptfunction.h"
|
#include "base/scriptfunction.h"
|
||||||
|
#include "base/dynamictype.h"
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
@ -38,6 +40,26 @@ CheckResult::Ptr IcingaCheckTask::ScriptFunc(const Service::Ptr&)
|
|||||||
perfdata->Set("active_checks", CIB::GetActiveChecksStatistics(interval) / interval);
|
perfdata->Set("active_checks", CIB::GetActiveChecksStatistics(interval) / interval);
|
||||||
perfdata->Set("passive_checks", CIB::GetPassiveChecksStatistics(interval) / interval);
|
perfdata->Set("passive_checks", CIB::GetPassiveChecksStatistics(interval) / interval);
|
||||||
|
|
||||||
|
double min_latency = -1, max_latency = 0, sum_latency = 0;
|
||||||
|
int count_latency = 0;
|
||||||
|
|
||||||
|
BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
|
||||||
|
double latency = Service::CalculateLatency(service->GetLastCheckResult());
|
||||||
|
|
||||||
|
if (min_latency == -1 || latency < min_latency)
|
||||||
|
min_latency = latency;
|
||||||
|
|
||||||
|
if (latency > max_latency)
|
||||||
|
max_latency = latency;
|
||||||
|
|
||||||
|
sum_latency += latency;
|
||||||
|
count_latency++;
|
||||||
|
}
|
||||||
|
|
||||||
|
perfdata->Set("min_latency", min_latency);
|
||||||
|
perfdata->Set("max_latency", max_latency);
|
||||||
|
perfdata->Set("avg_latency", sum_latency / count_latency);
|
||||||
|
|
||||||
CheckResult::Ptr cr = make_shared<CheckResult>();
|
CheckResult::Ptr cr = make_shared<CheckResult>();
|
||||||
cr->SetOutput("Icinga 2 is running.");
|
cr->SetOutput("Icinga 2 is running.");
|
||||||
cr->SetPerformanceData(perfdata);
|
cr->SetPerformanceData(perfdata);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user