Move CompatUtility::GetCheckableCheckType() into IDO/Livestatus features

It is just boolean mapping to numbers, each modules does that in a sort of different way.

DB IDO automatically transforms boolean to numbers.
Livestatus would return JSON which keeps true booleans, but requires a number (just a guess,
there is no spec for this message format).
This commit is contained in:
Michael Friedrich 2017-12-05 11:34:38 +01:00
parent 70af1a3545
commit 92c565d744
7 changed files with 5 additions and 11 deletions

View File

@ -1395,7 +1395,7 @@ void DbEvents::AddCheckableCheckHistory(const Checkable::Ptr& checkable, const C
query1.Category = DbCatCheck;
Dictionary::Ptr fields1 = new Dictionary();
fields1->Set("check_type", CompatUtility::GetCheckableCheckType(checkable));
fields1->Set("check_type", !checkable->GetEnableActiveChecks()); /* 0 .. active, 1 .. passive */
fields1->Set("current_check_attempt", checkable->GetCheckAttempt());
fields1->Set("max_check_attempts", checkable->GetMaxCheckAttempts());
fields1->Set("state_type", checkable->GetStateType());

View File

@ -141,7 +141,7 @@ Dictionary::Ptr HostDbObject::GetStatusFields() const
fields->Set("last_check", DbValue::FromTimestamp(cr->GetScheduleEnd()));
fields->Set("next_check", DbValue::FromTimestamp(host->GetNextCheck()));
fields->Set("check_type", CompatUtility::GetCheckableCheckType(host));
fields->Set("check_type", !host->GetEnableActiveChecks()); /* 0 .. active, 1 .. passive */
fields->Set("last_state_change", DbValue::FromTimestamp(host->GetLastStateChange()));
fields->Set("last_hard_state_change", DbValue::FromTimestamp(host->GetLastHardStateChange()));
fields->Set("last_hard_state", host->GetLastHardState());

View File

@ -128,7 +128,7 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields() const
fields->Set("last_check", DbValue::FromTimestamp(cr->GetScheduleEnd()));
fields->Set("next_check", DbValue::FromTimestamp(service->GetNextCheck()));
fields->Set("check_type", CompatUtility::GetCheckableCheckType(service));
fields->Set("check_type", !service->GetEnableActiveChecks()); /* 0 .. active, 1 .. passive */
fields->Set("last_state_change", DbValue::FromTimestamp(service->GetLastStateChange()));
fields->Set("last_hard_state_change", DbValue::FromTimestamp(service->GetLastHardStateChange()));
fields->Set("last_hard_state", service->GetLastHardState());

View File

@ -183,11 +183,6 @@ String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable)
return Empty;
}
int CompatUtility::GetCheckableCheckType(const Checkable::Ptr& checkable)
{
return (checkable->GetEnableActiveChecks() ? 0 : 1);
}
double CompatUtility::GetCheckableCheckInterval(const Checkable::Ptr& checkable)
{
return checkable->GetCheckInterval() / 60.0;

View File

@ -51,7 +51,6 @@ public:
/* service */
static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
static int GetCheckableCheckType(const Checkable::Ptr& checkable);
static double GetCheckableCheckInterval(const Checkable::Ptr& checkable);
static double GetCheckableRetryInterval(const Checkable::Ptr& checkable);
static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable);

View File

@ -522,7 +522,7 @@ Value HostsTable::CheckTypeAccessor(const Value& row)
if (!host)
return Empty;
return CompatUtility::GetCheckableCheckType(host);
return (host->GetEnableActiveChecks() ? 0 : 1); /* 0 .. active, 1 .. passive */
}
Value HostsTable::LastStateAccessor(const Value& row)

View File

@ -549,7 +549,7 @@ Value ServicesTable::CheckTypeAccessor(const Value& row)
if (!service)
return Empty;
return CompatUtility::GetCheckableCheckType(service);
return (service->GetEnableActiveChecks() ? 0 : 1); /* 0 .. active, 1 .. passive */
}
Value ServicesTable::AcknowledgedAccessor(const Value& row)