@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public function history($from, $to) |
| 28 | 28 | { |
| 29 | - $logs = ResourceLog::where('created_at', '>=', $from.' 00:00:00') |
|
| 30 | - ->where('created_at', '<=', $to.' 23:59:59') |
|
| 29 | + $logs = ResourceLog::where('created_at', '>=', $from . ' 00:00:00') |
|
| 30 | + ->where('created_at', '<=', $to . ' 23:59:59') |
|
| 31 | 31 | ->select(DB::raw('date(created_at) as date'), 'resource') |
| 32 | 32 | ->get(); |
| 33 | 33 | |
| 34 | - $labels = []; |
|
| 34 | + $labels = [ ]; |
|
| 35 | 35 | foreach (CarbonPeriod::create($from, $to) as $date) { |
| 36 | 36 | array_push($labels, $date->format('Y-m-d')); |
| 37 | 37 | } |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | protected function resourceLogCount($resource, $labels, $logs) |
| 52 | 52 | { |
| 53 | - $logCount = []; |
|
| 53 | + $logCount = [ ]; |
|
| 54 | 54 | foreach ($labels as $label) { |
| 55 | - $resourceCount = $logs->countBy(function ($logs) use ($resource, $label) { |
|
| 56 | - return $logs['resource'] == $resource && $logs['date'] == $label; |
|
| 55 | + $resourceCount = $logs->countBy(function($logs) use ($resource, $label) { |
|
| 56 | + return $logs[ 'resource' ] == $resource && $logs[ 'date' ] == $label; |
|
| 57 | 57 | }); |
| 58 | - array_push($logCount, count($resourceCount) > 1 ? $resourceCount[1] : 0); |
|
| 58 | + array_push($logCount, count($resourceCount) > 1 ? $resourceCount[ 1 ] : 0); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $logCount; |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function handle() |
| 47 | 47 | { |
| 48 | - $logs = []; |
|
| 49 | - $logs['signature'] = $signature; |
|
| 48 | + $logs = [ ]; |
|
| 49 | + $logs[ 'signature' ] = $signature; |
|
| 50 | 50 | |
| 51 | 51 | $cpuUsage = $this->cpu->check(); |
| 52 | 52 | $memoryUsage = $this->memory->check(); |
@@ -55,28 +55,28 @@ discard block |
||
| 55 | 55 | $webServerStatuses = $this->webServer->check(); |
| 56 | 56 | |
| 57 | 57 | if (config('stethoscope.monitorable_resources.cpu') && $cpuUsage > config(('stethoscope.thresholds.cpu'))) { |
| 58 | - $logs['cpu'] = $cpuUsage; |
|
| 58 | + $logs[ 'cpu' ] = $cpuUsage; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | if ($memoryUsage > config(('stethoscope.thresholds.memory')) && config('stethoscope.monitorable_resources.memory')) { |
| 62 | - $logs['memory'] = $memoryUsage; |
|
| 62 | + $logs[ 'memory' ] = $memoryUsage; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | if ($networkStatus == 'disconnected' && config('stethoscope.monitorable_resources.network')) { |
| 66 | - $logs['network'] = $networkStatus; |
|
| 66 | + $logs[ 'network' ] = $networkStatus; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | if ($storageFreeSpace < config(('stethoscope.thresholds.storage')) && config('stethoscope.monitorable_resources.storage')) { |
| 70 | - $logs['storage'] = $storageFreeSpace; |
|
| 70 | + $logs[ 'storage' ] = $storageFreeSpace; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | if ($webServerStatuses != 'active' && config('stethoscope.monitorable_resources.web_server')) { |
| 74 | - $logs['webServer'] = $webServerStatuses; |
|
| 74 | + $logs[ 'webServer' ] = $webServerStatuses; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | Record::record($logs); |
| 78 | 78 | |
| 79 | - if (! empty($logs)) { |
|
| 79 | + if (!empty($logs)) { |
|
| 80 | 80 | TroubleOccurred::dispatch($logs); |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -44,14 +44,14 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | public function handle() |
| 46 | 46 | { |
| 47 | - $logs = []; |
|
| 48 | - |
|
| 49 | - $logs['signature'] = $this->signature; |
|
| 50 | - $logs['cpu'] = $this->cpu->check(); |
|
| 51 | - $logs['memory'] = $this->memory->check(); |
|
| 52 | - $logs['network'] = $this->network->check(); |
|
| 53 | - $logs['storage'] = $this->storage->check(); |
|
| 54 | - $logs['webServer'] = $this->webServer->check(); |
|
| 47 | + $logs = [ ]; |
|
| 48 | + |
|
| 49 | + $logs[ 'signature' ] = $this->signature; |
|
| 50 | + $logs[ 'cpu' ] = $this->cpu->check(); |
|
| 51 | + $logs[ 'memory' ] = $this->memory->check(); |
|
| 52 | + $logs[ 'network' ] = $this->network->check(); |
|
| 53 | + $logs[ 'storage' ] = $this->storage->check(); |
|
| 54 | + $logs[ 'webServer' ] = $this->webServer->check(); |
|
| 55 | 55 | |
| 56 | 56 | TroubleOccurred::dispatch($logs); |
| 57 | 57 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | { |
| 7 | 7 | public function handle($logs) |
| 8 | 8 | { |
| 9 | - if (! is_null(config('stethoscope.notifications.notifiable'))) { |
|
| 9 | + if (!is_null(config('stethoscope.notifications.notifiable'))) { |
|
| 10 | 10 | $notifiable = app(config('stethoscope.notifications.notifiable')); |
| 11 | 11 | |
| 12 | 12 | $notificationClass = $this->detemineNotificationClass(); |
@@ -21,6 +21,6 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | $notifications = config('stethoscope.notifications.notifications'); |
| 23 | 23 | |
| 24 | - return array_keys($notifications)[0]; |
|
| 24 | + return array_keys($notifications)[ 0 ]; |
|
| 25 | 25 | } |
| 26 | 26 | } |
@@ -19,23 +19,23 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function record($logs) |
| 21 | 21 | { |
| 22 | - $file = config('stethoscope.log_file_storage.path').now()->format('Y-m-d'); |
|
| 22 | + $file = config('stethoscope.log_file_storage.path') . now()->format('Y-m-d'); |
|
| 23 | 23 | |
| 24 | 24 | $log = ''; |
| 25 | 25 | |
| 26 | 26 | foreach ($logs as $resource => $report) { |
| 27 | - $method = $resource.'Message'; |
|
| 27 | + $method = $resource . 'Message'; |
|
| 28 | 28 | |
| 29 | 29 | if (method_exists($this, $method)) { |
| 30 | - $log .= $this->$method($report)."\n"; |
|
| 30 | + $log .= $this->$method($report) . "\n"; |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | if ($log != '') { |
| 35 | - $log = $this->timeMessage()."\n".$log; |
|
| 35 | + $log = $this->timeMessage() . "\n" . $log; |
|
| 36 | 36 | |
| 37 | 37 | if ($this->storage->exists($file)) { |
| 38 | - $log = $this->storage->get($file)."\n \n".$log; |
|
| 38 | + $log = $this->storage->get($file) . "\n \n" . $log; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $this->storage->put($file, $log); |