From: Michael Friedrich Date: Tue, 5 Dec 2017 14:28:08 +0000 (+0100) Subject: Replace CompatUtility's enabled wrappers with native implementation getters X-Git-Tag: v2.9.0~222^2~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d1f772a6eadb394c659a5c8441bbd6eaffd72d5;p=icinga2 Replace CompatUtility's enabled wrappers with native implementation getters Many conversions were not necessary, or could be dealt inside the actual feature. libcompat and liblivestatus can take care about such specifics on their own, lib_db_ido doesn't need boolean conversion in fields, that is done inside the db driver. --- diff --git a/lib/compat/statusdatawriter.cpp b/lib/compat/statusdatawriter.cpp index eae647e41..6282cb9b1 100644 --- a/lib/compat/statusdatawriter.cpp +++ b/lib/compat/statusdatawriter.cpp @@ -266,12 +266,12 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host) fp << "\t" "check_interval" "\t" << CompatUtility::GetCheckableCheckInterval(host) << "\n" "\t" "retry_interval" "\t" << CompatUtility::GetCheckableRetryInterval(host) << "\n" "\t" "max_check_attempts" "\t" << host->GetMaxCheckAttempts() << "\n" - "\t" "active_checks_enabled" "\t" << CompatUtility::GetCheckableActiveChecksEnabled(host) << "\n" - "\t" "passive_checks_enabled" "\t" << CompatUtility::GetCheckablePassiveChecksEnabled(host) << "\n" - "\t" "notifications_enabled" "\t" << CompatUtility::GetCheckableNotificationsEnabled(host) << "\n" + "\t" "active_checks_enabled" "\t" << Convert::ToLong(host->GetEnableActiveChecks()) << "\n" + "\t" "passive_checks_enabled" "\t" << Convert::ToLong(host->GetEnablePassiveChecks()) << "\n" + "\t" "notifications_enabled" "\t" << Convert::ToLong(host->GetEnableNotifications()) << "\n" "\t" "notification_options" "\t" << CompatUtility::GetCheckableNotificationNotificationOptions(host) << "\n" "\t" "notification_interval" "\t" << CompatUtility::GetCheckableNotificationNotificationInterval(host) << "\n" - "\t" "event_handler_enabled" "\t" << CompatUtility::GetCheckableEventHandlerEnabled(host) << "\n"; + "\t" "event_handler_enabled" "\t" << Convert::ToLong(host->GetEnableEventHandler()) << "\n"; CheckCommand::Ptr checkcommand = host->GetCheckCommand(); if (checkcommand) @@ -294,7 +294,7 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host) fp << "\t" << "initial_state" "\t" "o" "\n" "\t" "low_flap_threshold" "\t" << host->GetFlappingThresholdLow() << "\n" "\t" "high_flap_threshold" "\t" << host->GetFlappingThresholdHigh() << "\n" - "\t" "process_perf_data" "\t" << CompatUtility::GetCheckableProcessPerformanceData(host) << "\n" + "\t" "process_perf_data" "\t" << Convert::ToLong(host->GetEnablePerfdata()) << "\n" "\t" "check_freshness" "\t" "1" "\n"; fp << "\t" "host_groups" "\t"; @@ -338,9 +338,9 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl "\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=" << (checkable->HasBeenChecked() ? 1 : 0) << "\n" + "\t" "has_been_checked=" << Convert::ToLong(checkable->HasBeenChecked()) << "\n" "\t" "should_be_scheduled=" << checkable->GetEnableActiveChecks() << "\n" - "\t" "event_handler_enabled=" << CompatUtility::GetCheckableEventHandlerEnabled(checkable) << "\n"; + "\t" "event_handler_enabled=" << Convert::ToLong(checkable->GetEnableEventHandler()) << "\n"; if (cr) { fp << "\t" << "check_execution_time=" << Convert::ToString(cr->CalculateExecutionTime()) << "\n" @@ -381,10 +381,10 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl "\t" "last_state_change=" << static_cast(checkable->GetLastStateChange()) << "\n" "\t" "last_hard_state_change=" << static_cast(checkable->GetLastHardStateChange()) << "\n" "\t" "last_update=" << static_cast(time(NULL)) << "\n" - "\t" "notifications_enabled=" << CompatUtility::GetCheckableNotificationsEnabled(checkable) << "\n" - "\t" "active_checks_enabled=" << CompatUtility::GetCheckableActiveChecksEnabled(checkable) << "\n" - "\t" "passive_checks_enabled=" << CompatUtility::GetCheckablePassiveChecksEnabled(checkable) << "\n" - "\t" "flap_detection_enabled=" << CompatUtility::GetCheckableFlapDetectionEnabled(checkable) << "\n" + "\t" "notifications_enabled" "\t" << Convert::ToLong(checkable->GetEnableNotifications()) << "\n" + "\t" "active_checks_enabled=" << Convert::ToLong(checkable->GetEnableActiveChecks()) << "\n" + "\t" "passive_checks_enabled=" << Convert::ToLong(checkable->GetEnablePassiveChecks()) << "\n" + "\t" "flap_detection_enabled=" << Convert::ToLong(checkable->GetEnableFlapping()) << "\n" "\t" "is_flapping=" << CompatUtility::GetCheckableIsFlapping(checkable) << "\n" "\t" "percent_state_change=" << CompatUtility::GetCheckablePercentStateChange(checkable) << "\n" "\t" "problem_has_been_acknowledged=" << (checkable->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n" @@ -431,15 +431,15 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s "\t" "check_interval" "\t" << CompatUtility::GetCheckableCheckInterval(service) << "\n" "\t" "retry_interval" "\t" << CompatUtility::GetCheckableRetryInterval(service) << "\n" "\t" "max_check_attempts" "\t" << service->GetMaxCheckAttempts() << "\n" - "\t" "active_checks_enabled" "\t" << CompatUtility::GetCheckableActiveChecksEnabled(service) << "\n" - "\t" "passive_checks_enabled" "\t" << CompatUtility::GetCheckablePassiveChecksEnabled(service) << "\n" - "\t" "flap_detection_enabled" "\t" << CompatUtility::GetCheckableFlapDetectionEnabled(service) << "\n" + "\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" "notifications_enabled" "\t" << CompatUtility::GetCheckableNotificationsEnabled(service) << "\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" "\t" "notification_period" "\t" << "" << "\n" - "\t" "event_handler_enabled" "\t" << CompatUtility::GetCheckableEventHandlerEnabled(service) << "\n"; + "\t" "event_handler_enabled" "\t" << Convert::ToLong(service->GetEnableEventHandler()) << "\n"; CheckCommand::Ptr checkcommand = service->GetCheckCommand(); if (checkcommand) @@ -466,8 +466,9 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s fp << "\t" "initial_state" "\t" "o" "\n" "\t" "low_flap_threshold" "\t" << service->GetFlappingThresholdLow() << "\n" "\t" "high_flap_threshold" "\t" << service->GetFlappingThresholdHigh() << "\n" - "\t" "process_perf_data" "\t" << CompatUtility::GetCheckableProcessPerformanceData(service) << "\n" + "\t" "process_perf_data" "\t" << Convert::ToLong(service->GetEnablePerfdata()) << "\n" "\t" "check_freshness" << "\t" "1" "\n"; + if (!notes.IsEmpty()) fp << "\t" "notes" "\t" << notes << "\n"; if (!notes_url.IsEmpty()) @@ -740,23 +741,23 @@ void StatusDataWriter::UpdateObjectsCache() /* Icinga 1.x only allows host->host, service->service dependencies */ if (!child_service && !parent_service) { objectfp << "define hostdependency {" "\n" - "\t" "dependent_host_name" "\t" << child_host->GetName() << "\n" - "\t" "host_name" "\t" << parent_host->GetName() << "\n" - "\t" "execution_failure_criteria" "\t" << criteria << "\n" - "\t" "notification_failure_criteria" "\t" << criteria << "\n" - "\t" "}" "\n" - "\n"; + "\t" "dependent_host_name" "\t" << child_host->GetName() << "\n" + "\t" "host_name" "\t" << parent_host->GetName() << "\n" + "\t" "execution_failure_criteria" "\t" << criteria << "\n" + "\t" "notification_failure_criteria" "\t" << criteria << "\n" + "\t" "}" "\n" + "\n"; } else if (child_service && parent_service){ objectfp << "define servicedependency {" "\n" - "\t" "dependent_host_name" "\t" << child_service->GetHost()->GetName() << "\n" - "\t" "dependent_service_description" "\t" << child_service->GetShortName() << "\n" - "\t" "host_name" "\t" << parent_service->GetHost()->GetName() << "\n" - "\t" "service_description" "\t" << parent_service->GetShortName() << "\n" - "\t" "execution_failure_criteria" "\t" << criteria << "\n" - "\t" "notification_failure_criteria" "\t" << criteria << "\n" - "\t" "}" "\n" - "\n"; + "\t" "dependent_host_name" "\t" << child_service->GetHost()->GetName() << "\n" + "\t" "dependent_service_description" "\t" << child_service->GetShortName() << "\n" + "\t" "host_name" "\t" << parent_service->GetHost()->GetName() << "\n" + "\t" "service_description" "\t" << parent_service->GetShortName() << "\n" + "\t" "execution_failure_criteria" "\t" << criteria << "\n" + "\t" "notification_failure_criteria" "\t" << criteria << "\n" + "\t" "}" "\n" + "\n"; } } @@ -798,32 +799,32 @@ void StatusDataWriter::StatusTimerHandler() "\n"; statusfp << "info {" "\n" - "\t" "created=" << Utility::GetTime() << "\n" - "\t" "version=" << Application::GetAppVersion() << "\n" - "\t" "}" "\n" - "\n"; + "\t" "created=" << Utility::GetTime() << "\n" + "\t" "version=" << Application::GetAppVersion() << "\n" + "\t" "}" "\n" + "\n"; statusfp << "programstatus {" "\n" - "\t" "icinga_pid=" << Utility::GetPid() << "\n" - "\t" "daemon_mode=1" "\n" - "\t" "program_start=" << static_cast(Application::GetStartTime()) << "\n" - "\t" "active_host_checks_enabled=" << (IcingaApplication::GetInstance()->GetEnableHostChecks() ? 1 : 0) << "\n" - "\t" "passive_host_checks_enabled=1" "\n" - "\t" "active_service_checks_enabled=" << (IcingaApplication::GetInstance()->GetEnableServiceChecks() ? 1 : 0) << "\n" - "\t" "passive_service_checks_enabled=1" "\n" - "\t" "check_service_freshness=1" "\n" - "\t" "check_host_freshness=1" "\n" - "\t" "enable_notifications=" << (IcingaApplication::GetInstance()->GetEnableNotifications() ? 1 : 0) << "\n" - "\t" "enable_event_handlers=" << (IcingaApplication::GetInstance()->GetEnableEventHandlers() ? 1 : 0) << "\n" - "\t" "enable_flap_detection=" << (IcingaApplication::GetInstance()->GetEnableFlapping() ? 1 : 0) << "\n" - "\t" "enable_failure_prediction=0" "\n" - "\t" "process_performance_data=" << (IcingaApplication::GetInstance()->GetEnablePerfdata() ? 1 : 0) << "\n" - "\t" "active_scheduled_host_check_stats=" << CIB::GetActiveHostChecksStatistics(60) << "," << CIB::GetActiveHostChecksStatistics(5 * 60) << "," << CIB::GetActiveHostChecksStatistics(15 * 60) << "\n" - "\t" "passive_host_check_stats=" << CIB::GetPassiveHostChecksStatistics(60) << "," << CIB::GetPassiveHostChecksStatistics(5 * 60) << "," << CIB::GetPassiveHostChecksStatistics(15 * 60) << "\n" - "\t" "active_scheduled_service_check_stats=" << CIB::GetActiveServiceChecksStatistics(60) << "," << CIB::GetActiveServiceChecksStatistics(5 * 60) << "," << CIB::GetActiveServiceChecksStatistics(15 * 60) << "\n" - "\t" "passive_service_check_stats=" << CIB::GetPassiveServiceChecksStatistics(60) << "," << CIB::GetPassiveServiceChecksStatistics(5 * 60) << "," << CIB::GetPassiveServiceChecksStatistics(15 * 60) << "\n" - "\t" "next_downtime_id=" << Downtime::GetNextDowntimeID() << "\n" - "\t" "next_comment_id=" << Comment::GetNextCommentID() << "\n"; + "\t" "icinga_pid=" << Utility::GetPid() << "\n" + "\t" "daemon_mode=1" "\n" + "\t" "program_start=" << static_cast(Application::GetStartTime()) << "\n" + "\t" "active_host_checks_enabled=" << Convert::ToLong(IcingaApplication::GetInstance()->GetEnableHostChecks()) << "\n" + "\t" "passive_host_checks_enabled=1" "\n" + "\t" "active_service_checks_enabled=" << Convert::ToLong(IcingaApplication::GetInstance()->GetEnableServiceChecks()) << "\n" + "\t" "passive_service_checks_enabled=1" "\n" + "\t" "check_service_freshness=1" "\n" + "\t" "check_host_freshness=1" "\n" + "\t" "enable_notifications=" << Convert::ToLong(IcingaApplication::GetInstance()->GetEnableNotifications()) << "\n" + "\t" "enable_event_handlers=" << Convert::ToLong(IcingaApplication::GetInstance()->GetEnableEventHandlers()) << "\n" + "\t" "enable_flap_detection=" << Convert::ToLong(IcingaApplication::GetInstance()->GetEnableFlapping()) << "\n" + "\t" "enable_failure_prediction=0" "\n" + "\t" "process_performance_data=" << Convert::ToLong(IcingaApplication::GetInstance()->GetEnablePerfdata()) << "\n" + "\t" "active_scheduled_host_check_stats=" << CIB::GetActiveHostChecksStatistics(60) << "," << CIB::GetActiveHostChecksStatistics(5 * 60) << "," << CIB::GetActiveHostChecksStatistics(15 * 60) << "\n" + "\t" "passive_host_check_stats=" << CIB::GetPassiveHostChecksStatistics(60) << "," << CIB::GetPassiveHostChecksStatistics(5 * 60) << "," << CIB::GetPassiveHostChecksStatistics(15 * 60) << "\n" + "\t" "active_scheduled_service_check_stats=" << CIB::GetActiveServiceChecksStatistics(60) << "," << CIB::GetActiveServiceChecksStatistics(5 * 60) << "," << CIB::GetActiveServiceChecksStatistics(15 * 60) << "\n" + "\t" "passive_service_check_stats=" << CIB::GetPassiveServiceChecksStatistics(60) << "," << CIB::GetPassiveServiceChecksStatistics(5 * 60) << "," << CIB::GetPassiveServiceChecksStatistics(15 * 60) << "\n" + "\t" "next_downtime_id=" << Downtime::GetNextDowntimeID() << "\n" + "\t" "next_comment_id=" << Comment::GetNextCommentID() << "\n"; statusfp << "\t" "}" "\n" "\n"; diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index 7749b275a..54d3da6d0 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -85,25 +85,25 @@ Dictionary::Ptr HostDbObject::GetConfigFields() const fields->Set("stalk_on_down", Empty); fields->Set("stalk_on_unreachable", Empty); - fields->Set("flap_detection_enabled", CompatUtility::GetCheckableFlapDetectionEnabled(host)); + fields->Set("flap_detection_enabled", host->GetEnableFlapping()); 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("process_performance_data", CompatUtility::GetCheckableProcessPerformanceData(host)); + fields->Set("process_performance_data", host->GetEnablePerfdata()); fields->Set("freshness_checks_enabled", CompatUtility::GetCheckableFreshnessChecksEnabled(host)); fields->Set("freshness_threshold", CompatUtility::GetCheckableFreshnessThreshold(host)); - fields->Set("passive_checks_enabled", CompatUtility::GetCheckablePassiveChecksEnabled(host)); - fields->Set("event_handler_enabled", CompatUtility::GetCheckableEventHandlerEnabled(host)); - fields->Set("active_checks_enabled", CompatUtility::GetCheckableActiveChecksEnabled(host)); + fields->Set("event_handler_enabled", host->GetEnableEventHandler()); + fields->Set("passive_checks_enabled", host->GetEnablePassiveChecks()); + fields->Set("active_checks_enabled", host->GetEnableActiveChecks()); fields->Set("retain_status_information", 1); fields->Set("retain_nonstatus_information", 1); - fields->Set("notifications_enabled", CompatUtility::GetCheckableNotificationsEnabled(host)); + fields->Set("notifications_enabled", host->GetEnableNotifications()); fields->Set("obsess_over_host", 0); fields->Set("failure_prediction_enabled", 0); @@ -152,14 +152,14 @@ Dictionary::Ptr HostDbObject::GetStatusFields() const fields->Set("last_notification", DbValue::FromTimestamp(CompatUtility::GetCheckableNotificationLastNotification(host))); fields->Set("next_notification", DbValue::FromTimestamp(CompatUtility::GetCheckableNotificationNextNotification(host))); fields->Set("no_more_notifications", Empty); - fields->Set("notifications_enabled", CompatUtility::GetCheckableNotificationsEnabled(host)); + fields->Set("notifications_enabled", host->GetEnableNotifications()); fields->Set("problem_has_been_acknowledged", host->GetAcknowledgement() != AcknowledgementNone); fields->Set("acknowledgement_type", host->GetAcknowledgement()); fields->Set("current_notification_number", CompatUtility::GetCheckableNotificationNotificationNumber(host)); - fields->Set("passive_checks_enabled", CompatUtility::GetCheckablePassiveChecksEnabled(host)); - fields->Set("active_checks_enabled", CompatUtility::GetCheckableActiveChecksEnabled(host)); - fields->Set("event_handler_enabled", CompatUtility::GetCheckableEventHandlerEnabled(host)); - fields->Set("flap_detection_enabled", CompatUtility::GetCheckableFlapDetectionEnabled(host)); + fields->Set("passive_checks_enabled", host->GetEnablePassiveChecks()); + fields->Set("active_checks_enabled", host->GetEnableActiveChecks()); + fields->Set("event_handler_enabled", host->GetEnableEventHandler()); + fields->Set("flap_detection_enabled", host->GetEnableFlapping()); fields->Set("is_flapping", CompatUtility::GetCheckableIsFlapping(host)); fields->Set("percent_state_change", CompatUtility::GetCheckablePercentStateChange(host)); @@ -170,7 +170,7 @@ Dictionary::Ptr HostDbObject::GetStatusFields() const fields->Set("scheduled_downtime_depth", host->GetDowntimeDepth()); fields->Set("failure_prediction_enabled", Empty); - fields->Set("process_performance_data", CompatUtility::GetCheckableProcessPerformanceData(host)); + fields->Set("process_performance_data", host->GetEnablePerfdata()); fields->Set("obsess_over_host", Empty); fields->Set("event_handler", CompatUtility::GetCheckableEventHandler(host)); fields->Set("check_command", CompatUtility::GetCheckableCheckCommand(host)); diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index eff6b71a8..fc2f4d041 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -78,22 +78,22 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields() const fields->Set("stalk_on_unknown", 0); fields->Set("stalk_on_critical", 0); fields->Set("is_volatile", CompatUtility::GetCheckableIsVolatile(service)); - fields->Set("flap_detection_enabled", CompatUtility::GetCheckableFlapDetectionEnabled(service)); + 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("process_performance_data", CompatUtility::GetCheckableProcessPerformanceData(service)); + fields->Set("process_performance_data", service->GetEnablePerfdata()); fields->Set("freshness_checks_enabled", CompatUtility::GetCheckableFreshnessChecksEnabled(service)); fields->Set("freshness_threshold", CompatUtility::GetCheckableFreshnessThreshold(service)); - fields->Set("passive_checks_enabled", CompatUtility::GetCheckablePassiveChecksEnabled(service)); - fields->Set("event_handler_enabled", CompatUtility::GetCheckableEventHandlerEnabled(service)); - fields->Set("active_checks_enabled", CompatUtility::GetCheckableActiveChecksEnabled(service)); + fields->Set("event_handler_enabled", service->GetEnableEventHandler()); + fields->Set("passive_checks_enabled", service->GetEnablePassiveChecks()); + fields->Set("active_checks_enabled", service->GetEnableActiveChecks()); fields->Set("retain_status_information", Empty); fields->Set("retain_nonstatus_information", Empty); - fields->Set("notifications_enabled", CompatUtility::GetCheckableNotificationsEnabled(service)); + fields->Set("notifications_enabled", service->GetEnableNotifications()); fields->Set("obsess_over_service", Empty); fields->Set("failure_prediction_enabled", Empty); fields->Set("notes", service->GetNotes()); @@ -140,14 +140,14 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields() const fields->Set("last_notification", DbValue::FromTimestamp(CompatUtility::GetCheckableNotificationLastNotification(service))); fields->Set("next_notification", DbValue::FromTimestamp(CompatUtility::GetCheckableNotificationNextNotification(service))); fields->Set("no_more_notifications", Empty); - fields->Set("notifications_enabled", CompatUtility::GetCheckableNotificationsEnabled(service)); + fields->Set("notifications_enabled", service->GetEnableNotifications()); fields->Set("problem_has_been_acknowledged", service->GetAcknowledgement() != AcknowledgementNone); fields->Set("acknowledgement_type", service->GetAcknowledgement()); fields->Set("current_notification_number", CompatUtility::GetCheckableNotificationNotificationNumber(service)); - fields->Set("passive_checks_enabled", CompatUtility::GetCheckablePassiveChecksEnabled(service)); - fields->Set("active_checks_enabled", CompatUtility::GetCheckableActiveChecksEnabled(service)); - fields->Set("event_handler_enabled", CompatUtility::GetCheckableEventHandlerEnabled(service)); - fields->Set("flap_detection_enabled", CompatUtility::GetCheckableFlapDetectionEnabled(service)); + fields->Set("passive_checks_enabled", service->GetEnablePassiveChecks()); + fields->Set("active_checks_enabled", service->GetEnableActiveChecks()); + fields->Set("event_handler_enabled", service->GetEnableEventHandler()); + fields->Set("flap_detection_enabled", service->GetEnableFlapping()); fields->Set("is_flapping", CompatUtility::GetCheckableIsFlapping(service)); fields->Set("percent_state_change", CompatUtility::GetCheckablePercentStateChange(service)); @@ -157,7 +157,7 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields() const } fields->Set("scheduled_downtime_depth", service->GetDowntimeDepth()); - fields->Set("process_performance_data", CompatUtility::GetCheckableProcessPerformanceData(service)); + fields->Set("process_performance_data", service->GetEnablePerfdata()); fields->Set("event_handler", CompatUtility::GetCheckableEventHandler(service)); fields->Set("check_command", CompatUtility::GetCheckableCheckCommand(service)); fields->Set("normal_check_interval", CompatUtility::GetCheckableCheckInterval(service)); diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index 3b5d8c756..7b8d937ee 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -202,26 +202,6 @@ String CompatUtility::GetCheckableCheckPeriod(const Checkable::Ptr& checkable) return "24x7"; } -int CompatUtility::GetCheckablePassiveChecksEnabled(const Checkable::Ptr& checkable) -{ - return (checkable->GetEnablePassiveChecks() ? 1 : 0); -} - -int CompatUtility::GetCheckableActiveChecksEnabled(const Checkable::Ptr& checkable) -{ - return (checkable->GetEnableActiveChecks() ? 1 : 0); -} - -int CompatUtility::GetCheckableEventHandlerEnabled(const Checkable::Ptr& checkable) -{ - return (checkable->GetEnableEventHandler() ? 1 : 0); -} - -int CompatUtility::GetCheckableFlapDetectionEnabled(const Checkable::Ptr& checkable) -{ - return (checkable->GetEnableFlapping() ? 1 : 0); -} - int CompatUtility::GetCheckableIsFlapping(const Checkable::Ptr& checkable) { return (checkable->IsFlapping() ? 1 : 0); @@ -237,11 +217,6 @@ double CompatUtility::GetCheckablePercentStateChange(const Checkable::Ptr& check return checkable->GetFlappingCurrent(); } -int CompatUtility::GetCheckableProcessPerformanceData(const Checkable::Ptr& checkable) -{ - return (checkable->GetEnablePerfdata() ? 1 : 0); -} - String CompatUtility::GetCheckableEventHandler(const Checkable::Ptr& checkable) { String event_command_str; @@ -355,11 +330,6 @@ String CompatUtility::GetCustomAttributeConfig(const CustomVarObject::Ptr& objec } /* notifications */ -int CompatUtility::GetCheckableNotificationsEnabled(const Checkable::Ptr& checkable) -{ - return (checkable->GetEnableNotifications() ? 1 : 0); -} - int CompatUtility::GetCheckableNotificationLastNotification(const Checkable::Ptr& checkable) { double last_notification = 0.0; diff --git a/lib/icinga/compatutility.hpp b/lib/icinga/compatutility.hpp index e5a9a89e1..5e6b176ec 100644 --- a/lib/icinga/compatutility.hpp +++ b/lib/icinga/compatutility.hpp @@ -54,14 +54,9 @@ public: static double GetCheckableCheckInterval(const Checkable::Ptr& checkable); static double GetCheckableRetryInterval(const Checkable::Ptr& checkable); static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable); - static int GetCheckablePassiveChecksEnabled(const Checkable::Ptr& checkable); - static int GetCheckableActiveChecksEnabled(const Checkable::Ptr& checkable); - static int GetCheckableEventHandlerEnabled(const Checkable::Ptr& checkable); - static int GetCheckableFlapDetectionEnabled(const Checkable::Ptr& checkable); static int GetCheckableIsFlapping(const Checkable::Ptr& checkable); static int GetCheckableIsReachable(const Checkable::Ptr& checkable); static double GetCheckablePercentStateChange(const Checkable::Ptr& checkable); - static int GetCheckableProcessPerformanceData(const Checkable::Ptr& checkable); static String GetCheckableEventHandler(const Checkable::Ptr& checkable); static String GetCheckableCheckCommand(const Checkable::Ptr& checkable); diff --git a/lib/livestatus/hoststable.cpp b/lib/livestatus/hoststable.cpp index 49dd9fac6..61e38108f 100644 --- a/lib/livestatus/hoststable.cpp +++ b/lib/livestatus/hoststable.cpp @@ -76,7 +76,7 @@ void HostsTable::AddColumns(Table *table, const String& prefix, table->AddColumn(prefix + "max_check_attempts", Column(&HostsTable::MaxCheckAttemptsAccessor, objectAccessor)); table->AddColumn(prefix + "flap_detection_enabled", Column(&HostsTable::FlapDetectionEnabledAccessor, objectAccessor)); table->AddColumn(prefix + "check_freshness", Column(&Table::OneAccessor, objectAccessor)); - table->AddColumn(prefix + "process_performance_data", Column(&Table::ZeroAccessor, objectAccessor)); + table->AddColumn(prefix + "process_performance_data", Column(&HostsTable::ProcessPerformanceDataAccessor, objectAccessor)); table->AddColumn(prefix + "accept_passive_checks", Column(&HostsTable::AcceptPassiveChecksAccessor, objectAccessor)); table->AddColumn(prefix + "event_handler_enabled", Column(&HostsTable::EventHandlerEnabledAccessor, objectAccessor)); table->AddColumn(prefix + "acknowledgement_type", Column(&HostsTable::AcknowledgementTypeAccessor, objectAccessor)); @@ -481,7 +481,7 @@ Value HostsTable::FlapDetectionEnabledAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckableFlapDetectionEnabled(host); + return Convert::ToLong(host->GetEnableFlapping()); } Value HostsTable::AcceptPassiveChecksAccessor(const Value& row) @@ -491,7 +491,7 @@ Value HostsTable::AcceptPassiveChecksAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckablePassiveChecksEnabled(host); + return Convert::ToLong(host->GetEnablePassiveChecks()); } Value HostsTable::EventHandlerEnabledAccessor(const Value& row) @@ -501,7 +501,7 @@ Value HostsTable::EventHandlerEnabledAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckableEventHandlerEnabled(host); + return Convert::ToLong(host->GetEnableEventHandler()); } Value HostsTable::AcknowledgementTypeAccessor(const Value& row) @@ -632,7 +632,7 @@ Value HostsTable::ChecksEnabledAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckableActiveChecksEnabled(host); + return Convert::ToLong(host->GetEnableActiveChecks()); } Value HostsTable::NotificationsEnabledAccessor(const Value& row) @@ -642,7 +642,17 @@ Value HostsTable::NotificationsEnabledAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckableNotificationsEnabled(host); + return Convert::ToLong(host->GetEnableNotifications()); +} + +Value HostsTable::ProcessPerformanceDataAccessor(const Value& row) +{ + Host::Ptr host = static_cast(row); + + if (!host) + return Empty; + + return Convert::ToLong(host->GetEnablePerfdata()); } Value HostsTable::AcknowledgedAccessor(const Value& row) @@ -763,7 +773,7 @@ Value HostsTable::ActiveChecksEnabledAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckableActiveChecksEnabled(host); + return Convert::ToLong(host->GetEnableActiveChecks()); } Value HostsTable::CheckOptionsAccessor(const Value&) diff --git a/lib/livestatus/servicestable.cpp b/lib/livestatus/servicestable.cpp index 072535ca9..e3aa936f5 100644 --- a/lib/livestatus/servicestable.cpp +++ b/lib/livestatus/servicestable.cpp @@ -721,7 +721,7 @@ Value ServicesTable::ChecksEnabledAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableActiveChecksEnabled(service); + return Convert::ToLong(service->GetEnableActiveChecks()); } Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row) @@ -731,7 +731,7 @@ Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckablePassiveChecksEnabled(service); + return Convert::ToLong(service->GetEnablePassiveChecks()); } Value ServicesTable::EventHandlerEnabledAccessor(const Value& row) @@ -741,7 +741,7 @@ Value ServicesTable::EventHandlerEnabledAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableEventHandlerEnabled(service); + return Convert::ToLong(service->GetEnableEventHandler()); } Value ServicesTable::NotificationsEnabledAccessor(const Value& row) @@ -751,7 +751,7 @@ Value ServicesTable::NotificationsEnabledAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableNotificationsEnabled(service); + return Convert::ToLong(service->GetEnableNotifications()); } Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row) @@ -761,7 +761,7 @@ Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableProcessPerformanceData(service); + return Convert::ToLong(service->GetEnablePerfdata()); } Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row) @@ -771,7 +771,7 @@ Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableActiveChecksEnabled(service); + return Convert::ToLong(service->GetEnableActiveChecks()); } Value ServicesTable::CheckOptionsAccessor(const Value& row) @@ -787,7 +787,7 @@ Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableFlapDetectionEnabled(service); + return Convert::ToLong(service->GetEnableFlapping()); } Value ServicesTable::CheckFreshnessAccessor(const Value& row)