public function beat($name)
 {
     //validate name is the right format
     $ping = Ping::findOrNewFromName($name);
     $ping->recordPingUpdate();
     return response('', 204);
 }
Esempio n. 2
0
 public function destroy(Request $request, $id)
 {
     Ping::findOrFail($id)->delete();
     if ($request->wantsJson()) {
         return 'OK';
     }
     return redirect('/cron');
 }
Esempio n. 3
0
 public function getUser()
 {
     $responseData = \Auth::user()->toArray();
     $responseData['pingBaseUrl'] = \App\Ping::baseUrl();
     $responseData['avatar'] = \Gravatar::get($responseData['email']);
     unset($responseData['id']);
     unset($responseData['updated_at']);
     return response($responseData, 200);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $results = [];
     $pings = Ping::active()->get();
     foreach ($pings as $ping) {
         /** @var Ping $ping */
         $results[] = [$ping->error, $ping->name, $ping->last_ping, $ping->frequency_value . ' ' . $ping->frequency, $ping->overdueDate, $ping->overdue];
         if ($ping->overdue) {
             $ping->setError();
         } else {
             $ping->clearError();
         }
     }
     $this->table(['error', 'name', 'last_ping', 'frequency', 'overdue_date', 'overdue'], $results);
 }
 /**
  * Handle the event.
  *
  * @param  PingFailure  $event
  * @return void
  */
 public function handle(PingFailure $event)
 {
     $ping = $event->ping;
     if ($ping instanceof ModelIdentifier) {
         $ping = Ping::findOrFail($ping->id);
     }
     /** @var Contact[] $contacts */
     $contacts = Contact::active()->get();
     foreach ($contacts as $contact) {
         if (!empty($contact->filter_tags)) {
             //contact has tags set, check for matches
             if (empty(array_intersect($contact->filter_tags, $ping->tags))) {
                 //no match
                 return;
             }
         }
         //contact the person
         Mail::queue(['text' => 'emails.ping-error'], ['ping' => $ping], function ($message) use($contact, $ping) {
             $message->subject("Nothing heard from ping " . $ping->name);
             $message->to($contact->email, $contact->name);
         });
     }
 }
Esempio n. 6
0
 /**
  * Create a new ping object with the default starting params
  *
  * @param string $name
  * @param bool   $active
  * @param null   $createdBy
  *
  * @return Ping
  */
 public static function createDefaultPing($name, $active, $createdBy = null)
 {
     $ping = new Ping();
     $ping->name = $name;
     if ($createdBy) {
         $ping->created_by = $createdBy;
     }
     $ping->active = $active;
     $ping->description = '';
     $ping->tags = [];
     $ping->error = false;
     $ping->frequency = 'day';
     $ping->frequency_value = '1';
     $ping->save();
     return $ping;
 }
Esempio n. 7
0
 /**
  * Display graph ping
  *
  * @param  int  $id
  * @return Response
  */
 public function graph_ping($id)
 {
     //
     $node = \App\Node::findOrFail($id);
     $pings = \App\Ping::where('node_id', $id)->orderBy('timestamp', 'desc')->paginate(10);
     return view('nodes.graph_ping', compact('node', 'pings'));
 }