diff --git a/lib/compat/statusdatawriter.cpp b/lib/compat/statusdatawriter.cpp index 142fdd91e..24be99a68 100644 --- a/lib/compat/statusdatawriter.cpp +++ b/lib/compat/statusdatawriter.cpp @@ -282,7 +282,9 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host) if (eventcommand && host->GetEnableEventHandler()) fp << "\t" "event_handler" "\t" << CompatUtility::GetCommandName(eventcommand) << "\n"; - fp << "\t" "check_period" "\t" << CompatUtility::GetCheckableCheckPeriod(host) << "\n"; + TimePeriod::Ptr checkPeriod = host->GetCheckPeriod(); + if (checkPeriod) + fp << "\t" "check_period" "\t" << checkPeriod->GetName() << "\n"; fp << "\t" "contacts" "\t"; DumpNameList(fp, CompatUtility::GetCheckableNotificationUsers(host)); @@ -336,13 +338,16 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl fp << "\t" << "check_command=" << CompatUtility::GetCommandName(checkcommand) << "!" << CompatUtility::GetCheckableCommandArgs(checkable) << "\n" "\t" "event_handler=" << CompatUtility::GetCommandName(eventcommand) << "\n" - "\t" "check_period=" << CompatUtility::GetCheckableCheckPeriod(checkable) << "\n" "\t" "check_interval=" << CompatUtility::GetCheckableCheckInterval(checkable) << "\n" "\t" "retry_interval=" << CompatUtility::GetCheckableRetryInterval(checkable) << "\n" "\t" "has_been_checked=" << Convert::ToLong(checkable->HasBeenChecked()) << "\n" "\t" "should_be_scheduled=" << checkable->GetEnableActiveChecks() << "\n" "\t" "event_handler_enabled=" << Convert::ToLong(checkable->GetEnableEventHandler()) << "\n"; + TimePeriod::Ptr checkPeriod = checkable->GetCheckPeriod(); + if (checkPeriod) + fp << "\t" "check_period" "\t" << checkPeriod->GetName() << "\n"; + if (cr) { fp << "\t" << "check_execution_time=" << Convert::ToString(cr->CalculateExecutionTime()) << "\n" "\t" "check_latency=" << Convert::ToString(cr->CalculateLatency()) << "\n"; @@ -427,7 +432,6 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s "\t" "host_name" "\t" << host->GetName() << "\n" "\t" "service_description" "\t" << service->GetShortName() << "\n" "\t" "display_name" "\t" << service->GetDisplayName() << "\n" - "\t" "check_period" "\t" << CompatUtility::GetCheckableCheckPeriod(service) << "\n" "\t" "check_interval" "\t" << CompatUtility::GetCheckableCheckInterval(service) << "\n" "\t" "retry_interval" "\t" << CompatUtility::GetCheckableRetryInterval(service) << "\n" "\t" "max_check_attempts" "\t" << service->GetMaxCheckAttempts() << "\n" @@ -449,6 +453,10 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s if (eventcommand && service->GetEnableEventHandler()) fp << "\t" "event_handler" "\t" << CompatUtility::GetCommandName(eventcommand) << "\n"; + TimePeriod::Ptr checkPeriod = service->GetCheckPeriod(); + if (checkPeriod) + fp << "\t" "check_period" "\t" << checkPeriod->GetName() << "\n"; + fp << "\t" "contacts" "\t"; DumpNameList(fp, CompatUtility::GetCheckableNotificationUsers(service)); fp << "\n"; diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index ac87a1529..2b030b3fa 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -193,15 +193,6 @@ double CompatUtility::GetCheckableRetryInterval(const Checkable::Ptr& checkable) return checkable->GetRetryInterval() / 60.0; } -String CompatUtility::GetCheckableCheckPeriod(const Checkable::Ptr& checkable) -{ - TimePeriod::Ptr check_period = checkable->GetCheckPeriod(); - if (check_period) - return check_period->GetName(); - else - return "24x7"; -} - int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable) { if (CompatUtility::GetCheckableNotificationNotificationInterval(checkable) == 0 && !checkable->GetVolatile()) diff --git a/lib/icinga/compatutility.hpp b/lib/icinga/compatutility.hpp index ee2bf3f2e..8dac5d1e9 100644 --- a/lib/icinga/compatutility.hpp +++ b/lib/icinga/compatutility.hpp @@ -53,7 +53,6 @@ public: static String GetCheckableCommandArgs(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); static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable); static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable); diff --git a/lib/livestatus/hoststable.cpp b/lib/livestatus/hoststable.cpp index 2bc48ea0c..b5959b9bc 100644 --- a/lib/livestatus/hoststable.cpp +++ b/lib/livestatus/hoststable.cpp @@ -304,7 +304,12 @@ Value HostsTable::CheckPeriodAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckableCheckPeriod(host); + TimePeriod::Ptr checkPeriod = host->GetCheckPeriod(); + + if (!checkPeriod) + return Empty; + + return checkPeriod->GetName(); } Value HostsTable::NotesAccessor(const Value& row) diff --git a/lib/livestatus/servicestable.cpp b/lib/livestatus/servicestable.cpp index 00b11616c..1e9283bd8 100644 --- a/lib/livestatus/servicestable.cpp +++ b/lib/livestatus/servicestable.cpp @@ -356,7 +356,12 @@ Value ServicesTable::CheckPeriodAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableCheckPeriod(service); + TimePeriod::Ptr checkPeriod = service->GetCheckPeriod(); + + if (!checkPeriod) + return Empty; + + return checkPeriod->GetName(); } Value ServicesTable::NotesAccessor(const Value& row)