Remove more redundant wrappers from CompatUtility class

This commit is contained in:
Michael Friedrich 2017-12-05 19:51:34 +01:00
parent 5466197d29
commit db6ed405e4
7 changed files with 20 additions and 46 deletions

View File

@ -434,7 +434,7 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
"\t" "active_checks_enabled" "\t" << Convert::ToLong(service->GetEnableActiveChecks()) << "\n"
"\t" "passive_checks_enabled" "\t" << Convert::ToLong(service->GetEnablePassiveChecks()) << "\n"
"\t" "flap_detection_enabled" "\t" << Convert::ToLong(service->GetEnableFlapping()) << "\n"
"\t" "is_volatile" "\t" << CompatUtility::GetCheckableIsVolatile(service) << "\n"
"\t" "is_volatile" "\t" << Convert::ToLong(service->GetVolatile()) << "\n"
"\t" "notifications_enabled" "\t" << Convert::ToLong(service->GetEnableNotifications()) << "\n"
"\t" "notification_options" "\t" << CompatUtility::GetCheckableNotificationNotificationOptions(service) << "\n"
"\t" "notification_interval" "\t" << CompatUtility::GetCheckableNotificationNotificationInterval(service) << "\n"

View File

@ -89,8 +89,8 @@ Dictionary::Ptr HostDbObject::GetConfigFields() const
fields->Set("flap_detection_on_up", Empty);
fields->Set("flap_detection_on_down", Empty);
fields->Set("flap_detection_on_unreachable", Empty);
fields->Set("low_flap_threshold", CompatUtility::GetCheckableLowFlapThreshold(host));
fields->Set("high_flap_threshold", CompatUtility::GetCheckableHighFlapThreshold(host));
fields->Set("low_flap_threshold", host->GetFlappingThresholdLow());
fields->Set("high_flap_threshold", host->GetFlappingThresholdLow());
fields->Set("process_performance_data", host->GetEnablePerfdata());

View File

@ -77,14 +77,14 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields() const
fields->Set("stalk_on_warning", 0);
fields->Set("stalk_on_unknown", 0);
fields->Set("stalk_on_critical", 0);
fields->Set("is_volatile", CompatUtility::GetCheckableIsVolatile(service));
fields->Set("is_volatile", service->GetVolatile());
fields->Set("flap_detection_enabled", service->GetEnableFlapping());
fields->Set("flap_detection_on_ok", Empty);
fields->Set("flap_detection_on_warning", Empty);
fields->Set("flap_detection_on_unknown", Empty);
fields->Set("flap_detection_on_critical", Empty);
fields->Set("low_flap_threshold", CompatUtility::GetCheckableLowFlapThreshold(service));
fields->Set("high_flap_threshold", CompatUtility::GetCheckableHighFlapThreshold(service));
fields->Set("low_flap_threshold", service->GetFlappingThresholdLow());
fields->Set("high_flap_threshold", service->GetFlappingThresholdLow());
fields->Set("process_performance_data", service->GetEnablePerfdata());
fields->Set("freshness_checks_enabled", CompatUtility::GetCheckableFreshnessChecksEnabled(service));
fields->Set("freshness_threshold", CompatUtility::GetCheckableFreshnessThreshold(service));

View File

