MCPcopy Create free account
hub / github.com/Icinga/icinga2 / GetStatusFields

Method GetStatusFields

lib/db_ido/hostdbobject.cpp:76–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76Dictionary::Ptr HostDbObject::GetStatusFields() const
77{
78 Dictionary::Ptr fields = new Dictionary();
79 Host::Ptr host = static_pointer_cast<Host>(GetObject());
80
81 CheckResult::Ptr cr = host->GetLastCheckResult();
82
83 if (cr) {
84 fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
85 fields->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
86 fields->Set("perfdata", PluginUtility::FormatPerfdata(cr->GetPerformanceData()));
87 fields->Set("check_source", cr->GetCheckSource());
88 fields->Set("latency", cr->CalculateLatency());
89 fields->Set("execution_time", cr->CalculateExecutionTime());
90 }
91
92 int currentState = host->GetState();
93
94 if (currentState != HostUp && !host->GetLastReachable())
95 currentState = 2; /* hardcoded compat state */
96
97 fields->Set("current_state", currentState);
98 fields->Set("has_been_checked", host->HasBeenChecked());
99 fields->Set("should_be_scheduled", host->GetEnableActiveChecks());
100 fields->Set("current_check_attempt", host->GetCheckAttempt());
101 fields->Set("max_check_attempts", host->GetMaxCheckAttempts());
102 fields->Set("last_check", DbValue::FromTimestamp(host->GetLastCheck()));
103 fields->Set("next_check", DbValue::FromTimestamp(host->GetNextCheck()));
104 fields->Set("check_type", !host->GetEnableActiveChecks()); /* 0 .. active, 1 .. passive */
105 fields->Set("last_state_change", DbValue::FromTimestamp(host->GetLastStateChange()));
106 fields->Set("last_hard_state_change", DbValue::FromTimestamp(host->GetLastHardStateChange()));
107 fields->Set("last_hard_state", host->GetLastHardState());
108 fields->Set("last_time_up", DbValue::FromTimestamp(host->GetLastStateUp()));
109 fields->Set("last_time_down", DbValue::FromTimestamp(host->GetLastStateDown()));
110 fields->Set("last_time_unreachable", DbValue::FromTimestamp(host->GetLastStateUnreachable()));
111 fields->Set("state_type", host->GetStateType());
112 fields->Set("notifications_enabled", host->GetEnableNotifications());
113 fields->Set("problem_has_been_acknowledged", host->GetAcknowledgement() != AcknowledgementNone);
114 fields->Set("acknowledgement_type", host->GetAcknowledgement());
115 fields->Set("passive_checks_enabled", host->GetEnablePassiveChecks());
116 fields->Set("active_checks_enabled", host->GetEnableActiveChecks());
117 fields->Set("event_handler_enabled", host->GetEnableEventHandler());
118 fields->Set("flap_detection_enabled", host->GetEnableFlapping());
119 fields->Set("is_flapping", host->IsFlapping());
120 fields->Set("percent_state_change", host->GetFlappingCurrent());
121 fields->Set("scheduled_downtime_depth", host->GetDowntimeDepth());
122 fields->Set("process_performance_data", host->GetEnablePerfdata());
123 fields->Set("normal_check_interval", host->GetCheckInterval() / 60.0);
124 fields->Set("retry_check_interval", host->GetRetryInterval() / 60.0);
125 fields->Set("check_timeperiod_object_id", host->GetCheckPeriod());
126 fields->Set("is_reachable", host->GetLastReachable());
127 fields->Set("original_attributes", JsonEncode(host->GetOriginalAttributes()));
128
129 fields->Set("current_notification_number", CompatUtility::GetCheckableNotificationNotificationNumber(host));
130 fields->Set("last_notification", DbValue::FromTimestamp(CompatUtility::GetCheckableNotificationLastNotification(host)));
131 fields->Set("next_notification", DbValue::FromTimestamp(CompatUtility::GetCheckableNotificationNextNotification(host)));
132
133 EventCommand::Ptr eventCommand = host->GetEventCommand();

Callers

nothing calls this directly

Calls 14

CalculateLatencyMethod · 0.80
HasBeenCheckedMethod · 0.80
GetLastCheckMethod · 0.80
GetLastHardStateMethod · 0.80
GetAcknowledgementMethod · 0.80
IsFlappingMethod · 0.80
GetDowntimeDepthMethod · 0.80
GetCheckPeriodMethod · 0.80
GetEventCommandMethod · 0.80
GetCheckCommandMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected