| 158 | } |
| 159 | |
| 160 | void DbConnection::UpdateProgramStatus() |
| 161 | { |
| 162 | IcingaApplication::Ptr icingaApplication = IcingaApplication::GetInstance(); |
| 163 | |
| 164 | if (!icingaApplication) |
| 165 | return; |
| 166 | |
| 167 | Log(LogNotice, "DbConnection") |
| 168 | << "Updating programstatus table."; |
| 169 | |
| 170 | std::vector<DbQuery> queries; |
| 171 | |
| 172 | DbQuery query1; |
| 173 | query1.Type = DbQueryNewTransaction; |
| 174 | query1.Priority = PriorityImmediate; |
| 175 | queries.emplace_back(std::move(query1)); |
| 176 | |
| 177 | DbQuery query2; |
| 178 | query2.Table = "programstatus"; |
| 179 | query2.IdColumn = "programstatus_id"; |
| 180 | query2.Type = DbQueryInsert | DbQueryDelete; |
| 181 | query2.Category = DbCatProgramStatus; |
| 182 | |
| 183 | query2.Fields = new Dictionary({ |
| 184 | { "instance_id", 0 }, /* DbConnection class fills in real ID */ |
| 185 | { "program_version", Application::GetAppVersion() }, |
| 186 | { "status_update_time", DbValue::FromTimestamp(Utility::GetTime()) }, |
| 187 | { "program_start_time", DbValue::FromTimestamp(Application::GetStartTime()) }, |
| 188 | { "is_currently_running", 1 }, |
| 189 | { "endpoint_name", icingaApplication->GetNodeName() }, |
| 190 | { "process_id", Utility::GetPid() }, |
| 191 | { "daemon_mode", 1 }, |
| 192 | { "last_command_check", DbValue::FromTimestamp(Utility::GetTime()) }, |
| 193 | { "notifications_enabled", (icingaApplication->GetEnableNotifications() ? 1 : 0) }, |
| 194 | { "active_host_checks_enabled", (icingaApplication->GetEnableHostChecks() ? 1 : 0) }, |
| 195 | { "passive_host_checks_enabled", 1 }, |
| 196 | { "active_service_checks_enabled", (icingaApplication->GetEnableServiceChecks() ? 1 : 0) }, |
| 197 | { "passive_service_checks_enabled", 1 }, |
| 198 | { "event_handlers_enabled", (icingaApplication->GetEnableEventHandlers() ? 1 : 0) }, |
| 199 | { "flap_detection_enabled", (icingaApplication->GetEnableFlapping() ? 1 : 0) }, |
| 200 | { "process_performance_data", (icingaApplication->GetEnablePerfdata() ? 1 : 0) } |
| 201 | }); |
| 202 | |
| 203 | query2.WhereCriteria = new Dictionary({ |
| 204 | { "instance_id", 0 } /* DbConnection class fills in real ID */ |
| 205 | }); |
| 206 | |
| 207 | queries.emplace_back(std::move(query2)); |
| 208 | |
| 209 | DbQuery query3; |
| 210 | query3.Type = DbQueryNewTransaction; |
| 211 | queries.emplace_back(std::move(query3)); |
| 212 | |
| 213 | DbObject::OnMultipleQueries(queries); |
| 214 | |
| 215 | DbQuery query4; |
| 216 | query4.Table = "runtimevariables"; |
| 217 | query4.Type = DbQueryDelete; |
nothing calls this directly
no test coverage detected