mirror of https://github.com/Icinga/icinga2.git
Merge pull request #5903 from Icinga/fix/cleanup-compatutility
Cleanup CompatUtility class and features
This commit is contained in:
commit
1d0fd5be11
|
@ -142,7 +142,7 @@ void CompatLogger::CheckResultHandler(const Checkable::Ptr& checkable, const Che
|
|||
|
||||
msgbuf << "HOST ALERT: "
|
||||
<< host->GetName() << ";"
|
||||
<< CompatUtility::GetHostStateString(host) << ";"
|
||||
<< GetHostStateString(host) << ";"
|
||||
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
||||
<< attempt_after << ";"
|
||||
<< output << ""
|
||||
|
@ -258,7 +258,7 @@ void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification
|
|||
if (service)
|
||||
notification_type_str = Service::StateToString(service->GetState());
|
||||
else
|
||||
notification_type_str = CompatUtility::GetHostStateString(host);
|
||||
notification_type_str = GetHostStateString(host);
|
||||
}
|
||||
|
||||
String author_comment = "";
|
||||
|
@ -290,7 +290,7 @@ void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification
|
|||
<< user->GetName() << ";"
|
||||
<< host->GetName() << ";"
|
||||
<< notification_type_str << " "
|
||||
<< "(" << CompatUtility::GetHostStateString(host) << ");"
|
||||
<< "(" << GetHostStateString(host) << ");"
|
||||
<< command_name << ";"
|
||||
<< output << ";"
|
||||
<< author_comment
|
||||
|
@ -422,7 +422,7 @@ void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
|||
} else {
|
||||
msgbuf << "HOST EVENT HANDLER: "
|
||||
<< host->GetName() << ";"
|
||||
<< CompatUtility::GetHostStateString(host) << ";"
|
||||
<< GetHostStateString(host) << ";"
|
||||
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
||||
<< current_attempt << ";"
|
||||
<< event_command_name;
|
||||
|
@ -435,6 +435,14 @@ void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
|||
}
|
||||
}
|
||||
|
||||
String CompatLogger::GetHostStateString(const Host::Ptr& host)
|
||||
{
|
||||
if (host->GetState() != HostUp && !host->IsReachable())
|
||||
return "UNREACHABLE"; /* hardcoded compat state */
|
||||
|
||||
return Host::StateToString(host->GetState());
|
||||
}
|
||||
|
||||
void CompatLogger::WriteLine(const String& line)
|
||||
{
|
||||
ASSERT(OwnsLock());
|
||||
|
@ -499,7 +507,7 @@ void CompatLogger::ReopenFile(bool rotate)
|
|||
std::ostringstream msgbuf;
|
||||
msgbuf << "CURRENT HOST STATE: "
|
||||
<< host->GetName() << ";"
|
||||
<< CompatUtility::GetHostStateString(host) << ";"
|
||||
<< GetHostStateString(host) << ";"
|
||||
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
||||
<< host->GetCheckAttempt() << ";"
|
||||
<< output << "";
|
||||
|
|
|
@ -62,6 +62,8 @@ private:
|
|||
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
|
||||
void EventCommandHandler(const Checkable::Ptr& service);
|
||||
|
||||
static String GetHostStateString(const Host::Ptr& host);
|
||||
|
||||
Timer::Ptr m_RotationTimer;
|
||||
void RotationTimerHandler();
|
||||
void ScheduleNextRotation();
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "icinga/timeperiod.hpp"
|
||||
#include "icinga/notificationcommand.hpp"
|
||||
#include "icinga/compatutility.hpp"
|
||||
#include "icinga/pluginutility.hpp"
|
||||
#include "icinga/dependency.hpp"
|
||||
#include "base/configtype.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
|
@ -263,15 +264,15 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
|||
|
||||
ObjectLock olock(host);
|
||||
|
||||
fp << "\t" "check_interval" "\t" << CompatUtility::GetCheckableCheckInterval(host) << "\n"
|
||||
"\t" "retry_interval" "\t" << CompatUtility::GetCheckableRetryInterval(host) << "\n"
|
||||
fp << "\t" "check_interval" "\t" << (host->GetCheckInterval() / 60.0) << "\n"
|
||||
"\t" "retry_interval" "\t" << (host->GetRetryInterval() / 60.0) << "\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" "notification_options" "\t" << CompatUtility::GetCheckableNotificationNotificationOptions(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" << GetNotificationOptions(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)
|
||||
|
@ -281,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));
|
||||
|
@ -294,7 +297,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";
|
||||
|
@ -335,12 +338,15 @@ 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=" << CompatUtility::GetCheckableHasBeenChecked(checkable) << "\n"
|
||||
"\t" "check_interval=" << (checkable->GetCheckInterval() / 60.0) << "\n"
|
||||
"\t" "retry_interval=" << (checkable->GetRetryInterval() / 60.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";
|
||||
|
||||
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"
|
||||
|
@ -359,20 +365,24 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl
|
|||
"\t" "last_time_critical=" << static_cast<int>(service->GetLastStateCritical()) << "\n"
|
||||
"\t" "last_time_unknown=" << static_cast<int>(service->GetLastStateUnknown()) << "\n";
|
||||
} else {
|
||||
fp << "\t" "current_state=" << CompatUtility::GetHostCurrentState(host) << "\n"
|
||||
int currentState = host->GetState();
|
||||
|
||||
if (currentState != HostUp && !host->IsReachable())
|
||||
currentState = 2; /* hardcoded compat state */
|
||||
|
||||
fp << "\t" "current_state=" << currentState << "\n"
|
||||
"\t" "last_hard_state=" << host->GetLastHardState() << "\n"
|
||||
"\t" "last_time_up=" << static_cast<int>(host->GetLastStateUp()) << "\n"
|
||||
"\t" "last_time_down=" << static_cast<int>(host->GetLastStateDown()) << "\n";
|
||||
}
|
||||
|
||||
fp << "\t" "state_type=" << checkable->GetStateType() << "\n"
|
||||
"\t" "plugin_output=" << CompatUtility::GetCheckResultOutput(cr) << "\n"
|
||||
"\t" "long_plugin_output=" << CompatUtility::GetCheckResultLongOutput(cr) << "\n"
|
||||
"\t" "performance_data=" << CompatUtility::GetCheckResultPerfdata(cr) << "\n";
|
||||
"\t" "last_check=" << static_cast<long>(host->GetLastCheck()) << "\n";
|
||||
|
||||
if (cr) {
|
||||
fp << "\t" << "check_source=" << cr->GetCheckSource() << "\n"
|
||||
"\t" "last_check=" << static_cast<long>(cr->GetScheduleEnd()) << "\n";
|
||||
fp << "\t" "plugin_output=" << CompatUtility::GetCheckResultOutput(cr) << "\n"
|
||||
"\t" "long_plugin_output=" << CompatUtility::GetCheckResultLongOutput(cr) << "\n"
|
||||
"\t" "performance_data=" << PluginUtility::FormatPerfdata(cr->GetPerformanceData()) << "\n";
|
||||
}
|
||||
|
||||
fp << "\t" << "next_check=" << static_cast<long>(checkable->GetNextCheck()) << "\n"
|
||||
|
@ -380,21 +390,21 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl
|
|||
"\t" "max_attempts=" << checkable->GetMaxCheckAttempts() << "\n"
|
||||
"\t" "last_state_change=" << static_cast<long>(checkable->GetLastStateChange()) << "\n"
|
||||
"\t" "last_hard_state_change=" << static_cast<long>(checkable->GetLastHardStateChange()) << "\n"
|
||||
"\t" "last_update=" << static_cast<long>(time(nullptr)) << "\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" "is_flapping=" << CompatUtility::GetCheckableIsFlapping(checkable) << "\n"
|
||||
"\t" "percent_state_change=" << CompatUtility::GetCheckablePercentStateChange(checkable) << "\n"
|
||||
"\t" "problem_has_been_acknowledged=" << CompatUtility::GetCheckableProblemHasBeenAcknowledged(checkable) << "\n"
|
||||
"\t" "acknowledgement_type=" << CompatUtility::GetCheckableAcknowledgementType(checkable) << "\n"
|
||||
"\t" "last_update=" << static_cast<long>(Utility::GetTime()) << "\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=" << Convert::ToLong(checkable->IsFlapping()) << "\n"
|
||||
"\t" "percent_state_change=" << checkable->GetFlappingCurrent() << "\n"
|
||||
"\t" "problem_has_been_acknowledged=" << (checkable->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n"
|
||||
"\t" "acknowledgement_type=" << checkable->GetAcknowledgement() << "\n"
|
||||
"\t" "acknowledgement_end_time=" << checkable->GetAcknowledgementExpiry() << "\n"
|
||||
"\t" "scheduled_downtime_depth=" << checkable->GetDowntimeDepth() << "\n"
|
||||
"\t" "last_notification=" << CompatUtility::GetCheckableNotificationLastNotification(checkable) << "\n"
|
||||
"\t" "next_notification=" << CompatUtility::GetCheckableNotificationNextNotification(checkable) << "\n"
|
||||
"\t" "current_notification_number=" << CompatUtility::GetCheckableNotificationNotificationNumber(checkable) << "\n"
|
||||
"\t" "is_reachable=" << CompatUtility::GetCheckableIsReachable(checkable) << "\n";
|
||||
"\t" "is_reachable=" << Convert::ToLong(checkable->IsReachable()) << "\n";
|
||||
}
|
||||
|
||||
void StatusDataWriter::DumpServiceStatus(std::ostream& fp, const Service::Ptr& service)
|
||||
|
@ -427,19 +437,18 @@ 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" "check_interval" "\t" << (service->GetCheckInterval() / 60.0) << "\n"
|
||||
"\t" "retry_interval" "\t" << (service->GetRetryInterval() / 60.0) << "\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" "is_volatile" "\t" << CompatUtility::GetCheckableIsVolatile(service) << "\n"
|
||||
"\t" "notifications_enabled" "\t" << CompatUtility::GetCheckableNotificationsEnabled(service) << "\n"
|
||||
"\t" "notification_options" "\t" << CompatUtility::GetCheckableNotificationNotificationOptions(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" << Convert::ToLong(service->GetVolatile()) << "\n"
|
||||
"\t" "notifications_enabled" "\t" << Convert::ToLong(service->GetEnableNotifications()) << "\n"
|
||||
"\t" "notification_options" "\t" << GetNotificationOptions(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)
|
||||
|
@ -449,6 +458,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";
|
||||
|
@ -466,8 +479,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 +754,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 +812,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<long>(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<long>(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";
|
||||
|
@ -863,3 +877,53 @@ void StatusDataWriter::ObjectHandler()
|
|||
{
|
||||
m_ObjectsCacheOutdated = true;
|
||||
}
|
||||
|
||||
String StatusDataWriter::GetNotificationOptions(const Checkable::Ptr& checkable)
|
||||
{
|
||||
Host::Ptr host;
|
||||
Service::Ptr service;
|
||||
tie(host, service) = GetHostService(checkable);
|
||||
|
||||
unsigned long notification_type_filter = 0;
|
||||
unsigned long notification_state_filter = 0;
|
||||
|
||||
for (const Notification::Ptr& notification : checkable->GetNotifications()) {
|
||||
notification_type_filter |= notification->GetTypeFilter();
|
||||
notification_state_filter |= notification->GetStateFilter();
|
||||
}
|
||||
|
||||
std::vector<String> notification_options;
|
||||
|
||||
/* notification state filters */
|
||||
if (service) {
|
||||
if (notification_state_filter & ServiceWarning) {
|
||||
notification_options.push_back("w");
|
||||
}
|
||||
if (notification_state_filter & ServiceUnknown) {
|
||||
notification_options.push_back("u");
|
||||
}
|
||||
if (notification_state_filter & ServiceCritical) {
|
||||
notification_options.push_back("c");
|
||||
}
|
||||
} else {
|
||||
if (notification_state_filter & HostDown) {
|
||||
notification_options.push_back("d");
|
||||
}
|
||||
}
|
||||
|
||||
/* notification type filters */
|
||||
if (notification_type_filter & NotificationRecovery) {
|
||||
notification_options.push_back("r");
|
||||
}
|
||||
if ((notification_type_filter & NotificationFlappingStart) ||
|
||||
(notification_type_filter & NotificationFlappingEnd)) {
|
||||
notification_options.push_back("f");
|
||||
}
|
||||
if ((notification_type_filter & NotificationDowntimeStart) ||
|
||||
(notification_type_filter & NotificationDowntimeEnd) ||
|
||||
(notification_type_filter & NotificationDowntimeRemoved)) {
|
||||
notification_options.push_back("s");
|
||||
}
|
||||
|
||||
return boost::algorithm::join(notification_options, ",");
|
||||
}
|
||||
|
|
|
@ -97,6 +97,8 @@ private:
|
|||
void UpdateObjectsCache();
|
||||
void StatusTimerHandler();
|
||||
void ObjectHandler();
|
||||
|
||||
static String GetNotificationOptions(const Checkable::Ptr& checkable);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -132,6 +132,12 @@ private:
|
|||
static void AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime::Ptr& downtime, bool historical);
|
||||
static void RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downtime::Ptr& downtime);
|
||||
static void EnableChangedHandlerInternal(const Checkable::Ptr& checkable, const String& fieldName, bool enabled);
|
||||
|
||||
static int GetHostState(const Host::Ptr& host);
|
||||
static String GetHostStateString(const Host::Ptr& host);
|
||||
static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
|
||||
static int MapNotificationReasonType(NotificationType type);
|
||||
static int MapExternalCommandType(const String& name);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ void DbObject::SendVarsConfigUpdateHeavy()
|
|||
query2.WhereCriteria->Set("object_id", obj);
|
||||
queries.emplace_back(std::move(query2));
|
||||
|
||||
Dictionary::Ptr vars = CompatUtility::GetCustomAttributeConfig(custom_var_object);
|
||||
Dictionary::Ptr vars = custom_var_object->GetVars();
|
||||
|
||||
if (vars) {
|
||||
ObjectLock olock (vars);
|
||||
|
@ -274,7 +274,7 @@ void DbObject::SendVarsStatusUpdate()
|
|||
if (!custom_var_object)
|
||||
return;
|
||||
|
||||
Dictionary::Ptr vars = CompatUtility::GetCustomAttributeConfig(custom_var_object);
|
||||
Dictionary::Ptr vars = custom_var_object->GetVars();
|
||||
|
||||
if (vars) {
|
||||
std::vector<DbQuery> queries;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "icinga/checkcommand.hpp"
|
||||
#include "icinga/eventcommand.hpp"
|
||||
#include "icinga/compatutility.hpp"
|
||||
#include "icinga/pluginutility.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/logger.hpp"
|
||||
|
@ -47,65 +48,52 @@ Dictionary::Ptr HostDbObject::GetConfigFields() const
|
|||
Dictionary::Ptr fields = new Dictionary();
|
||||
Host::Ptr host = static_pointer_cast<Host>(GetObject());
|
||||
|
||||
fields->Set("alias", CompatUtility::GetHostAlias(host));
|
||||
fields->Set("display_name", host->GetDisplayName());
|
||||
/* Compatibility fallback. */
|
||||
String displayName = host->GetDisplayName();
|
||||
|
||||
if (!displayName.IsEmpty())
|
||||
fields->Set("alias", displayName);
|
||||
else
|
||||
fields->Set("alias", host->GetName());
|
||||
|
||||
fields->Set("display_name", displayName);
|
||||
fields->Set("address", host->GetAddress());
|
||||
fields->Set("address6", host->GetAddress6());
|
||||
|
||||
fields->Set("check_command_object_id", host->GetCheckCommand());
|
||||
fields->Set("check_command_args", CompatUtility::GetCheckableCommandArgs(host));
|
||||
fields->Set("eventhandler_command_object_id", host->GetEventCommand());
|
||||
fields->Set("eventhandler_command_args", Empty);
|
||||
fields->Set("notification_timeperiod_object_id", Empty);
|
||||
fields->Set("check_timeperiod_object_id", host->GetCheckPeriod());
|
||||
fields->Set("failure_prediction_options", Empty);
|
||||
fields->Set("check_interval", CompatUtility::GetCheckableCheckInterval(host));
|
||||
fields->Set("retry_interval", CompatUtility::GetCheckableRetryInterval(host));
|
||||
fields->Set("check_interval", host->GetCheckInterval() / 60.0);
|
||||
fields->Set("retry_interval", host->GetRetryInterval() / 60.0);
|
||||
fields->Set("max_check_attempts", host->GetMaxCheckAttempts());
|
||||
|
||||
fields->Set("first_notification_delay", Empty);
|
||||
|
||||
fields->Set("notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(host));
|
||||
fields->Set("notify_on_down", CompatUtility::GetHostNotifyOnDown(host));
|
||||
fields->Set("notify_on_unreachable", CompatUtility::GetHostNotifyOnDown(host));
|
||||
|
||||
fields->Set("notify_on_recovery", CompatUtility::GetCheckableNotifyOnRecovery(host));
|
||||
fields->Set("notify_on_flapping", CompatUtility::GetCheckableNotifyOnFlapping(host));
|
||||
fields->Set("notify_on_downtime", CompatUtility::GetCheckableNotifyOnDowntime(host));
|
||||
|
||||
fields->Set("stalk_on_up", Empty);
|
||||
fields->Set("stalk_on_down", Empty);
|
||||
fields->Set("stalk_on_unreachable", Empty);
|
||||
|
||||
fields->Set("flap_detection_enabled", CompatUtility::GetCheckableFlapDetectionEnabled(host));
|
||||
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("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("retain_status_information", 1);
|
||||
fields->Set("retain_nonstatus_information", 1);
|
||||
|
||||
fields->Set("notifications_enabled", CompatUtility::GetCheckableNotificationsEnabled(host));
|
||||
|
||||
fields->Set("obsess_over_host", 0);
|
||||
fields->Set("failure_prediction_enabled", 0);
|
||||
|
||||
fields->Set("flap_detection_enabled", host->GetEnableFlapping());
|
||||
fields->Set("low_flap_threshold", host->GetFlappingThresholdLow());
|
||||
fields->Set("high_flap_threshold", host->GetFlappingThresholdLow());
|
||||
fields->Set("process_performance_data", host->GetEnablePerfdata());
|
||||
fields->Set("freshness_checks_enabled", 1);
|
||||
fields->Set("freshness_threshold", Convert::ToLong(host->GetCheckInterval()));
|
||||
fields->Set("event_handler_enabled", host->GetEnableEventHandler());
|
||||
fields->Set("passive_checks_enabled", host->GetEnablePassiveChecks());
|
||||
fields->Set("active_checks_enabled", host->GetEnableActiveChecks());
|
||||
fields->Set("notifications_enabled", host->GetEnableNotifications());
|
||||
fields->Set("notes", host->GetNotes());
|
||||
fields->Set("notes_url", host->GetNotesUrl());
|
||||
fields->Set("action_url", host->GetActionUrl());
|
||||
fields->Set("icon_image", host->GetIconImage());
|
||||
fields->Set("icon_image_alt", host->GetIconImageAlt());
|
||||
|
||||
fields->Set("notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(host));
|
||||
|
||||
unsigned long notificationStateFilter = CompatUtility::GetCheckableNotificationTypeFilter(host);
|
||||
unsigned long notificationTypeFilter = CompatUtility::GetCheckableNotificationTypeFilter(host);
|
||||
|
||||
fields->Set("notify_on_down", (notificationStateFilter & ServiceWarning) || (notificationStateFilter && ServiceCritical));
|
||||
fields->Set("notify_on_unreachable", 1); /* We don't have this filter and state, and as such we don't filter such notifications. */
|
||||
fields->Set("notify_on_recovery", notificationTypeFilter & NotificationRecovery);
|
||||
fields->Set("notify_on_flapping", (notificationTypeFilter & NotificationFlappingStart) ||
|
||||
(notificationTypeFilter & NotificationFlappingEnd));
|
||||
fields->Set("notify_on_downtime", (notificationTypeFilter & NotificationDowntimeStart) ||
|
||||
(notificationTypeFilter & NotificationDowntimeEnd) || (notificationTypeFilter & NotificationDowntimeRemoved));
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
@ -119,59 +107,62 @@ Dictionary::Ptr HostDbObject::GetStatusFields() const
|
|||
if (cr) {
|
||||
fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
||||
fields->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
||||
fields->Set("perfdata", CompatUtility::GetCheckResultPerfdata(cr));
|
||||
fields->Set("perfdata", PluginUtility::FormatPerfdata(cr->GetPerformanceData()));
|
||||
fields->Set("check_source", cr->GetCheckSource());
|
||||
fields->Set("latency", cr->CalculateLatency());
|
||||
fields->Set("execution_time", cr->CalculateExecutionTime());
|
||||
}
|
||||
|
||||
fields->Set("current_state", CompatUtility::GetHostCurrentState(host));
|
||||
fields->Set("has_been_checked", CompatUtility::GetCheckableHasBeenChecked(host));
|
||||
int currentState = host->GetState();
|
||||
|
||||
if (currentState != HostUp && !host->IsReachable())
|
||||
currentState = 2; /* hardcoded compat state */
|
||||
|
||||
fields->Set("current_state", currentState);
|
||||
fields->Set("has_been_checked", host->HasBeenChecked());
|
||||
fields->Set("should_be_scheduled", host->GetEnableActiveChecks());
|
||||
fields->Set("current_check_attempt", host->GetCheckAttempt());
|
||||
fields->Set("max_check_attempts", host->GetMaxCheckAttempts());
|
||||
|
||||
if (cr)
|
||||
fields->Set("last_check", DbValue::FromTimestamp(cr->GetScheduleEnd()));
|
||||
|
||||
fields->Set("last_check", DbValue::FromTimestamp(host->GetLastCheck()));
|
||||
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());
|
||||
fields->Set("last_time_up", DbValue::FromTimestamp(static_cast<int>(host->GetLastStateUp())));
|
||||
fields->Set("last_time_down", DbValue::FromTimestamp(static_cast<int>(host->GetLastStateDown())));
|
||||
fields->Set("last_time_unreachable", DbValue::FromTimestamp(static_cast<int>(host->GetLastStateUnreachable())));
|
||||
fields->Set("last_time_up", DbValue::FromTimestamp(host->GetLastStateUp()));
|
||||
fields->Set("last_time_down", DbValue::FromTimestamp(host->GetLastStateDown()));
|
||||
fields->Set("last_time_unreachable", DbValue::FromTimestamp(host->GetLastStateUnreachable()));
|
||||
fields->Set("state_type", host->GetStateType());
|
||||
fields->Set("notifications_enabled", host->GetEnableNotifications());
|
||||
fields->Set("problem_has_been_acknowledged", host->GetAcknowledgement() != AcknowledgementNone);
|
||||
fields->Set("acknowledgement_type", host->GetAcknowledgement());
|
||||
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", host->IsFlapping());
|
||||
fields->Set("percent_state_change", host->GetFlappingCurrent());
|
||||
fields->Set("scheduled_downtime_depth", host->GetDowntimeDepth());
|
||||
fields->Set("process_performance_data", host->GetEnablePerfdata());
|
||||
fields->Set("normal_check_interval", host->GetCheckInterval() / 60.0);
|
||||
fields->Set("retry_check_interval", host->GetRetryInterval() / 60.0);
|
||||
fields->Set("check_timeperiod_object_id", host->GetCheckPeriod());
|
||||
fields->Set("is_reachable", host->IsReachable());
|
||||
fields->Set("original_attributes", JsonEncode(host->GetOriginalAttributes()));
|
||||
|
||||
fields->Set("current_notification_number", CompatUtility::GetCheckableNotificationNotificationNumber(host));
|
||||
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("problem_has_been_acknowledged", CompatUtility::GetCheckableProblemHasBeenAcknowledged(host));
|
||||
fields->Set("acknowledgement_type", CompatUtility::GetCheckableAcknowledgementType(host));
|
||||
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("is_flapping", CompatUtility::GetCheckableIsFlapping(host));
|
||||
fields->Set("percent_state_change", CompatUtility::GetCheckablePercentStateChange(host));
|
||||
|
||||
if (cr) {
|
||||
fields->Set("latency", Convert::ToString(cr->CalculateLatency()));
|
||||
fields->Set("execution_time", Convert::ToString(cr->CalculateExecutionTime()));
|
||||
}
|
||||
EventCommand::Ptr eventCommand = host->GetEventCommand();
|
||||
|
||||
fields->Set("scheduled_downtime_depth", host->GetDowntimeDepth());
|
||||
fields->Set("failure_prediction_enabled", Empty);
|
||||
fields->Set("process_performance_data", CompatUtility::GetCheckableProcessPerformanceData(host));
|
||||
fields->Set("obsess_over_host", Empty);
|
||||
fields->Set("event_handler", CompatUtility::GetCheckableEventHandler(host));
|
||||
fields->Set("check_command", CompatUtility::GetCheckableCheckCommand(host));
|
||||
fields->Set("normal_check_interval", CompatUtility::GetCheckableCheckInterval(host));
|
||||
fields->Set("retry_check_interval", CompatUtility::GetCheckableRetryInterval(host));
|
||||
fields->Set("check_timeperiod_object_id", host->GetCheckPeriod());
|
||||
fields->Set("is_reachable", CompatUtility::GetCheckableIsReachable(host));
|
||||
if (eventCommand)
|
||||
fields->Set("event_handler", eventCommand->GetName());
|
||||
|
||||
fields->Set("original_attributes", JsonEncode(host->GetOriginalAttributes()));
|
||||
CheckCommand::Ptr checkCommand = host->GetCheckCommand();
|
||||
|
||||
if (checkCommand)
|
||||
fields->Set("check_command", checkCommand->GetName());
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
@ -275,7 +266,7 @@ void HostDbObject::OnConfigUpdateHeavy()
|
|||
continue;
|
||||
}
|
||||
|
||||
int state_filter = dep->GetStateFilter();
|
||||
int stateFilter = dep->GetStateFilter();
|
||||
|
||||
Log(LogDebug, "HostDbObject")
|
||||
<< "parent host: " << parent->GetName();
|
||||
|
@ -285,8 +276,8 @@ void HostDbObject::OnConfigUpdateHeavy()
|
|||
fields2->Set("dependent_host_object_id", host);
|
||||
fields2->Set("inherits_parent", 1);
|
||||
fields2->Set("timeperiod_object_id", dep->GetPeriod());
|
||||
fields2->Set("fail_on_up", (state_filter & StateFilterUp) ? 1 : 0);
|
||||
fields2->Set("fail_on_down", (state_filter & StateFilterDown) ? 1 : 0);
|
||||
fields2->Set("fail_on_up", stateFilter & StateFilterUp);
|
||||
fields2->Set("fail_on_down", stateFilter & StateFilterDown);
|
||||
fields2->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
|
||||
DbQuery query2;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "icinga/eventcommand.hpp"
|
||||
#include "icinga/externalcommandprocessor.hpp"
|
||||
#include "icinga/compatutility.hpp"
|
||||
#include "icinga/pluginutility.hpp"
|
||||
#include "icinga/icingaapplication.hpp"
|
||||
#include "remote/endpoint.hpp"
|
||||
#include "base/convert.hpp"
|
||||
|
@ -56,52 +57,42 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields() const
|
|||
fields->Set("host_object_id", host);
|
||||
fields->Set("display_name", service->GetDisplayName());
|
||||
fields->Set("check_command_object_id", service->GetCheckCommand());
|
||||
fields->Set("check_command_args", CompatUtility::GetCheckableCommandArgs(service));
|
||||
fields->Set("eventhandler_command_object_id", service->GetEventCommand());
|
||||
fields->Set("eventhandler_command_args", Empty);
|
||||
fields->Set("notification_timeperiod_object_id", Empty);
|
||||
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
||||
fields->Set("failure_prediction_options", Empty);
|
||||
fields->Set("check_interval", CompatUtility::GetCheckableCheckInterval(service));
|
||||
fields->Set("retry_interval", CompatUtility::GetCheckableRetryInterval(service));
|
||||
fields->Set("check_interval", service->GetCheckInterval() / 60.0);
|
||||
fields->Set("retry_interval", service->GetRetryInterval() / 60.0);
|
||||
fields->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||
fields->Set("first_notification_delay", Empty);
|
||||
fields->Set("notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(service));
|
||||
fields->Set("notify_on_warning", CompatUtility::GetCheckableNotifyOnWarning(service));
|
||||
fields->Set("notify_on_unknown", CompatUtility::GetCheckableNotifyOnUnknown(service));
|
||||
fields->Set("notify_on_critical", CompatUtility::GetCheckableNotifyOnCritical(service));
|
||||
fields->Set("notify_on_recovery", CompatUtility::GetCheckableNotifyOnRecovery(service));
|
||||
fields->Set("notify_on_flapping", CompatUtility::GetCheckableNotifyOnFlapping(service));
|
||||
fields->Set("notify_on_downtime", CompatUtility::GetCheckableNotifyOnDowntime(service));
|
||||
fields->Set("stalk_on_ok", 0);
|
||||
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("flap_detection_enabled", CompatUtility::GetCheckableFlapDetectionEnabled(service));
|
||||
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("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("retain_status_information", Empty);
|
||||
fields->Set("retain_nonstatus_information", Empty);
|
||||
fields->Set("notifications_enabled", CompatUtility::GetCheckableNotificationsEnabled(service));
|
||||
fields->Set("obsess_over_service", Empty);
|
||||
fields->Set("failure_prediction_enabled", Empty);
|
||||
fields->Set("is_volatile", service->GetVolatile());
|
||||
fields->Set("flap_detection_enabled", service->GetEnableFlapping());
|
||||
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", 1);
|
||||
fields->Set("freshness_threshold", Convert::ToLong(service->GetCheckInterval()));
|
||||
fields->Set("event_handler_enabled", service->GetEnableEventHandler());
|
||||
fields->Set("passive_checks_enabled", service->GetEnablePassiveChecks());
|
||||
fields->Set("active_checks_enabled", service->GetEnableActiveChecks());
|
||||
fields->Set("notifications_enabled", service->GetEnableNotifications());
|
||||
fields->Set("notes", service->GetNotes());
|
||||
fields->Set("notes_url", service->GetNotesUrl());
|
||||
fields->Set("action_url", service->GetActionUrl());
|
||||
fields->Set("icon_image", service->GetIconImage());
|
||||
fields->Set("icon_image_alt", service->GetIconImageAlt());
|
||||
|
||||
fields->Set("notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(service));
|
||||
|
||||
unsigned long notificationStateFilter = CompatUtility::GetCheckableNotificationTypeFilter(service);
|
||||
unsigned long notificationTypeFilter = CompatUtility::GetCheckableNotificationTypeFilter(service);
|
||||
|
||||
fields->Set("notify_on_warning", notificationStateFilter & ServiceWarning);
|
||||
fields->Set("notify_on_unknown", notificationStateFilter & ServiceUnknown);
|
||||
fields->Set("notify_on_critical", notificationStateFilter & ServiceCritical);
|
||||
fields->Set("notify_on_recovery", notificationTypeFilter & NotificationRecovery);
|
||||
fields->Set("notify_on_flapping", (notificationTypeFilter & NotificationFlappingStart) ||
|
||||
(notificationTypeFilter & NotificationFlappingEnd));
|
||||
fields->Set("notify_on_downtime", (notificationTypeFilter & NotificationDowntimeStart) ||
|
||||
(notificationTypeFilter & NotificationDowntimeEnd) || (notificationTypeFilter & NotificationDowntimeRemoved));
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
@ -114,58 +105,58 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields() const
|
|||
if (cr) {
|
||||
fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
||||
fields->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
||||
fields->Set("perfdata", CompatUtility::GetCheckResultPerfdata(cr));
|
||||
fields->Set("perfdata", PluginUtility::FormatPerfdata(cr->GetPerformanceData()));
|
||||
fields->Set("check_source", cr->GetCheckSource());
|
||||
fields->Set("latency", cr->CalculateLatency());
|
||||
fields->Set("execution_time", cr->CalculateExecutionTime());
|
||||
}
|
||||
|
||||
fields->Set("current_state", service->GetState());
|
||||
fields->Set("has_been_checked", CompatUtility::GetCheckableHasBeenChecked(service));
|
||||
fields->Set("has_been_checked", service->HasBeenChecked());
|
||||
fields->Set("should_be_scheduled", service->GetEnableActiveChecks());
|
||||
fields->Set("current_check_attempt", service->GetCheckAttempt());
|
||||
fields->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||
|
||||
if (cr)
|
||||
fields->Set("last_check", DbValue::FromTimestamp(cr->GetScheduleEnd()));
|
||||
|
||||
fields->Set("last_check", DbValue::FromTimestamp(service->GetLastCheck()));
|
||||
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());
|
||||
fields->Set("last_time_ok", DbValue::FromTimestamp(static_cast<int>(service->GetLastStateOK())));
|
||||
fields->Set("last_time_warning", DbValue::FromTimestamp(static_cast<int>(service->GetLastStateWarning())));
|
||||
fields->Set("last_time_critical", DbValue::FromTimestamp(static_cast<int>(service->GetLastStateCritical())));
|
||||
fields->Set("last_time_unknown", DbValue::FromTimestamp(static_cast<int>(service->GetLastStateUnknown())));
|
||||
fields->Set("last_time_ok", DbValue::FromTimestamp(service->GetLastStateOK()));
|
||||
fields->Set("last_time_warning", DbValue::FromTimestamp(service->GetLastStateWarning()));
|
||||
fields->Set("last_time_critical", DbValue::FromTimestamp(service->GetLastStateCritical()));
|
||||
fields->Set("last_time_unknown", DbValue::FromTimestamp(service->GetLastStateUnknown()));
|
||||
fields->Set("state_type", service->GetStateType());
|
||||
fields->Set("notifications_enabled", service->GetEnableNotifications());
|
||||
fields->Set("problem_has_been_acknowledged", service->GetAcknowledgement() != AcknowledgementNone);
|
||||
fields->Set("acknowledgement_type", service->GetAcknowledgement());
|
||||
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", service->IsFlapping());
|
||||
fields->Set("percent_state_change", service->GetFlappingCurrent());
|
||||
fields->Set("scheduled_downtime_depth", service->GetDowntimeDepth());
|
||||
fields->Set("process_performance_data", service->GetEnablePerfdata());
|
||||
fields->Set("normal_check_interval", service->GetCheckInterval() / 60.0);
|
||||
fields->Set("retry_check_interval", service->GetRetryInterval() / 60.0);
|
||||
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
||||
fields->Set("is_reachable", service->IsReachable());
|
||||
fields->Set("original_attributes", JsonEncode(service->GetOriginalAttributes()));
|
||||
|
||||
fields->Set("current_notification_number", CompatUtility::GetCheckableNotificationNotificationNumber(service));
|
||||
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("problem_has_been_acknowledged", CompatUtility::GetCheckableProblemHasBeenAcknowledged(service));
|
||||
fields->Set("acknowledgement_type", CompatUtility::GetCheckableAcknowledgementType(service));
|
||||
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("is_flapping", CompatUtility::GetCheckableIsFlapping(service));
|
||||
fields->Set("percent_state_change", CompatUtility::GetCheckablePercentStateChange(service));
|
||||
|
||||
if (cr) {
|
||||
fields->Set("latency", Convert::ToString(cr->CalculateLatency()));
|
||||
fields->Set("execution_time", Convert::ToString(cr->CalculateExecutionTime()));
|
||||
}
|
||||
EventCommand::Ptr eventCommand = service->GetEventCommand();
|
||||
|
||||
fields->Set("scheduled_downtime_depth", service->GetDowntimeDepth());
|
||||
fields->Set("process_performance_data", CompatUtility::GetCheckableProcessPerformanceData(service));
|
||||
fields->Set("event_handler", CompatUtility::GetCheckableEventHandler(service));
|
||||
fields->Set("check_command", CompatUtility::GetCheckableCheckCommand(service));
|
||||
fields->Set("normal_check_interval", CompatUtility::GetCheckableCheckInterval(service));
|
||||
fields->Set("retry_check_interval", CompatUtility::GetCheckableRetryInterval(service));
|
||||
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
||||
fields->Set("is_reachable", CompatUtility::GetCheckableIsReachable(service));
|
||||
if (eventCommand)
|
||||
fields->Set("event_handler", eventCommand->GetName());
|
||||
|
||||
fields->Set("original_attributes", JsonEncode(service->GetOriginalAttributes()));
|
||||
CheckCommand::Ptr checkCommand = service->GetCheckCommand();
|
||||
|
||||
if (checkCommand)
|
||||
fields->Set("check_command", checkCommand->GetName());
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
@ -236,7 +227,7 @@ void ServiceDbObject::OnConfigUpdateHeavy()
|
|||
Log(LogDebug, "ServiceDbObject")
|
||||
<< "service parents: " << parent->GetName();
|
||||
|
||||
int state_filter = dep->GetStateFilter();
|
||||
int stateFilter = dep->GetStateFilter();
|
||||
|
||||
/* service dependencies */
|
||||
Dictionary::Ptr fields1 = new Dictionary();
|
||||
|
@ -244,10 +235,10 @@ void ServiceDbObject::OnConfigUpdateHeavy()
|
|||
fields1->Set("dependent_service_object_id", service);
|
||||
fields1->Set("inherits_parent", 1);
|
||||
fields1->Set("timeperiod_object_id", dep->GetPeriod());
|
||||
fields1->Set("fail_on_ok", (state_filter & StateFilterOK) ? 1 : 0);
|
||||
fields1->Set("fail_on_warning", (state_filter & StateFilterWarning) ? 1 : 0);
|
||||
fields1->Set("fail_on_critical", (state_filter & StateFilterCritical) ? 1 : 0);
|
||||
fields1->Set("fail_on_unknown", (state_filter & StateFilterUnknown) ? 1 : 0);
|
||||
fields1->Set("fail_on_ok", stateFilter & StateFilterOK);
|
||||
fields1->Set("fail_on_warning", stateFilter & StateFilterWarning);
|
||||
fields1->Set("fail_on_critical", stateFilter & StateFilterCritical);
|
||||
fields1->Set("fail_on_unknown", stateFilter & StateFilterUnknown);
|
||||
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
|
||||
DbQuery query1;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
/* command */
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
String CompatUtility::GetCommandLine(const Command::Ptr& command)
|
||||
{
|
||||
Value commandLine = command->GetCommandLine();
|
||||
|
@ -56,6 +56,7 @@ String CompatUtility::GetCommandLine(const Command::Ptr& command)
|
|||
}
|
||||
|
||||
String CompatUtility::GetCommandNamePrefix(const Command::Ptr& command)
|
||||
/* Helper. */
|
||||
{
|
||||
if (!command)
|
||||
return Empty;
|
||||
|
@ -72,6 +73,7 @@ String CompatUtility::GetCommandNamePrefix(const Command::Ptr& command)
|
|||
}
|
||||
|
||||
String CompatUtility::GetCommandName(const Command::Ptr& command)
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
{
|
||||
if (!command)
|
||||
return Empty;
|
||||
|
@ -79,53 +81,7 @@ String CompatUtility::GetCommandName(const Command::Ptr& command)
|
|||
return GetCommandNamePrefix(command) + command->GetName();
|
||||
}
|
||||
|
||||
/* host */
|
||||
int CompatUtility::GetHostCurrentState(const Host::Ptr& host)
|
||||
{
|
||||
if (host->GetState() != HostUp && !host->IsReachable())
|
||||
return 2; /* hardcoded compat state */
|
||||
|
||||
return host->GetState();
|
||||
}
|
||||
|
||||
String CompatUtility::GetHostStateString(const Host::Ptr& host)
|
||||
{
|
||||
if (host->GetState() != HostUp && !host->IsReachable())
|
||||
return "UNREACHABLE"; /* hardcoded compat state */
|
||||
|
||||
return Host::StateToString(host->GetState());
|
||||
}
|
||||
|
||||
String CompatUtility::GetHostAlias(const Host::Ptr& host)
|
||||
{
|
||||
if (!host->GetDisplayName().IsEmpty())
|
||||
return host->GetName();
|
||||
else
|
||||
return host->GetDisplayName();
|
||||
}
|
||||
|
||||
int CompatUtility::GetHostNotifyOnDown(const Host::Ptr& host)
|
||||
{
|
||||
unsigned long notification_state_filter = GetCheckableNotificationStateFilter(host);
|
||||
|
||||
if ((notification_state_filter & ServiceCritical) ||
|
||||
(notification_state_filter & ServiceWarning))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CompatUtility::GetHostNotifyOnUnreachable(const Host::Ptr& host)
|
||||
{
|
||||
unsigned long notification_state_filter = GetCheckableNotificationStateFilter(host);
|
||||
|
||||
if (notification_state_filter & ServiceUnknown)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* service */
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable)
|
||||
{
|
||||
CheckCommand::Ptr command = checkable->GetCheckCommand();
|
||||
|
@ -191,204 +147,7 @@ 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;
|
||||
}
|
||||
|
||||
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::GetCheckableHasBeenChecked(const Checkable::Ptr& checkable)
|
||||
{
|
||||
return (checkable->GetLastCheckResult() ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
int CompatUtility::GetCheckableProblemHasBeenAcknowledged(const Checkable::Ptr& checkable)
|
||||
{
|
||||
return (checkable->GetAcknowledgement() != AcknowledgementNone ? 1 : 0);
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableAcknowledgementType(const Checkable::Ptr& checkable)
|
||||
{
|
||||
return static_cast<int>(checkable->GetAcknowledgement());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableIsReachable(const Checkable::Ptr& checkable)
|
||||
{
|
||||
return (checkable->IsReachable() ? 1 : 0);
|
||||
}
|
||||
|
||||
double CompatUtility::GetCheckablePercentStateChange(const Checkable::Ptr& checkable)
|
||||
{
|
||||
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;
|
||||
EventCommand::Ptr eventcommand = checkable->GetEventCommand();
|
||||
|
||||
if (eventcommand)
|
||||
event_command_str = eventcommand->GetName();
|
||||
|
||||
return event_command_str;
|
||||
}
|
||||
|
||||
String CompatUtility::GetCheckableCheckCommand(const Checkable::Ptr& checkable)
|
||||
{
|
||||
String check_command_str;
|
||||
CheckCommand::Ptr checkcommand = checkable->GetCheckCommand();
|
||||
|
||||
if (checkcommand)
|
||||
check_command_str = checkcommand->GetName();
|
||||
|
||||
return check_command_str;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableFreshnessThreshold(const Checkable::Ptr& checkable)
|
||||
{
|
||||
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())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableInCheckPeriod(const Checkable::Ptr& checkable)
|
||||
{
|
||||
TimePeriod::Ptr timeperiod = checkable->GetCheckPeriod();
|
||||
|
||||
/* none set means always checked */
|
||||
if (!timeperiod)
|
||||
return 1;
|
||||
|
||||
return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable)
|
||||
{
|
||||
for (const Notification::Ptr& notification : checkable->GetNotifications()) {
|
||||
TimePeriod::Ptr timeperiod = notification->GetPeriod();
|
||||
|
||||
if (!timeperiod || timeperiod->IsInside(Utility::GetTime()))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vars attr */
|
||||
Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const CustomVarObject::Ptr& object)
|
||||
{
|
||||
Dictionary::Ptr vars = object->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return nullptr;
|
||||
|
||||
return vars;
|
||||
}
|
||||
|
||||
String CompatUtility::GetCustomAttributeConfig(const CustomVarObject::Ptr& object, const String& name)
|
||||
{
|
||||
Dictionary::Ptr vars = object->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
||||
return vars->Get(name);
|
||||
}
|
||||
|
||||
/* notifications */
|
||||
int CompatUtility::GetCheckableNotificationsEnabled(const Checkable::Ptr& checkable)
|
||||
{
|
||||
return (checkable->GetEnableNotifications() ? 1 : 0);
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
int CompatUtility::GetCheckableNotificationLastNotification(const Checkable::Ptr& checkable)
|
||||
{
|
||||
double last_notification = 0.0;
|
||||
|
@ -400,6 +159,7 @@ int CompatUtility::GetCheckableNotificationLastNotification(const Checkable::Ptr
|
|||
return static_cast<int>(last_notification);
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
int CompatUtility::GetCheckableNotificationNextNotification(const Checkable::Ptr& checkable)
|
||||
{
|
||||
double next_notification = 0.0;
|
||||
|
@ -411,6 +171,7 @@ int CompatUtility::GetCheckableNotificationNextNotification(const Checkable::Ptr
|
|||
return static_cast<int>(next_notification);
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
int CompatUtility::GetCheckableNotificationNotificationNumber(const Checkable::Ptr& checkable)
|
||||
{
|
||||
int notification_number = 0;
|
||||
|
@ -422,6 +183,7 @@ int CompatUtility::GetCheckableNotificationNotificationNumber(const Checkable::P
|
|||
return notification_number;
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
double CompatUtility::GetCheckableNotificationNotificationInterval(const Checkable::Ptr& checkable)
|
||||
{
|
||||
double notification_interval = -1;
|
||||
|
@ -437,57 +199,7 @@ double CompatUtility::GetCheckableNotificationNotificationInterval(const Checkab
|
|||
return notification_interval / 60.0;
|
||||
}
|
||||
|
||||
String CompatUtility::GetCheckableNotificationNotificationOptions(const Checkable::Ptr& checkable)
|
||||
{
|
||||
|
||||
Host::Ptr host;
|
||||
Service::Ptr service;
|
||||
tie(host, service) = GetHostService(checkable);
|
||||
|
||||
unsigned long notification_type_filter = 0;
|
||||
unsigned long notification_state_filter = 0;
|
||||
|
||||
for (const Notification::Ptr& notification : checkable->GetNotifications()) {
|
||||
notification_type_filter |= notification->GetTypeFilter();
|
||||
notification_state_filter |= notification->GetStateFilter();
|
||||
}
|
||||
|
||||
std::vector<String> notification_options;
|
||||
|
||||
/* notification state filters */
|
||||
if (service) {
|
||||
if (notification_state_filter & ServiceWarning) {
|
||||
notification_options.emplace_back("w");
|
||||
}
|
||||
if (notification_state_filter & ServiceUnknown) {
|
||||
notification_options.emplace_back("u");
|
||||
}
|
||||
if (notification_state_filter & ServiceCritical) {
|
||||
notification_options.emplace_back("c");
|
||||
}
|
||||
} else {
|
||||
if (notification_state_filter & HostDown) {
|
||||
notification_options.emplace_back("d");
|
||||
}
|
||||
}
|
||||
|
||||
/* notification type filters */
|
||||
if (notification_type_filter & NotificationRecovery) {
|
||||
notification_options.emplace_back("r");
|
||||
}
|
||||
if ((notification_type_filter & NotificationFlappingStart) ||
|
||||
(notification_type_filter & NotificationFlappingEnd)) {
|
||||
notification_options.emplace_back("f");
|
||||
}
|
||||
if ((notification_type_filter & NotificationDowntimeStart) ||
|
||||
(notification_type_filter & NotificationDowntimeEnd) ||
|
||||
(notification_type_filter & NotificationDowntimeRemoved)) {
|
||||
notification_options.emplace_back("s");
|
||||
}
|
||||
|
||||
return boost::algorithm::join(notification_options, ",");
|
||||
}
|
||||
|
||||
/* Helper. */
|
||||
int CompatUtility::GetCheckableNotificationTypeFilter(const Checkable::Ptr& checkable)
|
||||
{
|
||||
unsigned long notification_type_filter = 0;
|
||||
|
@ -501,6 +213,7 @@ int CompatUtility::GetCheckableNotificationTypeFilter(const Checkable::Ptr& chec
|
|||
return notification_type_filter;
|
||||
}
|
||||
|
||||
/* Helper. */
|
||||
int CompatUtility::GetCheckableNotificationStateFilter(const Checkable::Ptr& checkable)
|
||||
{
|
||||
unsigned long notification_state_filter = 0;
|
||||
|
@ -514,61 +227,7 @@ int CompatUtility::GetCheckableNotificationStateFilter(const Checkable::Ptr& che
|
|||
return notification_state_filter;
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableNotifyOnWarning(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (GetCheckableNotificationStateFilter(checkable) & ServiceWarning)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableNotifyOnCritical(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (GetCheckableNotificationStateFilter(checkable) & ServiceCritical)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableNotifyOnUnknown(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (GetCheckableNotificationStateFilter(checkable) & ServiceUnknown)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableNotifyOnRecovery(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (GetCheckableNotificationTypeFilter(checkable) & NotificationRecovery)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableNotifyOnFlapping(const Checkable::Ptr& checkable)
|
||||
{
|
||||
unsigned long notification_type_filter = GetCheckableNotificationTypeFilter(checkable);
|
||||
|
||||
if ((notification_type_filter & NotificationFlappingStart) ||
|
||||
(notification_type_filter & NotificationFlappingEnd))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CompatUtility::GetCheckableNotifyOnDowntime(const Checkable::Ptr& checkable)
|
||||
{
|
||||
unsigned long notification_type_filter = GetCheckableNotificationTypeFilter(checkable);
|
||||
|
||||
if ((notification_type_filter & NotificationDowntimeStart) ||
|
||||
(notification_type_filter & NotificationDowntimeEnd) ||
|
||||
(notification_type_filter & NotificationDowntimeRemoved))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
std::set<User::Ptr> CompatUtility::GetCheckableNotificationUsers(const Checkable::Ptr& checkable)
|
||||
{
|
||||
/* Service -> Notifications -> (Users + UserGroups -> Users) */
|
||||
|
@ -591,6 +250,7 @@ std::set<User::Ptr> CompatUtility::GetCheckableNotificationUsers(const Checkable
|
|||
return allUsers;
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
std::set<UserGroup::Ptr> CompatUtility::GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable)
|
||||
{
|
||||
std::set<UserGroup::Ptr> usergroups;
|
||||
|
@ -606,6 +266,7 @@ std::set<UserGroup::Ptr> CompatUtility::GetCheckableNotificationUserGroups(const
|
|||
return usergroups;
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter, Livestatus, CompatLogger, GelfWriter. */
|
||||
String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
|
||||
{
|
||||
if (!cr)
|
||||
|
@ -620,6 +281,7 @@ String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
|
|||
return raw_output.SubStr(0, line_end);
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
String CompatUtility::GetCheckResultLongOutput(const CheckResult::Ptr& cr)
|
||||
{
|
||||
if (!cr)
|
||||
|
@ -640,14 +302,7 @@ String CompatUtility::GetCheckResultLongOutput(const CheckResult::Ptr& cr)
|
|||
return Empty;
|
||||
}
|
||||
|
||||
String CompatUtility::GetCheckResultPerfdata(const CheckResult::Ptr& cr)
|
||||
{
|
||||
if (!cr)
|
||||
return String();
|
||||
|
||||
return PluginUtility::FormatPerfdata(cr->GetPerformanceData());
|
||||
}
|
||||
|
||||
/* Helper for DB IDO, StatusDataWriter and Livestatus. Used in StatusDataWriter. */
|
||||
String CompatUtility::EscapeString(const String& str)
|
||||
{
|
||||
String result = str;
|
||||
|
@ -655,399 +310,10 @@ String CompatUtility::EscapeString(const String& str)
|
|||
return result;
|
||||
}
|
||||
|
||||
/* Used in ExternalCommandListener and CheckResultReader. */
|
||||
String CompatUtility::UnEscapeString(const String& str)
|
||||
{
|
||||
String result = str;
|
||||
boost::algorithm::replace_all(result, "\\n", "\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
std::pair<unsigned long, unsigned long> CompatUtility::ConvertTimestamp(double time)
|
||||
{
|
||||
unsigned long time_sec = static_cast<long>(time);
|
||||
unsigned long time_usec = (time - time_sec) * 1000 * 1000;
|
||||
|
||||
return std::make_pair(time_sec, time_usec);
|
||||
}
|
||||
|
||||
int CompatUtility::MapNotificationReasonType(NotificationType type)
|
||||
{
|
||||
switch (type) {
|
||||
case NotificationDowntimeStart:
|
||||
return 5;
|
||||
case NotificationDowntimeEnd:
|
||||
return 6;
|
||||
case NotificationDowntimeRemoved:
|
||||
return 7;
|
||||
case NotificationCustom:
|
||||
return 8;
|
||||
case NotificationAcknowledgement:
|
||||
return 1;
|
||||
case NotificationProblem:
|
||||
return 0;
|
||||
case NotificationRecovery:
|
||||
return 0;
|
||||
case NotificationFlappingStart:
|
||||
return 2;
|
||||
case NotificationFlappingEnd:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int CompatUtility::MapExternalCommandType(const String& name)
|
||||
{
|
||||
if (name == "NONE")
|
||||
return 0;
|
||||
if (name == "ADD_HOST_COMMENT")
|
||||
return 1;
|
||||
if (name == "DEL_HOST_COMMENT")
|
||||
return 2;
|
||||
if (name == "ADD_SVC_COMMENT")
|
||||
return 3;
|
||||
if (name == "DEL_SVC_COMMENT")
|
||||
return 4;
|
||||
if (name == "ENABLE_SVC_CHECK")
|
||||
return 5;
|
||||
if (name == "DISABLE_SVC_CHECK")
|
||||
return 6;
|
||||
if (name == "SCHEDULE_SVC_CHECK")
|
||||
return 7;
|
||||
if (name == "DELAY_SVC_NOTIFICATION")
|
||||
return 9;
|
||||
if (name == "DELAY_HOST_NOTIFICATION")
|
||||
return 10;
|
||||
if (name == "DISABLE_NOTIFICATIONS")
|
||||
return 11;
|
||||
if (name == "ENABLE_NOTIFICATIONS")
|
||||
return 12;
|
||||
if (name == "RESTART_PROCESS")
|
||||
return 13;
|
||||
if (name == "SHUTDOWN_PROCESS")
|
||||
return 14;
|
||||
if (name == "ENABLE_HOST_SVC_CHECKS")
|
||||
return 15;
|
||||
if (name == "DISABLE_HOST_SVC_CHECKS")
|
||||
return 16;
|
||||
if (name == "SCHEDULE_HOST_SVC_CHECKS")
|
||||
return 17;
|
||||
if (name == "DELAY_HOST_SVC_NOTIFICATIONS")
|
||||
return 19;
|
||||
if (name == "DEL_ALL_HOST_COMMENTS")
|
||||
return 20;
|
||||
if (name == "DEL_ALL_SVC_COMMENTS")
|
||||
return 21;
|
||||
if (name == "ENABLE_SVC_NOTIFICATIONS")
|
||||
return 22;
|
||||
if (name == "DISABLE_SVC_NOTIFICATIONS")
|
||||
return 23;
|
||||
if (name == "ENABLE_HOST_NOTIFICATIONS")
|
||||
return 24;
|
||||
if (name == "DISABLE_HOST_NOTIFICATIONS")
|
||||
return 25;
|
||||
if (name == "ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST")
|
||||
return 26;
|
||||
if (name == "DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST")
|
||||
return 27;
|
||||
if (name == "ENABLE_HOST_SVC_NOTIFICATIONS")
|
||||
return 28;
|
||||
if (name == "DISABLE_HOST_SVC_NOTIFICATIONS")
|
||||
return 29;
|
||||
if (name == "PROCESS_SERVICE_CHECK_RESULT")
|
||||
return 30;
|
||||
if (name == "SAVE_STATE_INFORMATION")
|
||||
return 31;
|
||||
if (name == "READ_STATE_INFORMATION")
|
||||
return 32;
|
||||
if (name == "ACKNOWLEDGE_HOST_PROBLEM")
|
||||
return 33;
|
||||
if (name == "ACKNOWLEDGE_SVC_PROBLEM")
|
||||
return 34;
|
||||
if (name == "START_EXECUTING_SVC_CHECKS")
|
||||
return 35;
|
||||
if (name == "STOP_EXECUTING_SVC_CHECKS")
|
||||
return 36;
|
||||
if (name == "START_ACCEPTING_PASSIVE_SVC_CHECKS")
|
||||
return 37;
|
||||
if (name == "STOP_ACCEPTING_PASSIVE_SVC_CHECKS")
|
||||
return 38;
|
||||
if (name == "ENABLE_PASSIVE_SVC_CHECKS")
|
||||
return 39;
|
||||
if (name == "DISABLE_PASSIVE_SVC_CHECKS")
|
||||
return 40;
|
||||
if (name == "ENABLE_EVENT_HANDLERS")
|
||||
return 41;
|
||||
if (name == "DISABLE_EVENT_HANDLERS")
|
||||
return 42;
|
||||
if (name == "ENABLE_HOST_EVENT_HANDLER")
|
||||
return 43;
|
||||
if (name == "DISABLE_HOST_EVENT_HANDLER")
|
||||
return 44;
|
||||
if (name == "ENABLE_SVC_EVENT_HANDLER")
|
||||
return 45;
|
||||
if (name == "DISABLE_SVC_EVENT_HANDLER")
|
||||
return 46;
|
||||
if (name == "ENABLE_HOST_CHECK")
|
||||
return 47;
|
||||
if (name == "DISABLE_HOST_CHECK")
|
||||
return 48;
|
||||
if (name == "START_OBSESSING_OVER_SVC_CHECKS")
|
||||
return 49;
|
||||
if (name == "STOP_OBSESSING_OVER_SVC_CHECKS")
|
||||
return 50;
|
||||
if (name == "REMOVE_HOST_ACKNOWLEDGEMENT")
|
||||
return 51;
|
||||
if (name == "REMOVE_SVC_ACKNOWLEDGEMENT")
|
||||
return 52;
|
||||
if (name == "SCHEDULE_FORCED_HOST_SVC_CHECKS")
|
||||
return 53;
|
||||
if (name == "SCHEDULE_FORCED_SVC_CHECK")
|
||||
return 54;
|
||||
if (name == "SCHEDULE_HOST_DOWNTIME")
|
||||
return 55;
|
||||
if (name == "SCHEDULE_SVC_DOWNTIME")
|
||||
return 56;
|
||||
if (name == "ENABLE_HOST_FLAP_DETECTION")
|
||||
return 57;
|
||||
if (name == "DISABLE_HOST_FLAP_DETECTION")
|
||||
return 58;
|
||||
if (name == "ENABLE_SVC_FLAP_DETECTION")
|
||||
return 59;
|
||||
if (name == "DISABLE_SVC_FLAP_DETECTION")
|
||||
return 60;
|
||||
if (name == "ENABLE_FLAP_DETECTION")
|
||||
return 61;
|
||||
if (name == "DISABLE_FLAP_DETECTION")
|
||||
return 62;
|
||||
if (name == "ENABLE_HOSTGROUP_SVC_NOTIFICATIONS")
|
||||
return 63;
|
||||
if (name == "DISABLE_HOSTGROUP_SVC_NOTIFICATIONS")
|
||||
return 64;
|
||||
if (name == "ENABLE_HOSTGROUP_HOST_NOTIFICATIONS")
|
||||
return 65;
|
||||
if (name == "DISABLE_HOSTGROUP_HOST_NOTIFICATIONS")
|
||||
return 66;
|
||||
if (name == "ENABLE_HOSTGROUP_SVC_CHECKS")
|
||||
return 67;
|
||||
if (name == "DISABLE_HOSTGROUP_SVC_CHECKS")
|
||||
return 68;
|
||||
if (name == "CANCEL_HOST_DOWNTIME")
|
||||
return 69;
|
||||
if (name == "CANCEL_SVC_DOWNTIME")
|
||||
return 70;
|
||||
if (name == "CANCEL_ACTIVE_HOST_DOWNTIME")
|
||||
return 71;
|
||||
if (name == "CANCEL_PENDING_HOST_DOWNTIME")
|
||||
return 72;
|
||||
if (name == "CANCEL_ACTIVE_SVC_DOWNTIME")
|
||||
return 73;
|
||||
if (name == "CANCEL_PENDING_SVC_DOWNTIME")
|
||||
return 74;
|
||||
if (name == "CANCEL_ACTIVE_HOST_SVC_DOWNTIME")
|
||||
return 75;
|
||||
if (name == "CANCEL_PENDING_HOST_SVC_DOWNTIME")
|
||||
return 76;
|
||||
if (name == "FLUSH_PENDING_COMMANDS")
|
||||
return 77;
|
||||
if (name == "DEL_HOST_DOWNTIME")
|
||||
return 78;
|
||||
if (name == "DEL_SVC_DOWNTIME")
|
||||
return 79;
|
||||
if (name == "ENABLE_FAILURE_PREDICTION")
|
||||
return 80;
|
||||
if (name == "DISABLE_FAILURE_PREDICTION")
|
||||
return 81;
|
||||
if (name == "ENABLE_PERFORMANCE_DATA")
|
||||
return 82;
|
||||
if (name == "DISABLE_PERFORMANCE_DATA")
|
||||
return 83;
|
||||
if (name == "SCHEDULE_HOSTGROUP_HOST_DOWNTIME")
|
||||
return 84;
|
||||
if (name == "SCHEDULE_HOSTGROUP_SVC_DOWNTIME")
|
||||
return 85;
|
||||
if (name == "SCHEDULE_HOST_SVC_DOWNTIME")
|
||||
return 86;
|
||||
if (name == "PROCESS_HOST_CHECK_RESULT")
|
||||
return 87;
|
||||
if (name == "START_EXECUTING_HOST_CHECKS")
|
||||
return 88;
|
||||
if (name == "STOP_EXECUTING_HOST_CHECKS")
|
||||
return 89;
|
||||
if (name == "START_ACCEPTING_PASSIVE_HOST_CHECKS")
|
||||
return 90;
|
||||
if (name == "STOP_ACCEPTING_PASSIVE_HOST_CHECKS")
|
||||
return 91;
|
||||
if (name == "ENABLE_PASSIVE_HOST_CHECKS")
|
||||
return 92;
|
||||
if (name == "DISABLE_PASSIVE_HOST_CHECKS")
|
||||
return 93;
|
||||
if (name == "START_OBSESSING_OVER_HOST_CHECKS")
|
||||
return 94;
|
||||
if (name == "STOP_OBSESSING_OVER_HOST_CHECKS")
|
||||
return 95;
|
||||
if (name == "SCHEDULE_HOST_CHECK")
|
||||
return 96;
|
||||
if (name == "SCHEDULE_FORCED_HOST_CHECK")
|
||||
return 98;
|
||||
if (name == "START_OBSESSING_OVER_SVC")
|
||||
return 99;
|
||||
if (name == "STOP_OBSESSING_OVER_SVC")
|
||||
return 100;
|
||||
if (name == "START_OBSESSING_OVER_HOST")
|
||||
return 101;
|
||||
if (name == "STOP_OBSESSING_OVER_HOST")
|
||||
return 102;
|
||||
if (name == "ENABLE_HOSTGROUP_HOST_CHECKS")
|
||||
return 103;
|
||||
if (name == "DISABLE_HOSTGROUP_HOST_CHECKS")
|
||||
return 104;
|
||||
if (name == "ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS")
|
||||
return 105;
|
||||
if (name == "DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS")
|
||||
return 106;
|
||||
if (name == "ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS")
|
||||
return 107;
|
||||
if (name == "DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS")
|
||||
return 108;
|
||||
if (name == "ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS")
|
||||
return 109;
|
||||
if (name == "DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS")
|
||||
return 110;
|
||||
if (name == "ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS")
|
||||
return 111;
|
||||
if (name == "DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS")
|
||||
return 112;
|
||||
if (name == "ENABLE_SERVICEGROUP_SVC_CHECKS")
|
||||
return 113;
|
||||
if (name == "DISABLE_SERVICEGROUP_SVC_CHECKS")
|
||||
return 114;
|
||||
if (name == "ENABLE_SERVICEGROUP_HOST_CHECKS")
|
||||
return 115;
|
||||
if (name == "DISABLE_SERVICEGROUP_HOST_CHECKS")
|
||||
return 116;
|
||||
if (name == "ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS")
|
||||
return 117;
|
||||
if (name == "DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS")
|
||||
return 118;
|
||||
if (name == "ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS")
|
||||
return 119;
|
||||
if (name == "DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS")
|
||||
return 120;
|
||||
if (name == "SCHEDULE_SERVICEGROUP_HOST_DOWNTIME")
|
||||
return 121;
|
||||
if (name == "SCHEDULE_SERVICEGROUP_SVC_DOWNTIME")
|
||||
return 122;
|
||||
if (name == "CHANGE_GLOBAL_HOST_EVENT_HANDLER")
|
||||
return 123;
|
||||
if (name == "CHANGE_GLOBAL_SVC_EVENT_HANDLER")
|
||||
return 124;
|
||||
if (name == "CHANGE_HOST_EVENT_HANDLER")
|
||||
return 125;
|
||||
if (name == "CHANGE_SVC_EVENT_HANDLER")
|
||||
return 126;
|
||||
if (name == "CHANGE_HOST_CHECK_COMMAND")
|
||||
return 127;
|
||||
if (name == "CHANGE_SVC_CHECK_COMMAND")
|
||||
return 128;
|
||||
if (name == "CHANGE_NORMAL_HOST_CHECK_INTERVAL")
|
||||
return 129;
|
||||
if (name == "CHANGE_NORMAL_SVC_CHECK_INTERVAL")
|
||||
return 130;
|
||||
if (name == "CHANGE_RETRY_SVC_CHECK_INTERVAL")
|
||||
return 131;
|
||||
if (name == "CHANGE_MAX_HOST_CHECK_ATTEMPTS")
|
||||
return 132;
|
||||
if (name == "CHANGE_MAX_SVC_CHECK_ATTEMPTS")
|
||||
return 133;
|
||||
if (name == "SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME")
|
||||
return 134;
|
||||
if (name == "ENABLE_HOST_AND_CHILD_NOTIFICATIONS")
|
||||
return 135;
|
||||
if (name == "DISABLE_HOST_AND_CHILD_NOTIFICATIONS")
|
||||
return 136;
|
||||
if (name == "SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME")
|
||||
return 137;
|
||||
if (name == "ENABLE_SERVICE_FRESHNESS_CHECKS")
|
||||
return 138;
|
||||
if (name == "DISABLE_SERVICE_FRESHNESS_CHECKS")
|
||||
return 139;
|
||||
if (name == "ENABLE_HOST_FRESHNESS_CHECKS")
|
||||
return 140;
|
||||
if (name == "DISABLE_HOST_FRESHNESS_CHECKS")
|
||||
return 141;
|
||||
if (name == "SET_HOST_NOTIFICATION_NUMBER")
|
||||
return 142;
|
||||
if (name == "SET_SVC_NOTIFICATION_NUMBER")
|
||||
return 143;
|
||||
if (name == "CHANGE_HOST_CHECK_TIMEPERIOD")
|
||||
return 144;
|
||||
if (name == "CHANGE_SVC_CHECK_TIMEPERIOD")
|
||||
return 145;
|
||||
if (name == "PROCESS_FILE")
|
||||
return 146;
|
||||
if (name == "CHANGE_CUSTOM_HOST_VAR")
|
||||
return 147;
|
||||
if (name == "CHANGE_CUSTOM_SVC_VAR")
|
||||
return 148;
|
||||
if (name == "CHANGE_CUSTOM_CONTACT_VAR")
|
||||
return 149;
|
||||
if (name == "ENABLE_CONTACT_HOST_NOTIFICATIONS")
|
||||
return 150;
|
||||
if (name == "DISABLE_CONTACT_HOST_NOTIFICATIONS")
|
||||
return 151;
|
||||
if (name == "ENABLE_CONTACT_SVC_NOTIFICATIONS")
|
||||
return 152;
|
||||
if (name == "DISABLE_CONTACT_SVC_NOTIFICATIONS")
|
||||
return 153;
|
||||
if (name == "ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS")
|
||||
return 154;
|
||||
if (name == "DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS")
|
||||
return 155;
|
||||
if (name == "ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS")
|
||||
return 156;
|
||||
if (name == "DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS")
|
||||
return 157;
|
||||
if (name == "CHANGE_RETRY_HOST_CHECK_INTERVAL")
|
||||
return 158;
|
||||
if (name == "SEND_CUSTOM_HOST_NOTIFICATION")
|
||||
return 159;
|
||||
if (name == "SEND_CUSTOM_SVC_NOTIFICATION")
|
||||
return 160;
|
||||
if (name == "CHANGE_HOST_NOTIFICATION_TIMEPERIOD")
|
||||
return 161;
|
||||
if (name == "CHANGE_SVC_NOTIFICATION_TIMEPERIOD")
|
||||
return 162;
|
||||
if (name == "CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD")
|
||||
return 163;
|
||||
if (name == "CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD")
|
||||
return 164;
|
||||
if (name == "CHANGE_HOST_MODATTR")
|
||||
return 165;
|
||||
if (name == "CHANGE_SVC_MODATTR")
|
||||
return 166;
|
||||
if (name == "CHANGE_CONTACT_MODATTR")
|
||||
return 167;
|
||||
if (name == "CHANGE_CONTACT_MODHATTR")
|
||||
return 168;
|
||||
if (name == "CHANGE_CONTACT_MODSATTR")
|
||||
return 169;
|
||||
if (name == "SYNC_STATE_INFORMATION")
|
||||
return 170;
|
||||
if (name == "DEL_DOWNTIME_BY_HOST_NAME")
|
||||
return 171;
|
||||
if (name == "DEL_DOWNTIME_BY_HOSTGROUP_NAME")
|
||||
return 172;
|
||||
if (name == "DEL_DOWNTIME_BY_START_TIME_COMMENT")
|
||||
return 173;
|
||||
if (name == "ACKNOWLEDGE_HOST_PROBLEM_EXPIRE")
|
||||
return 174;
|
||||
if (name == "ACKNOWLEDGE_SVC_PROBLEM_EXPIRE")
|
||||
return 175;
|
||||
if (name == "DISABLE_NOTIFICATIONS_EXPIRE_TIME")
|
||||
return 176;
|
||||
if (name == "CUSTOM_COMMAND")
|
||||
return 999;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,12 +21,8 @@
|
|||
#define COMPATUTILITY_H
|
||||
|
||||
#include "icinga/i2-icinga.hpp"
|
||||
#include "icinga/customvarobject.hpp"
|
||||
#include "icinga/host.hpp"
|
||||
#include "icinga/command.hpp"
|
||||
#include "base/dictionary.hpp"
|
||||
#include "base/array.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -43,44 +39,8 @@ public:
|
|||
static String GetCommandLine(const Command::Ptr& command);
|
||||
static String GetCommandName(const Command::Ptr& command);
|
||||
|
||||
/* host */
|
||||
static int GetHostCurrentState(const Host::Ptr& host);
|
||||
static String GetHostStateString(const Host::Ptr& host);
|
||||
static String GetHostAlias(const Host::Ptr& host);
|
||||
static int GetHostNotifyOnDown(const Host::Ptr& host);
|
||||
static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
|
||||
|
||||
/* 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);
|
||||
static int GetCheckableHasBeenChecked(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableProblemHasBeenAcknowledged(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableAcknowledgementType(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);
|
||||
|
||||
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);
|
||||
static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable);
|
||||
|
||||
/* notification */
|
||||
static int GetCheckableNotificationsEnabled(const Checkable::Ptr& checkable);
|
||||
|
@ -88,34 +48,17 @@ public:
|
|||
static int GetCheckableNotificationNextNotification(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotificationNotificationNumber(const Checkable::Ptr& checkable);
|
||||
static double GetCheckableNotificationNotificationInterval(const Checkable::Ptr& checkable);
|
||||
static String GetCheckableNotificationNotificationOptions(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotificationTypeFilter(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotificationStateFilter(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnWarning(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnCritical(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnUnknown(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnRecovery(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnFlapping(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnDowntime(const Checkable::Ptr& checkable);
|
||||
|
||||
static std::set<User::Ptr> GetCheckableNotificationUsers(const Checkable::Ptr& checkable);
|
||||
static std::set<UserGroup::Ptr> GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable);
|
||||
|
||||
/* custom attribute */
|
||||
static String GetCustomAttributeConfig(const CustomVarObject::Ptr& object, const String& name);
|
||||
static Dictionary::Ptr GetCustomAttributeConfig(const CustomVarObject::Ptr& object);
|
||||
|
||||
/* check result */
|
||||
static String GetCheckResultOutput(const CheckResult::Ptr& cr);
|
||||
static String GetCheckResultLongOutput(const CheckResult::Ptr& cr);
|
||||
static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
|
||||
|
||||
/* misc */
|
||||
static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
|
||||
|
||||
static int MapNotificationReasonType(NotificationType type);
|
||||
static int MapExternalCommandType(const String& name);
|
||||
|
||||
static String EscapeString(const String& str);
|
||||
static String UnEscapeString(const String& str);
|
||||
|
||||
|
|
|
@ -99,12 +99,7 @@ Value CommandsTable::CustomVariableNamesAccessor(const Value& row)
|
|||
if (!command)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(command);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||
}
|
||||
Dictionary::Ptr vars = command->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -128,12 +123,7 @@ Value CommandsTable::CustomVariableValuesAccessor(const Value& row)
|
|||
if (!command)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(command);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||
}
|
||||
Dictionary::Ptr vars = command->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -157,12 +147,7 @@ Value CommandsTable::CustomVariablesAccessor(const Value& row)
|
|||
if (!command)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(command);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||
}
|
||||
Dictionary::Ptr vars = command->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
|
|
@ -203,12 +203,7 @@ Value ContactsTable::CustomVariableNamesAccessor(const Value& row)
|
|||
if (!user)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(user);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(user);
|
||||
}
|
||||
Dictionary::Ptr vars = user->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -230,12 +225,7 @@ Value ContactsTable::CustomVariableValuesAccessor(const Value& row)
|
|||
if (!user)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(user);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(user);
|
||||
}
|
||||
Dictionary::Ptr vars = user->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -260,12 +250,7 @@ Value ContactsTable::CustomVariablesAccessor(const Value& row)
|
|||
if (!user)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(user);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(user);
|
||||
}
|
||||
Dictionary::Ptr vars = user->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -295,12 +280,7 @@ Value ContactsTable::CVIsJsonAccessor(const Value& row)
|
|||
if (!user)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(user);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(user);
|
||||
}
|
||||
Dictionary::Ptr vars = user->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "icinga/macroprocessor.hpp"
|
||||
#include "icinga/icingaapplication.hpp"
|
||||
#include "icinga/compatutility.hpp"
|
||||
#include "icinga/pluginutility.hpp"
|
||||
#include "base/configtype.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/json.hpp"
|
||||
|
@ -76,7 +77,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));
|
||||
|
@ -108,7 +109,7 @@ void HostsTable::AddColumns(Table *table, const String& prefix,
|
|||
table->AddColumn(prefix + "scheduled_downtime_depth", Column(&HostsTable::ScheduledDowntimeDepthAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "is_executing", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "active_checks_enabled", Column(&HostsTable::ActiveChecksEnabledAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "check_options", Column(&HostsTable::CheckOptionsAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "check_options", Column(&Table::EmptyStringAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "obsess_over_host", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "modified_attributes", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "modified_attributes_list", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
|
@ -303,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)
|
||||
|
@ -407,10 +413,10 @@ Value HostsTable::PerfDataAccessor(const Value& row)
|
|||
String perfdata;
|
||||
CheckResult::Ptr cr = host->GetLastCheckResult();
|
||||
|
||||
if (cr)
|
||||
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
||||
if (!cr)
|
||||
return Empty;
|
||||
|
||||
return perfdata;
|
||||
return PluginUtility::FormatPerfdata(cr->GetPerformanceData());
|
||||
}
|
||||
|
||||
Value HostsTable::IconImageAccessor(const Value& row)
|
||||
|
@ -481,7 +487,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 +497,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 +507,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)
|
||||
|
@ -512,7 +518,7 @@ Value HostsTable::AcknowledgementTypeAccessor(const Value& row)
|
|||
return Empty;
|
||||
|
||||
ObjectLock olock(host);
|
||||
return CompatUtility::GetCheckableAcknowledgementType(host);
|
||||
return host->GetAcknowledgement();
|
||||
}
|
||||
|
||||
Value HostsTable::CheckTypeAccessor(const Value& row)
|
||||
|
@ -522,7 +528,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)
|
||||
|
@ -602,7 +608,7 @@ Value HostsTable::HasBeenCheckedAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableHasBeenChecked(host);
|
||||
return Convert::ToLong(host->HasBeenChecked());
|
||||
}
|
||||
|
||||
Value HostsTable::CurrentNotificationNumberAccessor(const Value& row)
|
||||
|
@ -632,7 +638,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 +648,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<Host::Ptr>(row);
|
||||
|
||||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return Convert::ToLong(host->GetEnablePerfdata());
|
||||
}
|
||||
|
||||
Value HostsTable::AcknowledgedAccessor(const Value& row)
|
||||
|
@ -653,7 +669,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)
|
||||
|
@ -683,7 +699,7 @@ Value HostsTable::NoMoreNotificationsAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableNoMoreNotifications(host);
|
||||
return (CompatUtility::GetCheckableNotificationNotificationInterval(host) == 0 && !host->GetVolatile()) ? 1 : 0;
|
||||
}
|
||||
|
||||
Value HostsTable::LastCheckAccessor(const Value& row)
|
||||
|
@ -763,13 +779,7 @@ Value HostsTable::ActiveChecksEnabledAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableActiveChecksEnabled(host);
|
||||
}
|
||||
|
||||
Value HostsTable::CheckOptionsAccessor(const Value&)
|
||||
{
|
||||
/* TODO - forcexec, freshness, orphan, none */
|
||||
return Empty;
|
||||
return Convert::ToLong(host->GetEnableActiveChecks());
|
||||
}
|
||||
|
||||
Value HostsTable::CheckIntervalAccessor(const Value& row)
|
||||
|
@ -779,7 +789,7 @@ Value HostsTable::CheckIntervalAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableCheckInterval(host);
|
||||
return host->GetCheckInterval() / 60.0;
|
||||
}
|
||||
|
||||
Value HostsTable::RetryIntervalAccessor(const Value& row)
|
||||
|
@ -789,7 +799,7 @@ Value HostsTable::RetryIntervalAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableRetryInterval(host);
|
||||
return host->GetRetryInterval() / 60.0;
|
||||
}
|
||||
|
||||
Value HostsTable::NotificationIntervalAccessor(const Value& row)
|
||||
|
@ -809,7 +819,7 @@ Value HostsTable::LowFlapThresholdAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableLowFlapThreshold(host);
|
||||
return host->GetFlappingThresholdLow();
|
||||
}
|
||||
|
||||
Value HostsTable::HighFlapThresholdAccessor(const Value& row)
|
||||
|
@ -819,7 +829,7 @@ Value HostsTable::HighFlapThresholdAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableHighFlapThreshold(host);
|
||||
return host->GetFlappingThresholdHigh();
|
||||
}
|
||||
|
||||
Value HostsTable::LatencyAccessor(const Value& row)
|
||||
|
@ -859,7 +869,7 @@ Value HostsTable::PercentStateChangeAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckablePercentStateChange(host);
|
||||
return host->GetFlappingCurrent();
|
||||
}
|
||||
|
||||
Value HostsTable::InNotificationPeriodAccessor(const Value& row)
|
||||
|
@ -869,7 +879,14 @@ Value HostsTable::InNotificationPeriodAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableInNotificationPeriod(host);
|
||||
for (const Notification::Ptr& notification : host->GetNotifications()) {
|
||||
TimePeriod::Ptr timeperiod = notification->GetPeriod();
|
||||
|
||||
if (!timeperiod || timeperiod->IsInside(Utility::GetTime()))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Value HostsTable::InCheckPeriodAccessor(const Value& row)
|
||||
|
@ -879,7 +896,13 @@ Value HostsTable::InCheckPeriodAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableInCheckPeriod(host);
|
||||
TimePeriod::Ptr timeperiod = host->GetCheckPeriod();
|
||||
|
||||
/* none set means always checked */
|
||||
if (!timeperiod)
|
||||
return 1;
|
||||
|
||||
return Convert::ToLong(timeperiod->IsInside(Utility::GetTime()));
|
||||
}
|
||||
|
||||
Value HostsTable::ContactsAccessor(const Value& row)
|
||||
|
@ -1013,12 +1036,7 @@ Value HostsTable::CustomVariableNamesAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(host);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(host);
|
||||
}
|
||||
Dictionary::Ptr vars = host->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -1040,12 +1058,7 @@ Value HostsTable::CustomVariableValuesAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(host);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(host);
|
||||
}
|
||||
Dictionary::Ptr vars = host->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -1070,12 +1083,7 @@ Value HostsTable::CustomVariablesAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(host);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(host);
|
||||
}
|
||||
Dictionary::Ptr vars = host->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -1105,12 +1113,7 @@ Value HostsTable::CVIsJsonAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(host);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(host);
|
||||
}
|
||||
Dictionary::Ptr vars = host->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
@ -1390,7 +1393,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)
|
||||
|
|
|
@ -99,7 +99,6 @@ protected:
|
|||
static Value IsFlappingAccessor(const Value& row);
|
||||
static Value ScheduledDowntimeDepthAccessor(const Value& row);
|
||||
static Value ActiveChecksEnabledAccessor(const Value& row);
|
||||
static Value CheckOptionsAccessor(const Value& row);
|
||||
static Value CheckIntervalAccessor(const Value& row);
|
||||
static Value RetryIntervalAccessor(const Value& row);
|
||||
static Value NotificationIntervalAccessor(const Value& row);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "icinga/macroprocessor.hpp"
|
||||
#include "icinga/icingaapplication.hpp"
|
||||
#include "icinga/compatutility.hpp"
|
||||
#include "icinga/pluginutility.hpp"
|
||||
#include "base/configtype.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/json.hpp"
|
||||
|
@ -103,9 +104,9 @@ void ServicesTable::AddColumns(Table *table, const String& prefix,
|
|||
table->AddColumn(prefix + "process_performance_data", Column(&ServicesTable::ProcessPerformanceDataAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "is_executing", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "active_checks_enabled", Column(&ServicesTable::ActiveChecksEnabledAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "check_options", Column(&ServicesTable::CheckOptionsAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "check_options", Column(&Table::EmptyStringAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "flap_detection_enabled", Column(&ServicesTable::FlapDetectionEnabledAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "check_freshness", Column(&ServicesTable::CheckFreshnessAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "check_freshness", Column(&Table::OneAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "obsess_over_service", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "modified_attributes", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
table->AddColumn(prefix + "modified_attributes_list", Column(&Table::ZeroAccessor, objectAccessor));
|
||||
|
@ -342,10 +343,10 @@ Value ServicesTable::PerfDataAccessor(const Value& row)
|
|||
String perfdata;
|
||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||
|
||||
if (cr)
|
||||
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
||||
if (!cr)
|
||||
return Empty;
|
||||
|
||||
return perfdata;
|
||||
return PluginUtility::FormatPerfdata(cr->GetPerformanceData());
|
||||
}
|
||||
|
||||
Value ServicesTable::CheckPeriodAccessor(const Value& row)
|
||||
|
@ -355,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)
|
||||
|
@ -509,7 +515,7 @@ Value ServicesTable::HasBeenCheckedAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableHasBeenChecked(service);
|
||||
return Convert::ToLong(service->HasBeenChecked());
|
||||
}
|
||||
|
||||
Value ServicesTable::LastStateAccessor(const Value& row)
|
||||
|
@ -549,7 +555,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)
|
||||
|
@ -560,7 +566,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)
|
||||
|
@ -571,7 +577,7 @@ Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
|
|||
return Empty;
|
||||
|
||||
ObjectLock olock(service);
|
||||
return CompatUtility::GetCheckableAcknowledgementType(service);
|
||||
return service->GetAcknowledgement();
|
||||
}
|
||||
|
||||
Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
|
||||
|
@ -581,7 +587,7 @@ Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableNoMoreNotifications(service);
|
||||
return (CompatUtility::GetCheckableNotificationNotificationInterval(service) == 0 && !service->GetVolatile()) ? 1 : 0;
|
||||
}
|
||||
|
||||
Value ServicesTable::LastTimeOkAccessor(const Value& row)
|
||||
|
@ -721,7 +727,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 +737,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 +747,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 +757,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 +767,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,13 +777,7 @@ Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableActiveChecksEnabled(service);
|
||||
}
|
||||
|
||||
Value ServicesTable::CheckOptionsAccessor(const Value& row)
|
||||
{
|
||||
/* TODO - forcexec, freshness, orphan, none */
|
||||
return Empty;
|
||||
return Convert::ToLong(service->GetEnableActiveChecks());
|
||||
}
|
||||
|
||||
Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row)
|
||||
|
@ -787,17 +787,7 @@ Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableFlapDetectionEnabled(service);
|
||||
}
|
||||
|
||||
Value ServicesTable::CheckFreshnessAccessor(const Value& row)
|
||||
{
|
||||
Service::Ptr service = static_cast<Service::Ptr>(row);
|
||||
|
||||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableFreshnessChecksEnabled(service);
|
||||
return Convert::ToLong(service->GetEnableFlapping());
|
||||
}
|
||||
|
||||
Value ServicesTable::StalenessAccessor(const Value& row)
|
||||
|
@ -807,7 +797,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)
|
||||
|
@ -817,7 +810,7 @@ Value ServicesTable::CheckIntervalAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableCheckInterval(service);
|
||||
return service->GetCheckInterval() / 60.0;
|
||||
}
|
||||
|
||||
Value ServicesTable::RetryIntervalAccessor(const Value& row)
|
||||
|
@ -827,7 +820,7 @@ Value ServicesTable::RetryIntervalAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableRetryInterval(service);
|
||||
return service->GetRetryInterval() / 60.0;
|
||||
}
|
||||
|
||||
Value ServicesTable::NotificationIntervalAccessor(const Value& row)
|
||||
|
@ -847,7 +840,7 @@ Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableLowFlapThreshold(service);
|
||||
return service->GetFlappingThresholdLow();
|
||||
}
|
||||
|
||||
Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
|
||||
|
@ -857,7 +850,7 @@ Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableHighFlapThreshold(service);
|
||||
return service->GetFlappingThresholdHigh();
|
||||
}
|
||||
|
||||
Value ServicesTable::LatencyAccessor(const Value& row)
|
||||
|
@ -897,7 +890,7 @@ Value ServicesTable::PercentStateChangeAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckablePercentStateChange(service);
|
||||
return service->GetFlappingCurrent();
|
||||
}
|
||||
|
||||
Value ServicesTable::InCheckPeriodAccessor(const Value& row)
|
||||
|
@ -907,7 +900,13 @@ Value ServicesTable::InCheckPeriodAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableInCheckPeriod(service);
|
||||
TimePeriod::Ptr timeperiod = service->GetCheckPeriod();
|
||||
|
||||
/* none set means always checked */
|
||||
if (!timeperiod)
|
||||
return 1;
|
||||
|
||||
return Convert::ToLong(timeperiod->IsInside(Utility::GetTime()));
|
||||
}
|
||||
|
||||
Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
|
||||
|
@ -917,7 +916,14 @@ Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableInNotificationPeriod(service);
|
||||
for (const Notification::Ptr& notification : service->GetNotifications()) {
|
||||
TimePeriod::Ptr timeperiod = notification->GetPeriod();
|
||||
|
||||
if (!timeperiod || timeperiod->IsInside(Utility::GetTime()))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Value ServicesTable::ContactsAccessor(const Value& row)
|
||||
|
@ -1052,12 +1058,7 @@ Value ServicesTable::CustomVariableNamesAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(service);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(service);
|
||||
}
|
||||
Dictionary::Ptr vars = service->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -1079,12 +1080,7 @@ Value ServicesTable::CustomVariableValuesAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(service);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(service);
|
||||
}
|
||||
Dictionary::Ptr vars = service->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -1109,12 +1105,7 @@ Value ServicesTable::CustomVariablesAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(service);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(service);
|
||||
}
|
||||
Dictionary::Ptr vars = service->GetVars();
|
||||
|
||||
Array::Ptr cv = new Array();
|
||||
|
||||
|
@ -1144,12 +1135,7 @@ Value ServicesTable::CVIsJsonAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr vars;
|
||||
|
||||
{
|
||||
ObjectLock olock(service);
|
||||
vars = CompatUtility::GetCustomAttributeConfig(service);
|
||||
}
|
||||
Dictionary::Ptr vars = service->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
|
|
@ -98,9 +98,7 @@ protected:
|
|||
static Value NotificationsEnabledAccessor(const Value& row);
|
||||
static Value ProcessPerformanceDataAccessor(const Value& row);
|
||||
static Value ActiveChecksEnabledAccessor(const Value& row);
|
||||
static Value CheckOptionsAccessor(const Value& row);
|
||||
static Value FlapDetectionEnabledAccessor(const Value& row);
|
||||
static Value CheckFreshnessAccessor(const Value& row);
|
||||
static Value StalenessAccessor(const Value& row);
|
||||
static Value CheckIntervalAccessor(const Value& row);
|
||||
static Value RetryIntervalAccessor(const Value& row);
|
||||
|
|
|
@ -325,8 +325,7 @@ void GelfWriter::NotificationToUserHandlerInternal(const Notification::Ptr& noti
|
|||
fields->Set("short_message", output);
|
||||
} else {
|
||||
fields->Set("_type", "HOST NOTIFICATION");
|
||||
//TODO: why?
|
||||
fields->Set("short_message", "(" + CompatUtility::GetHostStateString(host) + ")");
|
||||
fields->Set("short_message", output);
|
||||
}
|
||||
|
||||
fields->Set("_state", service ? Service::StateToString(service->GetState()) : Host::StateToString(host->GetState()));
|
||||
|
|
Loading…
Reference in New Issue