/** * @param SubjectInterface $subject * @param IncidentInterface $incident */ public function notify(SubjectInterface $subject, IncidentInterface $incident) { if ($incident->getStatus() != IncidentInterface::STATUS_OK) { $message = Swift_Message::newInstance()->setTo($subject->getTarget())->setFrom($this->getFrom(), $this->getFromName())->setSubject(sprintf(self::EMAIL_SUBJECT_T, $incident->getIdent()))->setBody(sprintf(self::EMAIL_BODY_T, $incident->getMessage(), $incident->getType())); $this->getMailer()->send($message); $this->getMailer()->getTransport()->stop(); } }
/** * @param IncidentInterface $incident * @param $serverUrl */ protected function incidentCreate(IncidentInterface $incident, $serverUrl) { $response = $this->getHttpClient()->post($serverUrl . $this->getResourceUrl(), ['Content-type' => 'application/json'], json_encode(['name' => $incident->getIdent(), 'message' => $incident->getMessage(), 'status' => 1, 'visible' => 1])); if ($response instanceof ResponseInterface) { $data = json_decode($response->getBody()->getContents()); if (isset($data->data->id)) { $incident->setExternalId($data->data->id); } } }
/** * @param SubjectInterface $subject * @param IncidentInterface $incident */ public function notify(SubjectInterface $subject, IncidentInterface $incident) { $event = new Event(); $event->serviceKey = $this->getServiceKey(); $event->incidentKey = sprintf('hci_%d', $incident->getId()); if ($incident->getStatus() != IncidentInterface::STATUS_OK) { $event->description = $incident->getIdent(); $event->eventType = Event::EVENT_TYPE_TRIGGER; $event->details = ['log' => $incident->getMessage(), 'status' => $incident->getStatus(), 'type' => $incident->getType(), 'id' => $incident->getId()]; } else { $event->eventType = Event::EVENT_TYPE_RESOLVE; } $this->getEventClient()->post($event); }
/** * @param SubjectInterface $subject * @param IncidentInterface $incident */ public function notify(SubjectInterface $subject, IncidentInterface $incident) { if ($incident->getStatus() != IncidentInterface::STATUS_OK) { file_put_contents($this->getSubjectNotifyFilePath($subject), $incident->getMessage()); } }