public function domainSuffix()
 {
     $beat = new Heartbeat();
     $beat->setup('nagios://nagios.xp-framework.net:5667/servicename?hostname=client&domain=.xp-framework.net');
     $this->assertEquals('client.xp-framework.net', $beat->host);
     $beat->setup('nagios://nagios.xp-framework.net:5667/servicename?hostname=client&domain=xp-framework.net');
     $this->assertEquals('client.xp-framework.net', $beat->host);
 }
Example #2
0
 /**
  * Get instance of this class.
  *
  * @return  org.nagios.nsca.Heartbeat
  */
 public static function getInstance()
 {
     if (NULL === self::$instance) {
         self::$instance = new Heartbeat();
     }
     return self::$instance;
 }
 public function beat()
 {
     $data = Input::all();
     // return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_SUCCESS, $data['data']);
     if (is_null($data)) {
         return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_ERROR, array('item' => 'data'));
     }
     if (is_null($data['phone_imei'])) {
         return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_ERROR, array('item' => 'phone_imei'));
     }
     $heartbeat = new Heartbeat($data);
     $heartbeat->save();
     $device = Device::with(array('users' => function ($query) {
         $query->where('device_user.user_id', '=', Auth::user()->id);
     }, 'heartbeats' => function ($query) {
     }))->where('hardware_id', '=', $data['phone_imei'])->whereNull('deleted_at')->get();
     if (is_null($device)) {
         $device = new Device(array('name' => $data['phone_imei'], 'hardware_id' => $data['phone_imei']));
         $device->save();
     }
     $device->heartbeats()->attach($heartbeat);
     return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_SUCCESS, $device);
 }