| 210 | } |
| 211 | |
| 212 | Value ClusterEvents::NextCheckChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params) |
| 213 | { |
| 214 | Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint(); |
| 215 | |
| 216 | if (!endpoint) { |
| 217 | Log(LogNotice, "ClusterEvents") |
| 218 | << "Discarding 'next check changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed)."; |
| 219 | return Empty; |
| 220 | } |
| 221 | |
| 222 | Host::Ptr host = Host::GetByName(params->Get("host")); |
| 223 | |
| 224 | if (!host) |
| 225 | return Empty; |
| 226 | |
| 227 | Checkable::Ptr checkable; |
| 228 | |
| 229 | if (params->Contains("service")) |
| 230 | checkable = host->GetServiceByShortName(params->Get("service")); |
| 231 | else |
| 232 | checkable = host; |
| 233 | |
| 234 | if (!checkable) |
| 235 | return Empty; |
| 236 | |
| 237 | if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) { |
| 238 | Log(LogNotice, "ClusterEvents") |
| 239 | << "Discarding 'next check changed' message for checkable '" << checkable->GetName() |
| 240 | << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access."; |
| 241 | return Empty; |
| 242 | } |
| 243 | |
| 244 | double nextCheck = params->Get("next_check"); |
| 245 | |
| 246 | if (nextCheck < Application::GetStartTime() + 60) |
| 247 | return Empty; |
| 248 | |
| 249 | checkable->SetNextCheck(params->Get("next_check"), false, origin); |
| 250 | |
| 251 | return Empty; |
| 252 | } |
| 253 | |
| 254 | void ClusterEvents::LastCheckStartedChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin) |
| 255 | { |
nothing calls this directly
no test coverage detected