@ -202,21 +202,6 @@ String CompatUtility::GetCheckableCheckPeriod(const Checkable::Ptr& checkable)
return "24x7";
}
int CompatUtility::GetCheckableIsVolatile(const Checkable::Ptr& checkable)
{
return (checkable->GetVolatile() ? 1 : 0);
}
double CompatUtility::GetCheckableLowFlapThreshold(const Checkable::Ptr& checkable)
{
return checkable->GetFlappingThresholdLow();
}
double CompatUtility::GetCheckableHighFlapThreshold(const Checkable::Ptr& checkable)
{
return checkable->GetFlappingThresholdHigh();
}
int CompatUtility::GetCheckableFreshnessChecksEnabled(const Checkable::Ptr& checkable)
{
return (checkable->GetCheckInterval() > 0 ? 1 : 0);
@ -227,19 +212,6 @@ int CompatUtility::GetCheckableFreshnessThreshold(const Checkable::Ptr& checkabl
return static_cast<int>(checkable->GetCheckInterval());
}
double CompatUtility::GetCheckableStaleness(const Checkable::Ptr& checkable)
{
if (checkable->HasBeenChecked() && checkable->GetLastCheck() > 0)
return (Utility::GetTime() - checkable->GetLastCheck()) / (checkable->GetCheckInterval() * 3600);
return 0.0;
}
int CompatUtility::GetCheckableIsAcknowledged(const Checkable::Ptr& checkable)
{
return (checkable->IsAcknowledged() ? 1 : 0);
}
int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable)
{
if (CompatUtility::GetCheckableNotificationNotificationInterval(checkable) == 0 && !checkable->GetVolatile())

View File

@ -55,12 +55,8 @@ public:
static double GetCheckableRetryInterval(const Checkable::Ptr& checkable);
static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable);
static int GetCheckableIsVolatile(const Checkable::Ptr& checkable);
static double GetCheckableLowFlapThreshold(const Checkable::Ptr& checkable);
static double GetCheckableHighFlapThreshold(const Checkable::Ptr& checkable);
static int GetCheckableFreshnessChecksEnabled(const Checkable::Ptr& checkable);
static int GetCheckableFreshnessThreshold(const Checkable::Ptr& checkable);
static double GetCheckableStaleness(const Checkable::Ptr& checkable);
static int GetCheckableIsAcknowledged(const Checkable::Ptr& checkable);
static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable);
static int GetCheckableInCheckPeriod(const Checkable::Ptr& checkable);

View File

@ -663,7 +663,7 @@ Value HostsTable::AcknowledgedAccessor(const Value& row)
return Empty;
ObjectLock olock(host);
return CompatUtility::GetCheckableIsAcknowledged(host);
return host->IsAcknowledged();
}
Value HostsTable::StateAccessor(const Value& row)
@ -813,7 +813,7 @@ Value HostsTable::LowFlapThresholdAccessor(const Value& row)
if (!host)
return Empty;
return CompatUtility::GetCheckableLowFlapThreshold(host);
return host->GetFlappingThresholdLow();
}
Value HostsTable::HighFlapThresholdAccessor(const Value& row)
@ -823,7 +823,7 @@ Value HostsTable::HighFlapThresholdAccessor(const Value& row)
if (!host)
return Empty;
return CompatUtility::GetCheckableHighFlapThreshold(host);
return host->GetFlappingThresholdHigh();
}
Value HostsTable::LatencyAccessor(const Value& row)
@ -1394,7 +1394,10 @@ Value HostsTable::StalenessAccessor(const Value& row)
if (!host)
return Empty;
return CompatUtility::GetCheckableStaleness(host);
if (host->HasBeenChecked() && host->GetLastCheck() > 0)
return (Utility::GetTime() - host->GetLastCheck()) / (host->GetCheckInterval() * 3600);
return 0.0;
}
Value HostsTable::GroupsAccessor(const Value& row)

View File

@ -560,7 +560,7 @@ Value ServicesTable::AcknowledgedAccessor(const Value& row)
return Empty;
ObjectLock olock(service);
return CompatUtility::GetCheckableIsAcknowledged(service);
return service->IsAcknowledged();
}
Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
@ -801,7 +801,10 @@ Value ServicesTable::StalenessAccessor(const Value& row)
if (!service)
return Empty;
return CompatUtility::GetCheckableStaleness(service);
if (service->HasBeenChecked() && service->GetLastCheck() > 0)
return (Utility::GetTime() - service->GetLastCheck()) / (service->GetCheckInterval() * 3600);
return 0.0;
}
Value ServicesTable::CheckIntervalAccessor(const Value& row)
@ -841,7 +844,7 @@ Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
if (!service)
return Empty;
return CompatUtility::GetCheckableLowFlapThreshold(service);
return service->GetFlappingThresholdLow();
}
Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
@ -851,7 +854,7 @@ Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
if (!service)
return Empty;
return CompatUtility::GetCheckableHighFlapThreshold(service);
return service->GetFlappingThresholdHigh();
}
Value ServicesTable::LatencyAccessor(const Value& row)