public function createEvent(Request $request, $payload) { $newEvent = json_decode($payload); $issue = $newEvent->issue; $message = $issue->fields->summary; $project = $issue->fields->project->key; $jiraStatus = $issue->fields->status->name; $identifier = "jira_" . $issue->key; if (in_array($jiraStatus, $this->successStates)) { $status = Event::STATUS_SUCCESS; } else { $status = Event::STATUS_FAILURE; } $event = new RawEvent(); $event->setIdentifier($identifier); $event->setMessage($message); $event->setSystem($project); $event->setStatus($status); $parts = parse_url($issue->self); $url = $parts["scheme"] . "://" . $parts["host"] . "/browse/" . $newEvent->issue->key; $event->setUrl($url); $event->setUnique(true); $event->setType("jira"); return $event; }
public function createEvent(Request $request, $payload) { // @todo not sure if the clean process is needed anymore $cleanPayload = preg_replace("^\${(.*)}^", '""', $payload); $newEvent = json_decode($cleanPayload); $event = new RawEvent(); $identifier = "appDynamics_" . $newEvent->event->application->id . '_'; // appD . application . healthrule if ($newEvent->event->healthRuleEvent == "true") { $identifier .= $newEvent->event->healthRule->id; $event->setUnique(false); } else { $identifier .= $newEvent->event->incident->id; $event->setUnique(true); } $event->setIdentifier($identifier); $event->setMessage($newEvent->event->summaryMessage); if (in_array($newEvent->event->eventType, $this->successStatus)) { $event->setStatus(Event::STATUS_SUCCESS); } else { $event->setStatus(Event::STATUS_FAILURE); } $event->setSystem($this->translate($newEvent->event->application->name)); $event->setType("AppDynamics"); $event->setUrl($newEvent->event->deepLink); return $event; }
public function createEvent(Request $request, $payload) { $event = \json_decode($payload); $rawEvent = new RawEvent(); $rawEvent->setType('pingdom'); $rawEvent->setSystem($event->check_params->hostname); $rawEvent->setIdentifier('pingdom_' . $rawEvent->getSystem() . '_' . $event->check_name); $rawEvent->setUrl('https://my.pingdom.com/newchecks/checks#'); if ($event->current_state == self::STATE_FAILURE) { $rawEvent->setStatus(Event::STATUS_FAILURE); $rawEvent->setMessage('Error: ' . $event->long_description . ' (url: ' . $event->check_params->full_url . ')'); } else { $rawEvent->setStatus(Event::STATUS_SUCCESS); $rawEvent->setMessage(''); } return $rawEvent; }
public function createEvent(Request $request, $payload) { $newEvent = json_decode($request->get('payload')); $event = new RawEvent(); $system = $newEvent->repository->owner_name . ':' . $newEvent->repository->name . ':' . $newEvent->branch; if ($newEvent->result == self::STATUS_SUCCESS) { $event->setStatus(Event::STATUS_SUCCESS); $event->setMessage(""); } else { $event->setStatus(Event::STATUS_FAILURE); $event->setMessage("Building " . $system . " failed. Last commit by " . $newEvent->committer_name . '.'); } $event->setSystem($system); $event->setIdentifier('travis_' . $system); $event->setUrl($newEvent->build_url); $event->setType('travis'); return $event; }
protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine')->getManager(); $tools = $em->getRepository('KoalamonIncidentDashboardBundle:Tool')->findBy(["active" => true]); foreach ($tools as $tool) { if (!is_null($tool->getInterval()) && $tool->getInterval() != 0) { $eventIdentifier = $em->getRepository('KoalamonIncidentDashboardBundle:EventIdentifier')->findLastEventByTool($tool); if (is_null($eventIdentifier)) { continue; } $event = $eventIdentifier->getLastEvent(); $interval = $tool->getInterval() + 1; $now = new \DateTime(); $lastEventLimit = $now->sub(new \DateInterval("PT" . $interval . "M")); $rawEvent = new RawEvent(); $rawEvent->setIdentifier('koalamon_tool_intervalcheck_' . $tool->getIdentifier()); $rawEvent->setSystem('Koalamon'); $rawEvent->setType('koalamon_intervalcheck'); $rawEvent->setUnique(false); try { $created = $event->getCreated(); } catch (\Exception $e) { $output->writeln("<error>" . $e->getMessage() . "</error>"); $created = new \DateTime(); $created->sub(new \DateInterval("P30D")); } if ($created < $lastEventLimit) { $rawEvent->setStatus(Event::STATUS_FAILURE); $message = "The tool '" . $tool->getName() . "' with id='" . $tool->getId() . "' did not send any events since " . $created->format("d.m.Y H:i:m") . "."; $rawEvent->setMessage($message); $output->writeln("project_id: " . $tool->getProject()->getId() . " (" . $tool->getProject()->getName() . ") -- " . $message); } else { $rawEvent->setStatus(Event::STATUS_SUCCESS); $rawEvent->setMessage("The tool '" . $tool->getName() . "' with id='" . $tool->getId() . ' was triggered within the last ' . $interval . ' minutes.'); } try { $this->getContainer()->get('koalamon.project.helper')->addRawEvent($rawEvent, $tool->getProject()); } catch (\Exception $e) { $output->writeln('Exception: ' . $e->getMessage()); } } } }
public function createEvent(Request $request, $payload) { $event = \json_decode($payload); if ($event->state == 'completed') { $rawEvent = new RawEvent(); $rawEvent->setSystem($event->_embedded->repository->login . ':' . $event->_embedded->repository->name . ':' . $event->_embedded->head_index->branch_reference); $rawEvent->setValue($event->_embedded->head_index->_embedded->project->metric_values->{'scrutinizer.quality'}); $rawEvent->setIdentifier('scrutinizer:' . $rawEvent->getSystem()); $rawEvent->setType('scrutinizer'); $rawEvent->setUrl('https://scrutinizer-ci.com' . str_replace('api/repositories/', '', $event->_links->self->href)); if ($rawEvent->getValue() > $this->limit) { $rawEvent->setStatus(Event::STATUS_SUCCESS); $rawEvent->setMessage(''); } else { $rawEvent->setStatus(Event::STATUS_FAILURE); $rawEvent->setMessage('The scrutinizer quality index is too low (' . round($rawEvent->getValue(), 2) . ').'); } return $rawEvent; } return []; }
public function createEvent(Request $request, $payload) { $newEvent = json_decode(urldecode($payload)); if ($request->get('confirmationURL')) { $url = trim(preg_replace('/\\s\\s+/', ' ', $request->get('confirmationURL'))); $content = file_get_contents($url); return false; } if (!property_exists($newEvent, 'alert')) { return false; } $alert = $newEvent->alert; $event = new RawEvent(); $event->setType('monitis'); $system = str_replace('http://', '', $alert->url); $system = str_replace(' ', '', $system); $event->setSystem($system); if ($alert->alertType === self::STATUS_PROBLEM) { $event->setStatus(Event::STATUS_FAILURE); if (property_exists($alert, "errorString")) { $event->setMessage($alert->errorString); } else { $event->setMessage('Monitis found an error for ' . $alert->name . '.'); } } else { $event->setStatus(Event::STATUS_SUCCESS); $event->setMessage(""); } $event->setIdentifier("monitis_" . $system . "_" . $alert->type); $event->setUnique(false); $event->setUrl('http://dashboard.monitis.com/'); if (property_exists($alert, 'stepDuration')) { $event->setValue($alert->stepDuration); } return $event; }
public function createEvent(Request $request, $payload) { $newEvent = json_decode($payload); if ($newEvent->current_state == self::STATUS_SUCCESS) { $status = Event::STATUS_FAILURE; } else { $status = Event::STATUS_SUCCESS; } $event = new RawEvent(); $event->setStatus($status); $event->setIdentifier("newrelic_" . $newEvent->policy_name . "_" . $this->translate($newEvent->targets[0]->name)); $event->setMessage($newEvent->details); $event->setSystem($this->translate($newEvent->targets[0]->name)); $event->setUrl($newEvent->incident_url); $event->setType("newrelic"); $event->setUnique(true); return $event; }
public function onEventCreate(NewEventEvent $event) { $currentEvent = $event->getEvent(); $lastEvent = $event->getLastEvent(); if ($currentEvent->getType() == self::TOOL_IDENTIFIER) { return; } if (!is_null($lastEvent) && $currentEvent->getStatus() == $lastEvent->getStatus()) { return; } $system = $currentEvent->getEventIdentifier()->getSystem(); if (is_null($system)) { return; } $tool = $currentEvent->getEventIdentifier()->getTool(); $status = Event::STATUS_SUCCESS; $message = ''; if ($system->getThreshold() == 0 || $currentEvent->getStatus() == Event::STATUS_SUCCESS) { $healthStatus = max(0, $system->getHealthStatus() - $tool->getScore()); } else { $healthStatus = $system->getHealthStatus() + $tool->getScore(); if ($healthStatus >= $system->getThreshold()) { $status = Event::STATUS_FAILURE; $message = 'The health status of "' . $system->getName() . '" is critical.'; } } $system->setHealthStatus($healthStatus); $this->doctrineManager->persist($system); $this->doctrineManager->flush(); $rawEvent = new RawEvent(); $rawEvent->setSystem($system->getIdentifier()); $rawEvent->setType(self::TOOL_IDENTIFIER); $rawEvent->setUnique(false); $rawEvent->setValue($healthStatus); $rawEvent->setStatus($status); $rawEvent->setMessage($message); $rawEvent->setIdentifier(self::TOOL_IDENTIFIER . '_' . $system->getIdentifier()); $this->container->get('koalamon.project.helper')->addRawEvent($rawEvent, $currentEvent->getEventIdentifier()->getProject()); }
public function createEvent(Request $request, $payload) { $newEvent = json_decode($payload); $event = new RawEvent(); if ($newEvent->build->phase != self::PHASE_COMPLETED) { return []; } if ($newEvent->build->status == self::STATUS_SUCCESS) { $status = Event::STATUS_SUCCESS; $message = ""; } else { $status = Event::STATUS_FAILURE; $message = "Jenkins \"" . $newEvent->name . "\" failed"; } $event->setMessage($message); $event->setStatus($status); $event->setSystem($newEvent->name); $event->setIdentifier($newEvent->name); $event->setUrl($newEvent->build->full_url); $event->setType($event->getIdentifier()); return [$event]; }
public function createEvent(Request $request, $payload) { $newEvent = json_decode($payload); $event = new RawEvent(); $event->setIdentifier($newEvent->identifier); $event->setMessage($newEvent->message); $event->setStatus($newEvent->status); $event->setSystem($newEvent->system); if (property_exists($newEvent, "value")) { $event->setValue($newEvent->value); } if (property_exists($newEvent, "componentId")) { $event->setComponentId($newEvent->componentId); } if (property_exists($newEvent, "url")) { $event->setUrl($newEvent->url); } else { $event->setUrl(""); } if (property_exists($newEvent, "type")) { $event->setType($newEvent->type); } return $event; }
public function translate(RawEvent $event) { if (!is_null($this->getUrl())) { $event->setUrl($this->getUrl()); } if (!is_null($this->getType())) { $event->setType($this->getType()); } if (!is_null($this > $this->getSystem())) { $event->setSystem($this->getSystem()); } if (!is_null($this->getMessage())) { $event->setMessage($this->getMessage()); } return $event; }