repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
eyewitness/eye
app/Notifications/Messages/Queue/FailedCountOk.php
FailedCountOk.meta
public function meta() { return [ 'Connection' => e($this->meta['queue']->connection), 'Queue' => e($this->meta['queue']->tube), 'Driver' => e($this->meta['queue']->driver), 'Your threshold' => e($this->meta['queue']->alert_failed_jobs_greater_than), 'Actual failed job count' => e($this->meta['failed_job_count']), ]; }
php
public function meta() { return [ 'Connection' => e($this->meta['queue']->connection), 'Queue' => e($this->meta['queue']->tube), 'Driver' => e($this->meta['queue']->driver), 'Your threshold' => e($this->meta['queue']->alert_failed_jobs_greater_than), 'Actual failed job count' => e($this->meta['failed_job_count']), ]; }
[ "public", "function", "meta", "(", ")", "{", "return", "[", "'Connection'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'queue'", "]", "->", "connection", ")", ",", "'Queue'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'queue'", "]", "->...
Any meta information for the message. @return array
[ "Any", "meta", "information", "for", "the", "message", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Messages/Queue/FailedCountOk.php#L44-L53
eyewitness/eye
app/Commands/RegenerateCommand.php
RegenerateCommand.handle
public function handle() { if (! $this->option('force') && ! $this->confirmRegenerate()) { return $this->info('Aborted. No changes were made. If you need assistance please contact us anytime at: support@eyewitness.io'); } $app_token = $this->generateRandom(16); $secret_key = $this->generateRandom(32); $this->modifyEnvironmentFile('EYEWITNESS_APP_TOKEN', 'app_token', $app_token); $this->modifyEnvironmentFile('EYEWITNESS_SECRET_KEY', 'secret_key', $secret_key); $this->modifyEnvironmentFile('EYEWITNESS_SUBSCRIPTION_KEY', 'subscription_key', null); $this->laravel['config']['eyewitness.app_token'] = $app_token; $this->laravel['config']['eyewitness.secret_key'] = $secret_key; $this->laravel['config']['eyewitness.subscription_key'] = null; $this->displayOutcome(); $this->checkCaching(); }
php
public function handle() { if (! $this->option('force') && ! $this->confirmRegenerate()) { return $this->info('Aborted. No changes were made. If you need assistance please contact us anytime at: support@eyewitness.io'); } $app_token = $this->generateRandom(16); $secret_key = $this->generateRandom(32); $this->modifyEnvironmentFile('EYEWITNESS_APP_TOKEN', 'app_token', $app_token); $this->modifyEnvironmentFile('EYEWITNESS_SECRET_KEY', 'secret_key', $secret_key); $this->modifyEnvironmentFile('EYEWITNESS_SUBSCRIPTION_KEY', 'subscription_key', null); $this->laravel['config']['eyewitness.app_token'] = $app_token; $this->laravel['config']['eyewitness.secret_key'] = $secret_key; $this->laravel['config']['eyewitness.subscription_key'] = null; $this->displayOutcome(); $this->checkCaching(); }
[ "public", "function", "handle", "(", ")", "{", "if", "(", "!", "$", "this", "->", "option", "(", "'force'", ")", "&&", "!", "$", "this", "->", "confirmRegenerate", "(", ")", ")", "{", "return", "$", "this", "->", "info", "(", "'Aborted. No changes were...
Set the application token and the secret key in the config file. @return mixed
[ "Set", "the", "application", "token", "and", "the", "secret", "key", "in", "the", "config", "file", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/RegenerateCommand.php#L35-L54
eyewitness/eye
app/Commands/RegenerateCommand.php
RegenerateCommand.modifyEnvironmentFile
protected function modifyEnvironmentFile($param, $type, $value) { if ($this->paramAlreadyInFile($param, $type)) { $this->overwriteExistingParamToFile($param, $type, $value); } else { $this->addNewParamToFile($param, $value); } }
php
protected function modifyEnvironmentFile($param, $type, $value) { if ($this->paramAlreadyInFile($param, $type)) { $this->overwriteExistingParamToFile($param, $type, $value); } else { $this->addNewParamToFile($param, $value); } }
[ "protected", "function", "modifyEnvironmentFile", "(", "$", "param", ",", "$", "type", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "paramAlreadyInFile", "(", "$", "param", ",", "$", "type", ")", ")", "{", "$", "this", "->", "overwriteExi...
Update the application environment file with the new config. @param string $param @param string $type @param string $value @return void
[ "Update", "the", "application", "environment", "file", "with", "the", "new", "config", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/RegenerateCommand.php#L64-L71
eyewitness/eye
app/Commands/RegenerateCommand.php
RegenerateCommand.paramAlreadyInFile
protected function paramAlreadyInFile($param, $type) { return preg_match($this->replacementPattern($param, $type), $this->getEnvFile()); }
php
protected function paramAlreadyInFile($param, $type) { return preg_match($this->replacementPattern($param, $type), $this->getEnvFile()); }
[ "protected", "function", "paramAlreadyInFile", "(", "$", "param", ",", "$", "type", ")", "{", "return", "preg_match", "(", "$", "this", "->", "replacementPattern", "(", "$", "param", ",", "$", "type", ")", ",", "$", "this", "->", "getEnvFile", "(", ")", ...
Check if the current .env file already has the param. @param string $param @param string $type @return bool
[ "Check", "if", "the", "current", ".", "env", "file", "already", "has", "the", "param", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/RegenerateCommand.php#L80-L83
eyewitness/eye
app/Commands/RegenerateCommand.php
RegenerateCommand.overwriteExistingParamToFile
protected function overwriteExistingParamToFile($param, $type, $value) { $this->writeEnvFile(preg_replace( $this->replacementPattern($param, $type), $param.'='.$value, $this->getEnvFile() )); }
php
protected function overwriteExistingParamToFile($param, $type, $value) { $this->writeEnvFile(preg_replace( $this->replacementPattern($param, $type), $param.'='.$value, $this->getEnvFile() )); }
[ "protected", "function", "overwriteExistingParamToFile", "(", "$", "param", ",", "$", "type", ",", "$", "value", ")", "{", "$", "this", "->", "writeEnvFile", "(", "preg_replace", "(", "$", "this", "->", "replacementPattern", "(", "$", "param", ",", "$", "t...
Check if the current .env file already has the param. @param string $param @param string $type @param string $value @return void
[ "Check", "if", "the", "current", ".", "env", "file", "already", "has", "the", "param", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/RegenerateCommand.php#L93-L100
eyewitness/eye
app/Commands/RegenerateCommand.php
RegenerateCommand.addNewParamToFile
protected function addNewParamToFile($param, $value) { $this->writeEnvFile($this->getEnvFile().PHP_EOL.$param.'='.$value); }
php
protected function addNewParamToFile($param, $value) { $this->writeEnvFile($this->getEnvFile().PHP_EOL.$param.'='.$value); }
[ "protected", "function", "addNewParamToFile", "(", "$", "param", ",", "$", "value", ")", "{", "$", "this", "->", "writeEnvFile", "(", "$", "this", "->", "getEnvFile", "(", ")", ".", "PHP_EOL", ".", "$", "param", ".", "'='", ".", "$", "value", ")", ";...
Check if the current .env file already has the param. @param string $param @param string $value @return void
[ "Check", "if", "the", "current", ".", "env", "file", "already", "has", "the", "param", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/RegenerateCommand.php#L109-L112
eyewitness/eye
app/Commands/RegenerateCommand.php
RegenerateCommand.checkCaching
protected function checkCaching() { if (app()->routesAreCached() && app()->configurationIsCached()) { $this->info('p.s. you need to run "config:cache" + "route:cache" + "queue:restart" to ensure your application updates and queue monitoring works correctly.'); } elseif (app()->configurationIsCached()) { $this->info('p.s. you need to run "config:cache" + "queue:restart" to ensure your application updates and queue monitoring works correctly.'); } elseif (app()->routesAreCached()) { $this->info('p.s. you need to run "route:cache" + "queue:restart" to ensure your application updates and queue monitoring works correctly.'); } else { $this->info('p.s. you need to run "queue:restart" to ensure your queue monitoring works correctly.'); } $this->info(' '); }
php
protected function checkCaching() { if (app()->routesAreCached() && app()->configurationIsCached()) { $this->info('p.s. you need to run "config:cache" + "route:cache" + "queue:restart" to ensure your application updates and queue monitoring works correctly.'); } elseif (app()->configurationIsCached()) { $this->info('p.s. you need to run "config:cache" + "queue:restart" to ensure your application updates and queue monitoring works correctly.'); } elseif (app()->routesAreCached()) { $this->info('p.s. you need to run "route:cache" + "queue:restart" to ensure your application updates and queue monitoring works correctly.'); } else { $this->info('p.s. you need to run "queue:restart" to ensure your queue monitoring works correctly.'); } $this->info(' '); }
[ "protected", "function", "checkCaching", "(", ")", "{", "if", "(", "app", "(", ")", "->", "routesAreCached", "(", ")", "&&", "app", "(", ")", "->", "configurationIsCached", "(", ")", ")", "{", "$", "this", "->", "info", "(", "'p.s. you need to run \"config...
Check if any caching has occured. @return void
[ "Check", "if", "any", "caching", "has", "occured", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/RegenerateCommand.php#L154-L167
eyewitness/eye
app/Commands/RegenerateCommand.php
RegenerateCommand.writeEnvFile
public function writeEnvFile($string) { file_put_contents($this->laravel->environmentPath().'/'.$this->laravel->environmentFile(), $string); }
php
public function writeEnvFile($string) { file_put_contents($this->laravel->environmentPath().'/'.$this->laravel->environmentFile(), $string); }
[ "public", "function", "writeEnvFile", "(", "$", "string", ")", "{", "file_put_contents", "(", "$", "this", "->", "laravel", "->", "environmentPath", "(", ")", ".", "'/'", ".", "$", "this", "->", "laravel", "->", "environmentFile", "(", ")", ",", "$", "st...
Get the env file contents. @param string $string @return void
[ "Get", "the", "env", "file", "contents", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/RegenerateCommand.php#L199-L202
eyewitness/eye
app/Eye.php
Eye.getConfig
public function getConfig() { $data['eyewitness_version'] = $this->version(); $data['eyewitness_config'] = config('eyewitness'); $data['application_debug'] = config('app.debug'); $data['application_environment'] = app()->environment(); return $data; }
php
public function getConfig() { $data['eyewitness_version'] = $this->version(); $data['eyewitness_config'] = config('eyewitness'); $data['application_debug'] = config('app.debug'); $data['application_environment'] = app()->environment(); return $data; }
[ "public", "function", "getConfig", "(", ")", "{", "$", "data", "[", "'eyewitness_version'", "]", "=", "$", "this", "->", "version", "(", ")", ";", "$", "data", "[", "'eyewitness_config'", "]", "=", "config", "(", "'eyewitness'", ")", ";", "$", "data", ...
Get current configuration. @return array
[ "Get", "current", "configuration", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L187-L195
eyewitness/eye
app/Eye.php
Eye.getCustomWitnesses
public function getCustomWitnesses($filterIsDue = false) { $list = collect(); foreach (config('eyewitness.custom_witnesses', []) as $witness) { if ($this->isValidWitness($witness)) { $instance = app($witness); if ($filterIsDue) { if ($instance->isDue()) { $list->push($instance); } } else { $list->push($instance); } } } return $list; }
php
public function getCustomWitnesses($filterIsDue = false) { $list = collect(); foreach (config('eyewitness.custom_witnesses', []) as $witness) { if ($this->isValidWitness($witness)) { $instance = app($witness); if ($filterIsDue) { if ($instance->isDue()) { $list->push($instance); } } else { $list->push($instance); } } } return $list; }
[ "public", "function", "getCustomWitnesses", "(", "$", "filterIsDue", "=", "false", ")", "{", "$", "list", "=", "collect", "(", ")", ";", "foreach", "(", "config", "(", "'eyewitness.custom_witnesses'", ",", "[", "]", ")", "as", "$", "witness", ")", "{", "...
Load all custom witnesses and optionally filter if they are due to run. @param bool $filterIsDue @return \Illuminate\Support\Collection
[ "Load", "all", "custom", "witnesses", "and", "optionally", "filter", "if", "they", "are", "due", "to", "run", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L203-L221
eyewitness/eye
app/Eye.php
Eye.application
public function application() { if (is_null($this->application)) { $this->application = app(Application::class); } return $this->application; }
php
public function application() { if (is_null($this->application)) { $this->application = app(Application::class); } return $this->application; }
[ "public", "function", "application", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "application", ")", ")", "{", "$", "this", "->", "application", "=", "app", "(", "Application", "::", "class", ")", ";", "}", "return", "$", "this", "->...
Return the Application instance. @return \Eyewitness\Eye\Monitors\Application
[ "Return", "the", "Application", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L228-L235
eyewitness/eye
app/Eye.php
Eye.scheduler
public function scheduler() { if (is_null($this->scheduler)) { $this->scheduler = app(Scheduler::class); } return $this->scheduler; }
php
public function scheduler() { if (is_null($this->scheduler)) { $this->scheduler = app(Scheduler::class); } return $this->scheduler; }
[ "public", "function", "scheduler", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "scheduler", ")", ")", "{", "$", "this", "->", "scheduler", "=", "app", "(", "Scheduler", "::", "class", ")", ";", "}", "return", "$", "this", "->", "sc...
Return the Scheduler instance. @return \Eyewitness\Eye\Monitors\Scheduler
[ "Return", "the", "Scheduler", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L242-L249
eyewitness/eye
app/Eye.php
Eye.database
public function database() { if (is_null($this->database)) { $this->database = app(Database::class); } return $this->database; }
php
public function database() { if (is_null($this->database)) { $this->database = app(Database::class); } return $this->database; }
[ "public", "function", "database", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "database", ")", ")", "{", "$", "this", "->", "database", "=", "app", "(", "Database", "::", "class", ")", ";", "}", "return", "$", "this", "->", "databa...
Return the Database instance. @return \Eyewitness\Eye\Monitors\Database
[ "Return", "the", "Database", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L256-L263
eyewitness/eye
app/Eye.php
Eye.composer
public function composer() { if (is_null($this->composer)) { $this->composer = app(Composer::class); } return $this->composer; }
php
public function composer() { if (is_null($this->composer)) { $this->composer = app(Composer::class); } return $this->composer; }
[ "public", "function", "composer", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "composer", ")", ")", "{", "$", "this", "->", "composer", "=", "app", "(", "Composer", "::", "class", ")", ";", "}", "return", "$", "this", "->", "compos...
Return the Composer instance. @return \Eyewitness\Eye\Monitors\Composer
[ "Return", "the", "Composer", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L270-L277
eyewitness/eye
app/Eye.php
Eye.notifier
public function notifier() { if (is_null($this->notifier)) { $this->notifier = app(Notifier::class); } return $this->notifier; }
php
public function notifier() { if (is_null($this->notifier)) { $this->notifier = app(Notifier::class); } return $this->notifier; }
[ "public", "function", "notifier", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "notifier", ")", ")", "{", "$", "this", "->", "notifier", "=", "app", "(", "Notifier", "::", "class", ")", ";", "}", "return", "$", "this", "->", "notifi...
Return the Notifier instance. @return \Eyewitness\Eye\Notifications\Notifier
[ "Return", "the", "Notifier", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L284-L291
eyewitness/eye
app/Eye.php
Eye.status
public function status() { if (is_null($this->status)) { $this->status = app(Status::class); } return $this->status; }
php
public function status() { if (is_null($this->status)) { $this->status = app(Status::class); } return $this->status; }
[ "public", "function", "status", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "status", ")", ")", "{", "$", "this", "->", "status", "=", "app", "(", "Status", "::", "class", ")", ";", "}", "return", "$", "this", "->", "status", ";"...
Return the Eyewitness status instance. @return \Eyewitness\Eye\Status
[ "Return", "the", "Eyewitness", "status", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L298-L305
eyewitness/eye
app/Eye.php
Eye.logger
public function logger() { if (is_null($this->logger)) { $this->logger = app(Logger::class); } return $this->logger; }
php
public function logger() { if (is_null($this->logger)) { $this->logger = app(Logger::class); } return $this->logger; }
[ "public", "function", "logger", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "logger", ")", ")", "{", "$", "this", "->", "logger", "=", "app", "(", "Logger", "::", "class", ")", ";", "}", "return", "$", "this", "->", "logger", ";"...
Return the Eyewitness logger instance. @return \Eyewitness\Eye\Log
[ "Return", "the", "Eyewitness", "logger", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L312-L319
eyewitness/eye
app/Eye.php
Eye.server
public function server() { if (is_null($this->server)) { $this->server = app(Server::class); } return $this->server; }
php
public function server() { if (is_null($this->server)) { $this->server = app(Server::class); } return $this->server; }
[ "public", "function", "server", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "server", ")", ")", "{", "$", "this", "->", "server", "=", "app", "(", "Server", "::", "class", ")", ";", "}", "return", "$", "this", "->", "server", ";"...
Return the Server instance. @return \Eyewitness\Eye\Monitors\Server
[ "Return", "the", "Server", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L326-L333
eyewitness/eye
app/Eye.php
Eye.debug
public function debug() { if (is_null($this->debug)) { $this->debug = app(Debug::class); } return $this->debug; }
php
public function debug() { if (is_null($this->debug)) { $this->debug = app(Debug::class); } return $this->debug; }
[ "public", "function", "debug", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "debug", ")", ")", "{", "$", "this", "->", "debug", "=", "app", "(", "Debug", "::", "class", ")", ";", "}", "return", "$", "this", "->", "debug", ";", "...
Return the Debug instance. @return \Eyewitness\Eye\Monitors\Debug
[ "Return", "the", "Debug", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L340-L347
eyewitness/eye
app/Eye.php
Eye.queue
public function queue() { if (is_null($this->queue)) { $this->queue = app(Queue::class); } return $this->queue; }
php
public function queue() { if (is_null($this->queue)) { $this->queue = app(Queue::class); } return $this->queue; }
[ "public", "function", "queue", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "queue", ")", ")", "{", "$", "this", "->", "queue", "=", "app", "(", "Queue", "::", "class", ")", ";", "}", "return", "$", "this", "->", "queue", ";", "...
Return the Queue instance. @return \Eyewitness\Eye\Monitors\Queue
[ "Return", "the", "Queue", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L354-L361
eyewitness/eye
app/Eye.php
Eye.disk
public function disk() { if (is_null($this->disk)) { $this->disk = app(Disk::class); } return $this->disk; }
php
public function disk() { if (is_null($this->disk)) { $this->disk = app(Disk::class); } return $this->disk; }
[ "public", "function", "disk", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "disk", ")", ")", "{", "$", "this", "->", "disk", "=", "app", "(", "Disk", "::", "class", ")", ";", "}", "return", "$", "this", "->", "disk", ";", "}" ]
Return the Disk instance. @return \Eyewitness\Eye\Monitors\Disk
[ "Return", "the", "Disk", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L368-L375
eyewitness/eye
app/Eye.php
Eye.dns
public function dns() { if (is_null($this->dns)) { $this->dns = app(Dns::class); } return $this->dns; }
php
public function dns() { if (is_null($this->dns)) { $this->dns = app(Dns::class); } return $this->dns; }
[ "public", "function", "dns", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "dns", ")", ")", "{", "$", "this", "->", "dns", "=", "app", "(", "Dns", "::", "class", ")", ";", "}", "return", "$", "this", "->", "dns", ";", "}" ]
Return the Dns instance. @return \Eyewitness\Eye\Monitors\Dns
[ "Return", "the", "Dns", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L382-L389
eyewitness/eye
app/Eye.php
Eye.ssl
public function ssl() { if (is_null($this->ssl)) { $this->ssl = app(Ssl::class); } return $this->ssl; }
php
public function ssl() { if (is_null($this->ssl)) { $this->ssl = app(Ssl::class); } return $this->ssl; }
[ "public", "function", "ssl", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "ssl", ")", ")", "{", "$", "this", "->", "ssl", "=", "app", "(", "Ssl", "::", "class", ")", ";", "}", "return", "$", "this", "->", "ssl", ";", "}" ]
Return the Ssl instance. @return \Eyewitness\Eye\Monitors\Ssl
[ "Return", "the", "Ssl", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L396-L403
eyewitness/eye
app/Eye.php
Eye.log
public function log() { if (is_null($this->log)) { $this->log = app(Log::class); } return $this->log; }
php
public function log() { if (is_null($this->log)) { $this->log = app(Log::class); } return $this->log; }
[ "public", "function", "log", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "log", ")", ")", "{", "$", "this", "->", "log", "=", "app", "(", "Log", "::", "class", ")", ";", "}", "return", "$", "this", "->", "log", ";", "}" ]
Return the Log instance. @return \Eyewitness\Eye\Monitors\Log
[ "Return", "the", "Log", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L410-L417
eyewitness/eye
app/Eye.php
Eye.api
public function api() { if (is_null($this->api)) { $this->api = app(Api::class); } return $this->api; }
php
public function api() { if (is_null($this->api)) { $this->api = app(Api::class); } return $this->api; }
[ "public", "function", "api", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "api", ")", ")", "{", "$", "this", "->", "api", "=", "app", "(", "Api", "::", "class", ")", ";", "}", "return", "$", "this", "->", "api", ";", "}" ]
Return the Api instance. @return \Eyewitness\Eye\Api
[ "Return", "the", "Api", "instance", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L424-L431
eyewitness/eye
app/Eye.php
Eye.laravelVersionIs
public static function laravelVersionIs($operator, $version, $laravel = null) { if (is_null($laravel)) { $laravel = app()->version(); } $laravel = strtok($laravel, ' '); return version_compare($laravel, $version, $operator); }
php
public static function laravelVersionIs($operator, $version, $laravel = null) { if (is_null($laravel)) { $laravel = app()->version(); } $laravel = strtok($laravel, ' '); return version_compare($laravel, $version, $operator); }
[ "public", "static", "function", "laravelVersionIs", "(", "$", "operator", ",", "$", "version", ",", "$", "laravel", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "laravel", ")", ")", "{", "$", "laravel", "=", "app", "(", ")", "->", "version"...
Compare Laravel 5.x version to the variable given. @param double $version @return boolean
[ "Compare", "Laravel", "5", ".", "x", "version", "to", "the", "variable", "given", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Eye.php#L451-L460
eyewitness/eye
app/Monitors/Ssl.php
Ssl.poll
public function poll() { if (! count(config('eyewitness.application_domains'))) { $this->eye->logger()->debug('No application domain set for SSL monitor'); return; } foreach (config('eyewitness.application_domains') as $domain) { if ($this->isValidDomain($domain)) { $this->startScan($domain); } } }
php
public function poll() { if (! count(config('eyewitness.application_domains'))) { $this->eye->logger()->debug('No application domain set for SSL monitor'); return; } foreach (config('eyewitness.application_domains') as $domain) { if ($this->isValidDomain($domain)) { $this->startScan($domain); } } }
[ "public", "function", "poll", "(", ")", "{", "if", "(", "!", "count", "(", "config", "(", "'eyewitness.application_domains'", ")", ")", ")", "{", "$", "this", "->", "eye", "->", "logger", "(", ")", "->", "debug", "(", "'No application domain set for SSL moni...
Poll the SSL for its checks. @return void
[ "Poll", "the", "SSL", "for", "its", "checks", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Ssl.php#L20-L32
eyewitness/eye
app/Monitors/Ssl.php
Ssl.result
public function result() { if (! count(config('eyewitness.application_domains'))) { $this->eye->logger()->debug('No application domain set for SSL monitor'); return; } foreach (config('eyewitness.application_domains') as $domain) { $result = $this->getResults($domain); if ($result) { $this->checkForSslRecordChanges($domain, $result); $this->saveSslRecord($domain, $result); } } }
php
public function result() { if (! count(config('eyewitness.application_domains'))) { $this->eye->logger()->debug('No application domain set for SSL monitor'); return; } foreach (config('eyewitness.application_domains') as $domain) { $result = $this->getResults($domain); if ($result) { $this->checkForSslRecordChanges($domain, $result); $this->saveSslRecord($domain, $result); } } }
[ "public", "function", "result", "(", ")", "{", "if", "(", "!", "count", "(", "config", "(", "'eyewitness.application_domains'", ")", ")", ")", "{", "$", "this", "->", "eye", "->", "logger", "(", ")", "->", "debug", "(", "'No application domain set for SSL mo...
Determine the SSL scan results. @return void
[ "Determine", "the", "SSL", "scan", "results", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Ssl.php#L39-L54
eyewitness/eye
app/Monitors/Ssl.php
Ssl.startScan
protected function startScan($domain) { $result = $this->eye->api()->sslStart($domain); if (isset($result['multiple_ips']) && isset($result['token'])) { $result = $this->eye->api()->sslStart($domain, $result['multiple_ips'], $result['token']); } if (isset($result['error'])) { return $this->eye->logger()->error('SSL API scan error', $result['error'], $domain); } if (($result['status_id'] == "1") && (isset($result['job_id']))) { Cache::put('eyewitness_ssl_job_id_'.$domain, $result['job_id'], 50); } else { $this->eye->logger()->error('SSL API invalid result', print_r($result, true), $domain); } }
php
protected function startScan($domain) { $result = $this->eye->api()->sslStart($domain); if (isset($result['multiple_ips']) && isset($result['token'])) { $result = $this->eye->api()->sslStart($domain, $result['multiple_ips'], $result['token']); } if (isset($result['error'])) { return $this->eye->logger()->error('SSL API scan error', $result['error'], $domain); } if (($result['status_id'] == "1") && (isset($result['job_id']))) { Cache::put('eyewitness_ssl_job_id_'.$domain, $result['job_id'], 50); } else { $this->eye->logger()->error('SSL API invalid result', print_r($result, true), $domain); } }
[ "protected", "function", "startScan", "(", "$", "domain", ")", "{", "$", "result", "=", "$", "this", "->", "eye", "->", "api", "(", ")", "->", "sslStart", "(", "$", "domain", ")", ";", "if", "(", "isset", "(", "$", "result", "[", "'multiple_ips'", ...
Start the scan for a given domain for a valid SSL certificate against the API. @param string $domain @return void
[ "Start", "the", "scan", "for", "a", "given", "domain", "for", "a", "valid", "SSL", "certificate", "against", "the", "API", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Ssl.php#L62-L79
eyewitness/eye
app/Monitors/Ssl.php
Ssl.getResults
protected function getResults($domain) { if (! Cache::has('eyewitness_ssl_job_id_'.$domain)) { return null; } $result = $this->eye->api()->sslResult(Cache::pull('eyewitness_ssl_job_id_'.$domain)); if (isset($result['error'])) { return $this->eye->logger()->error('SSL API result error', $result['error'], $domain); } return $result; }
php
protected function getResults($domain) { if (! Cache::has('eyewitness_ssl_job_id_'.$domain)) { return null; } $result = $this->eye->api()->sslResult(Cache::pull('eyewitness_ssl_job_id_'.$domain)); if (isset($result['error'])) { return $this->eye->logger()->error('SSL API result error', $result['error'], $domain); } return $result; }
[ "protected", "function", "getResults", "(", "$", "domain", ")", "{", "if", "(", "!", "Cache", "::", "has", "(", "'eyewitness_ssl_job_id_'", ".", "$", "domain", ")", ")", "{", "return", "null", ";", "}", "$", "result", "=", "$", "this", "->", "eye", "...
Get the scan results from the API. @param string $domain @return array|null
[ "Get", "the", "scan", "results", "from", "the", "API", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Ssl.php#L87-L100
eyewitness/eye
app/Monitors/Ssl.php
Ssl.checkForSslRecordChanges
protected function checkForSslRecordChanges($domain, $result) { if (! $ssl_history = History::where('meta', $domain)->first()) { return; } if ($ssl_history->record['valid'] !== $result['certificates']['information'][0]['valid_now']) { if (! $result['certificates']['information'][0]['valid_now']) { $this->eye->status()->setSick('ssl_'.$domain); return $this->eye->notifier()->alert(new Invalid(['domain' => $domain])); } } if ($ssl_history->record['revoked'] !== $result['certificates']['information'][0]['revoked']) { if ($result['certificates']['information'][0]['revoked']) { $this->eye->status()->setSick('ssl_'.$domain); return $this->eye->notifier()->alert(new Revoked(['domain' => $domain])); } } if ($ssl_history->record['expires_soon'] !== $result['certificates']['information'][0]['expires_soon']) { if ($result['certificates']['information'][0]['expires_soon']) { $this->eye->status()->setSick('ssl_'.$domain); return $this->eye->notifier()->alert(new Expiring(['domain' => $domain, 'valid_to' => $result['certificates']['information'][0]['valid_to']])); } } if ($ssl_history->record['grade'] !== $result['results']['grade']) { return $this->eye->notifier()->alert(new GradeChange(['domain' => $domain, 'old_grade' => $ssl_history->record['grade'], 'new_grade' => $result['results']['grade']])); } $this->eye->status()->setHealthy('ssl_'.$domain); }
php
protected function checkForSslRecordChanges($domain, $result) { if (! $ssl_history = History::where('meta', $domain)->first()) { return; } if ($ssl_history->record['valid'] !== $result['certificates']['information'][0]['valid_now']) { if (! $result['certificates']['information'][0]['valid_now']) { $this->eye->status()->setSick('ssl_'.$domain); return $this->eye->notifier()->alert(new Invalid(['domain' => $domain])); } } if ($ssl_history->record['revoked'] !== $result['certificates']['information'][0]['revoked']) { if ($result['certificates']['information'][0]['revoked']) { $this->eye->status()->setSick('ssl_'.$domain); return $this->eye->notifier()->alert(new Revoked(['domain' => $domain])); } } if ($ssl_history->record['expires_soon'] !== $result['certificates']['information'][0]['expires_soon']) { if ($result['certificates']['information'][0]['expires_soon']) { $this->eye->status()->setSick('ssl_'.$domain); return $this->eye->notifier()->alert(new Expiring(['domain' => $domain, 'valid_to' => $result['certificates']['information'][0]['valid_to']])); } } if ($ssl_history->record['grade'] !== $result['results']['grade']) { return $this->eye->notifier()->alert(new GradeChange(['domain' => $domain, 'old_grade' => $ssl_history->record['grade'], 'new_grade' => $result['results']['grade']])); } $this->eye->status()->setHealthy('ssl_'.$domain); }
[ "protected", "function", "checkForSslRecordChanges", "(", "$", "domain", ",", "$", "result", ")", "{", "if", "(", "!", "$", "ssl_history", "=", "History", "::", "where", "(", "'meta'", ",", "$", "domain", ")", "->", "first", "(", ")", ")", "{", "return...
Check if the supplied result is different from the most recently stored SSL record available. @param string $domain @param array $result @return void
[ "Check", "if", "the", "supplied", "result", "is", "different", "from", "the", "most", "recently", "stored", "SSL", "record", "available", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Ssl.php#L110-L145
eyewitness/eye
app/Monitors/Ssl.php
Ssl.saveSslRecord
protected function saveSslRecord($domain, $result) { $record['grade'] = $result['results']['grade']; $record['results_url'] = 'https://www.htbridge.com/ssl/?id=' . $result['internals']['short_id']; if (isset($result['certificates']['information'][0])) { $record['valid'] = $result['certificates']['information'][0]['valid_now']; $record['valid_from'] = $result['certificates']['information'][0]['valid_from']; $record['valid_to'] = $result['certificates']['information'][0]['valid_to']; $record['revoked'] = $result['certificates']['information'][0]['revoked']; $record['expires_soon'] = $result['certificates']['information'][0]['expires_soon']; $record['issuer'] = $result['certificates']['information'][0]['issuer_cn']; } try { History::where('meta', $domain)->delete(); History::create(['type' => 'ssl', 'meta' => $domain, 'record' => $record]); } catch (Exception $e) { $this->eye->logger()->error('Ssl record save failed', $e, $domain); throw $e; } }
php
protected function saveSslRecord($domain, $result) { $record['grade'] = $result['results']['grade']; $record['results_url'] = 'https://www.htbridge.com/ssl/?id=' . $result['internals']['short_id']; if (isset($result['certificates']['information'][0])) { $record['valid'] = $result['certificates']['information'][0]['valid_now']; $record['valid_from'] = $result['certificates']['information'][0]['valid_from']; $record['valid_to'] = $result['certificates']['information'][0]['valid_to']; $record['revoked'] = $result['certificates']['information'][0]['revoked']; $record['expires_soon'] = $result['certificates']['information'][0]['expires_soon']; $record['issuer'] = $result['certificates']['information'][0]['issuer_cn']; } try { History::where('meta', $domain)->delete(); History::create(['type' => 'ssl', 'meta' => $domain, 'record' => $record]); } catch (Exception $e) { $this->eye->logger()->error('Ssl record save failed', $e, $domain); throw $e; } }
[ "protected", "function", "saveSslRecord", "(", "$", "domain", ",", "$", "result", ")", "{", "$", "record", "[", "'grade'", "]", "=", "$", "result", "[", "'results'", "]", "[", "'grade'", "]", ";", "$", "record", "[", "'results_url'", "]", "=", "'https:...
Save the SSL record to the database. @param string $domain @param array $result @return void
[ "Save", "the", "SSL", "record", "to", "the", "database", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Ssl.php#L154-L175
eyewitness/eye
app/Monitors/Ssl.php
Ssl.isValidDomain
protected function isValidDomain($domain) { if (filter_var($domain, FILTER_VALIDATE_URL) === false) { $this->eye->logger()->debug('SSL URL not valid', $domain); return false; } return true; }
php
protected function isValidDomain($domain) { if (filter_var($domain, FILTER_VALIDATE_URL) === false) { $this->eye->logger()->debug('SSL URL not valid', $domain); return false; } return true; }
[ "protected", "function", "isValidDomain", "(", "$", "domain", ")", "{", "if", "(", "filter_var", "(", "$", "domain", ",", "FILTER_VALIDATE_URL", ")", "===", "false", ")", "{", "$", "this", "->", "eye", "->", "logger", "(", ")", "->", "debug", "(", "'SS...
Check if the URL is valid. @param string $domain @return bool
[ "Check", "if", "the", "URL", "is", "valid", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Ssl.php#L183-L191
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.getCommandName
public function getCommandName($filtered = true) { if ($this->command) { if ($filtered) { return $this->filterArtisanCommand($this->command); } else { return $this->command; } } if ($this->description) { return $this->description; } if (isset($this->callback) && is_string($this->callback)) { return $this->callback; } return 'Unnamed Closure'; }
php
public function getCommandName($filtered = true) { if ($this->command) { if ($filtered) { return $this->filterArtisanCommand($this->command); } else { return $this->command; } } if ($this->description) { return $this->description; } if (isset($this->callback) && is_string($this->callback)) { return $this->callback; } return 'Unnamed Closure'; }
[ "public", "function", "getCommandName", "(", "$", "filtered", "=", "true", ")", "{", "if", "(", "$", "this", "->", "command", ")", "{", "if", "(", "$", "filtered", ")", "{", "return", "$", "this", "->", "filterArtisanCommand", "(", "$", "this", "->", ...
Get the summary of the event for display. @param bool $filtered @return string
[ "Get", "the", "summary", "of", "the", "event", "for", "display", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L101-L120
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.outputNotBeingCaptured
protected function outputNotBeingCaptured() { if (is_null($this->output)) { return true; } if (is_callable([$this, 'getDefaultOutput'])) { return $this->output === $this->getDefaultOutput(); } return in_array($this->output, ['NUL', '/dev/null']); }
php
protected function outputNotBeingCaptured() { if (is_null($this->output)) { return true; } if (is_callable([$this, 'getDefaultOutput'])) { return $this->output === $this->getDefaultOutput(); } return in_array($this->output, ['NUL', '/dev/null']); }
[ "protected", "function", "outputNotBeingCaptured", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "output", ")", ")", "{", "return", "true", ";", "}", "if", "(", "is_callable", "(", "[", "$", "this", ",", "'getDefaultOutput'", "]", ")", "...
Check if output is being captured. @return bool
[ "Check", "if", "output", "is", "being", "captured", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L152-L163
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.recordEventStart
public function recordEventStart() { try { $this->scheduler = Scheduler::firstOrNew(['mutex' => $this->mutexName()]); if (! $this->scheduler->exists) { $this->scheduler->fill([ 'schedule' => $this->expression, 'command' => $this->getCommandName(), 'timezone' => $this->timezone, 'run_in_background' => $this->runInBackground, 'without_overlapping' => $this->withoutOverlapping, 'on_one_server' => $this->onOneServer, 'next_run_due' => $this->getNextRunDue($this->expression, $this->timezone), 'next_check_due' => $this->getNextCheckDue($this->expression, $this->timezone), ]); } else { $this->scheduler->fill([ 'last_run' => date("Y-m-d H:i:s"), 'next_run_due' => $this->getNextRunDue($this->expression, $this->timezone), 'next_check_due' => $this->getNextCheckDue($this->expression, $this->timezone), ]); } $this->scheduler->save(); $this->history = History::create([ 'scheduler_id' => $this->scheduler->id, 'expected_completion' => $this->determineExpectedCompletion($this->scheduler), ]); } catch (Exception $e) { app(Eye::class)->logger()->error('Unable to track scheduler', $e->getMessage(), ['expresison' => $this->expression, 'command_name' => $this->getCommandName()]); } $this->start = microtime(true); $this->exitcode = 1; }
php
public function recordEventStart() { try { $this->scheduler = Scheduler::firstOrNew(['mutex' => $this->mutexName()]); if (! $this->scheduler->exists) { $this->scheduler->fill([ 'schedule' => $this->expression, 'command' => $this->getCommandName(), 'timezone' => $this->timezone, 'run_in_background' => $this->runInBackground, 'without_overlapping' => $this->withoutOverlapping, 'on_one_server' => $this->onOneServer, 'next_run_due' => $this->getNextRunDue($this->expression, $this->timezone), 'next_check_due' => $this->getNextCheckDue($this->expression, $this->timezone), ]); } else { $this->scheduler->fill([ 'last_run' => date("Y-m-d H:i:s"), 'next_run_due' => $this->getNextRunDue($this->expression, $this->timezone), 'next_check_due' => $this->getNextCheckDue($this->expression, $this->timezone), ]); } $this->scheduler->save(); $this->history = History::create([ 'scheduler_id' => $this->scheduler->id, 'expected_completion' => $this->determineExpectedCompletion($this->scheduler), ]); } catch (Exception $e) { app(Eye::class)->logger()->error('Unable to track scheduler', $e->getMessage(), ['expresison' => $this->expression, 'command_name' => $this->getCommandName()]); } $this->start = microtime(true); $this->exitcode = 1; }
[ "public", "function", "recordEventStart", "(", ")", "{", "try", "{", "$", "this", "->", "scheduler", "=", "Scheduler", "::", "firstOrNew", "(", "[", "'mutex'", "=>", "$", "this", "->", "mutexName", "(", ")", "]", ")", ";", "if", "(", "!", "$", "this"...
Set everything and pass the start of the job to Eyewitness to record. @return void
[ "Set", "everything", "and", "pass", "the", "start", "of", "the", "job", "to", "Eyewitness", "to", "record", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L170-L208
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.recordEventFinish
public function recordEventFinish() { if (is_null($this->history)) { return; } $this->history->time_to_run = $this->calculateRunTime(); $this->history->exitcode = $this->exitcode; $this->history->output = $this->retrieveOutput(); $this->history->save(); }
php
public function recordEventFinish() { if (is_null($this->history)) { return; } $this->history->time_to_run = $this->calculateRunTime(); $this->history->exitcode = $this->exitcode; $this->history->output = $this->retrieveOutput(); $this->history->save(); }
[ "public", "function", "recordEventFinish", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "history", ")", ")", "{", "return", ";", "}", "$", "this", "->", "history", "->", "time_to_run", "=", "$", "this", "->", "calculateRunTime", "(", ")...
Pass the results of the of the job to Eyewitness to record. @return void
[ "Pass", "the", "results", "of", "the", "of", "the", "job", "to", "Eyewitness", "to", "record", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L215-L225
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.handleNotifications
protected function handleNotifications() { if (($this->exitcode > 0) && $this->scheduler->alert_on_fail) { return app(Eye::class)->notifier()->alert(new Error(['scheduler' => $this->scheduler, 'exitcode' => $this->exitcode])); } if (($this->scheduler->alert_run_time_greater_than > 0) && ($this->history->time_to_run > $this->scheduler->alert_run_time_greater_than)) { return app(Eye::class)->notifier()->alert(new Slow(['scheduler' => $this->scheduler, 'time_to_run' => $this->history->time_to_run])); } if (($this->scheduler->alert_run_time_less_than > 0) && ($this->history->time_to_run < $this->scheduler->alert_run_time_less_than)) { return app(Eye::class)->notifier()->alert(new Fast(['scheduler' => $this->scheduler, 'time_to_run' => $this->history->time_to_run])); } if (! $this->scheduler->healthy) { if (! is_null($this->scheduler->healthy)) { app(Eye::class)->notifier()->alert(new Working(['scheduler' => $this->scheduler])); } $this->scheduler->healthy = true; $this->scheduler->save(); } }
php
protected function handleNotifications() { if (($this->exitcode > 0) && $this->scheduler->alert_on_fail) { return app(Eye::class)->notifier()->alert(new Error(['scheduler' => $this->scheduler, 'exitcode' => $this->exitcode])); } if (($this->scheduler->alert_run_time_greater_than > 0) && ($this->history->time_to_run > $this->scheduler->alert_run_time_greater_than)) { return app(Eye::class)->notifier()->alert(new Slow(['scheduler' => $this->scheduler, 'time_to_run' => $this->history->time_to_run])); } if (($this->scheduler->alert_run_time_less_than > 0) && ($this->history->time_to_run < $this->scheduler->alert_run_time_less_than)) { return app(Eye::class)->notifier()->alert(new Fast(['scheduler' => $this->scheduler, 'time_to_run' => $this->history->time_to_run])); } if (! $this->scheduler->healthy) { if (! is_null($this->scheduler->healthy)) { app(Eye::class)->notifier()->alert(new Working(['scheduler' => $this->scheduler])); } $this->scheduler->healthy = true; $this->scheduler->save(); } }
[ "protected", "function", "handleNotifications", "(", ")", "{", "if", "(", "(", "$", "this", "->", "exitcode", ">", "0", ")", "&&", "$", "this", "->", "scheduler", "->", "alert_on_fail", ")", "{", "return", "app", "(", "Eye", "::", "class", ")", "->", ...
Handle any required notifications from the job. @return void
[ "Handle", "any", "required", "notifications", "from", "the", "job", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L232-L257
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.runCommandInForeground
protected function runCommandInForeground(Container $container) { register_shutdown_function(function () { $this->forgetMutex(); }); $this->ensureOutputIsBeingCapturedForEyewitness(); $this->recordEventStart(); $this->callBeforeCallbacks($container); try { $this->runForegroundProcess($container); } finally { $this->callAfterCallbacks($container); $this->recordEventFinish(); $this->forgetMutex(); $this->handleNotifications(); } }
php
protected function runCommandInForeground(Container $container) { register_shutdown_function(function () { $this->forgetMutex(); }); $this->ensureOutputIsBeingCapturedForEyewitness(); $this->recordEventStart(); $this->callBeforeCallbacks($container); try { $this->runForegroundProcess($container); } finally { $this->callAfterCallbacks($container); $this->recordEventFinish(); $this->forgetMutex(); $this->handleNotifications(); } }
[ "protected", "function", "runCommandInForeground", "(", "Container", "$", "container", ")", "{", "register_shutdown_function", "(", "function", "(", ")", "{", "$", "this", "->", "forgetMutex", "(", ")", ";", "}", ")", ";", "$", "this", "->", "ensureOutputIsBei...
Run the command in the foreground. @param \Illuminate\Contracts\Container\Container $container @return void
[ "Run", "the", "command", "in", "the", "foreground", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L265-L285
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.mutexName
public function mutexName() { if (Eye::laravelVersionIs('>=', '5.2.0')) { return 'framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($this->expression.$this->command); } return 'framework/schedule-'.md5($this->expression.$this->command); }
php
public function mutexName() { if (Eye::laravelVersionIs('>=', '5.2.0')) { return 'framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($this->expression.$this->command); } return 'framework/schedule-'.md5($this->expression.$this->command); }
[ "public", "function", "mutexName", "(", ")", "{", "if", "(", "Eye", "::", "laravelVersionIs", "(", "'>='", ",", "'5.2.0'", ")", ")", "{", "return", "'framework'", ".", "DIRECTORY_SEPARATOR", ".", "'schedule-'", ".", "sha1", "(", "$", "this", "->", "express...
Get the mutex name for the scheduled command. @return string
[ "Get", "the", "mutex", "name", "for", "the", "scheduled", "command", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L292-L299
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.forgetMutex
public function forgetMutex() { if (Eye::laravelVersionIs('<', '5.4.0')) { if (file_exists($this->mutexPath())) { unlink($this->mutexPath()); } } elseif (Eye::laravelVersionIs('<', '5.4.17')) { $this->cache->forget($this->mutexName()); } else { $this->mutex->forget($this); } }
php
public function forgetMutex() { if (Eye::laravelVersionIs('<', '5.4.0')) { if (file_exists($this->mutexPath())) { unlink($this->mutexPath()); } } elseif (Eye::laravelVersionIs('<', '5.4.17')) { $this->cache->forget($this->mutexName()); } else { $this->mutex->forget($this); } }
[ "public", "function", "forgetMutex", "(", ")", "{", "if", "(", "Eye", "::", "laravelVersionIs", "(", "'<'", ",", "'5.4.0'", ")", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "mutexPath", "(", ")", ")", ")", "{", "unlink", "(", "$", "...
Run the correct shutdown function based upon the Laravel version. @return void
[ "Run", "the", "correct", "shutdown", "function", "based", "upon", "the", "Laravel", "version", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L316-L327
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.setMutex
protected function setMutex() { if (Eye::laravelVersionIs('<', '5.4.0')) { return touch($this->mutexPath()); } elseif (Eye::laravelVersionIs('<', '5.4.17')) { return $this->cache->add($this->mutexName(), true, 1440); } return $this->mutex->create($this); }
php
protected function setMutex() { if (Eye::laravelVersionIs('<', '5.4.0')) { return touch($this->mutexPath()); } elseif (Eye::laravelVersionIs('<', '5.4.17')) { return $this->cache->add($this->mutexName(), true, 1440); } return $this->mutex->create($this); }
[ "protected", "function", "setMutex", "(", ")", "{", "if", "(", "Eye", "::", "laravelVersionIs", "(", "'<'", ",", "'5.4.0'", ")", ")", "{", "return", "touch", "(", "$", "this", "->", "mutexPath", "(", ")", ")", ";", "}", "elseif", "(", "Eye", "::", ...
Run the correct mutex based upon the Laravel version. @return bool
[ "Run", "the", "correct", "mutex", "based", "upon", "the", "Laravel", "version", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L335-L344
eyewitness/eye
app/Scheduling/BaseEvent.php
BaseEvent.filterArtisanCommand
protected function filterArtisanCommand($command) { $parts = explode(" ", $command); if (isset($parts[2])) { if (str_contains(strtolower($parts[0]), 'php') && str_contains(strtolower($parts[1]), 'artisan')) { unset($parts[0]); unset($parts[1]); return implode(" ", $parts); } } return $command; }
php
protected function filterArtisanCommand($command) { $parts = explode(" ", $command); if (isset($parts[2])) { if (str_contains(strtolower($parts[0]), 'php') && str_contains(strtolower($parts[1]), 'artisan')) { unset($parts[0]); unset($parts[1]); return implode(" ", $parts); } } return $command; }
[ "protected", "function", "filterArtisanCommand", "(", "$", "command", ")", "{", "$", "parts", "=", "explode", "(", "\" \"", ",", "$", "command", ")", ";", "if", "(", "isset", "(", "$", "parts", "[", "2", "]", ")", ")", "{", "if", "(", "str_contains",...
Get the command name without the junk. @param string $command @return string
[ "Get", "the", "command", "name", "without", "the", "junk", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Scheduling/BaseEvent.php#L352-L365
eyewitness/eye
app/Queue/Handlers/DatabaseQueue.php
DatabaseQueue.pendingJobsCount
public function pendingJobsCount($tube) { try { $count = $this->queue->table($this->table) ->whereNull('reserved_at') ->where('queue', $tube) ->where('available_at', '<=', time()) ->count(); } catch (QueryException $e) { $count = 0; } return $count; }
php
public function pendingJobsCount($tube) { try { $count = $this->queue->table($this->table) ->whereNull('reserved_at') ->where('queue', $tube) ->where('available_at', '<=', time()) ->count(); } catch (QueryException $e) { $count = 0; } return $count; }
[ "public", "function", "pendingJobsCount", "(", "$", "tube", ")", "{", "try", "{", "$", "count", "=", "$", "this", "->", "queue", "->", "table", "(", "$", "this", "->", "table", ")", "->", "whereNull", "(", "'reserved_at'", ")", "->", "where", "(", "'...
Return the number of pending jobs for the tube. @param string $tube @return int
[ "Return", "the", "number", "of", "pending", "jobs", "for", "the", "tube", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/Handlers/DatabaseQueue.php#L36-L49
eyewitness/eye
app/Monitors/Dns.php
Dns.poll
public function poll() { if (! count(config('eyewitness.application_domains'))) { $this->eye->logger()->debug('No application domain set for DNS witness'); return; } foreach (config('eyewitness.application_domains') as $domain) { $record = $this->getDnsRecord($domain); if ($record && $this->hasDnsRecordChanged($domain, $record)) { if ($this->checkDnsChangeThreshold($domain)) { $this->saveDnsRecord($domain, $record); $this->eye->notifier()->alert(new Change(['domain' => $domain])); } } } }
php
public function poll() { if (! count(config('eyewitness.application_domains'))) { $this->eye->logger()->debug('No application domain set for DNS witness'); return; } foreach (config('eyewitness.application_domains') as $domain) { $record = $this->getDnsRecord($domain); if ($record && $this->hasDnsRecordChanged($domain, $record)) { if ($this->checkDnsChangeThreshold($domain)) { $this->saveDnsRecord($domain, $record); $this->eye->notifier()->alert(new Change(['domain' => $domain])); } } } }
[ "public", "function", "poll", "(", ")", "{", "if", "(", "!", "count", "(", "config", "(", "'eyewitness.application_domains'", ")", ")", ")", "{", "$", "this", "->", "eye", "->", "logger", "(", ")", "->", "debug", "(", "'No application domain set for DNS witn...
Poll the DNS for its checks. @return void
[ "Poll", "the", "DNS", "for", "its", "checks", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Dns.php#L17-L34
eyewitness/eye
app/Monitors/Dns.php
Dns.getDnsRecord
protected function getDnsRecord($domain) { if (filter_var($domain, FILTER_VALIDATE_URL) === false) { $this->eye->logger()->debug('DNS URL not valid', $domain); return false; } try { $dns = $this->pollDns($this->parseUrl($domain)); } catch (Exception $e) { $this->eye->logger()->debug('DNS lookup failed', ['domain' => $domain, 'exception' => $e->getMessage()]); return false; } return $this->stripTtlFromDns($dns); }
php
protected function getDnsRecord($domain) { if (filter_var($domain, FILTER_VALIDATE_URL) === false) { $this->eye->logger()->debug('DNS URL not valid', $domain); return false; } try { $dns = $this->pollDns($this->parseUrl($domain)); } catch (Exception $e) { $this->eye->logger()->debug('DNS lookup failed', ['domain' => $domain, 'exception' => $e->getMessage()]); return false; } return $this->stripTtlFromDns($dns); }
[ "protected", "function", "getDnsRecord", "(", "$", "domain", ")", "{", "if", "(", "filter_var", "(", "$", "domain", ",", "FILTER_VALIDATE_URL", ")", "===", "false", ")", "{", "$", "this", "->", "eye", "->", "logger", "(", ")", "->", "debug", "(", "'DNS...
Poll the DNS for its checks. @param string $domain @return array|bool
[ "Poll", "the", "DNS", "for", "its", "checks", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Dns.php#L42-L58
eyewitness/eye
app/Monitors/Dns.php
Dns.hasDnsRecordChanged
protected function hasDnsRecordChanged($domain, $record) { if (! $dns_history = History::where('meta', $domain)->orderBy('created_at', 'desc')->first()) { $this->saveDnsRecord($domain, $record); return false; } $differences = $this->compareDnsRecords($dns_history->record, $record); return (count($differences['original']) && count($differences['new'])); }
php
protected function hasDnsRecordChanged($domain, $record) { if (! $dns_history = History::where('meta', $domain)->orderBy('created_at', 'desc')->first()) { $this->saveDnsRecord($domain, $record); return false; } $differences = $this->compareDnsRecords($dns_history->record, $record); return (count($differences['original']) && count($differences['new'])); }
[ "protected", "function", "hasDnsRecordChanged", "(", "$", "domain", ",", "$", "record", ")", "{", "if", "(", "!", "$", "dns_history", "=", "History", "::", "where", "(", "'meta'", ",", "$", "domain", ")", "->", "orderBy", "(", "'created_at'", ",", "'desc...
Check if the supplied record is different from the most recently stored DNS record available. @param string $domain @param array $record @return bool
[ "Check", "if", "the", "supplied", "record", "is", "different", "from", "the", "most", "recently", "stored", "DNS", "record", "available", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Dns.php#L68-L78
eyewitness/eye
app/Monitors/Dns.php
Dns.saveDnsRecord
protected function saveDnsRecord($domain, $record) { $this->sortArray($record); try { History::create(['type' => 'dns', 'meta' => $domain, 'record' => $this->utf8_converter($record)]); } catch (Exception $e) { $this->eye->logger()->error('DNS record save failed', $e, $domain); throw $e; } }
php
protected function saveDnsRecord($domain, $record) { $this->sortArray($record); try { History::create(['type' => 'dns', 'meta' => $domain, 'record' => $this->utf8_converter($record)]); } catch (Exception $e) { $this->eye->logger()->error('DNS record save failed', $e, $domain); throw $e; } }
[ "protected", "function", "saveDnsRecord", "(", "$", "domain", ",", "$", "record", ")", "{", "$", "this", "->", "sortArray", "(", "$", "record", ")", ";", "try", "{", "History", "::", "create", "(", "[", "'type'", "=>", "'dns'", ",", "'meta'", "=>", "...
Save the DNS record to the database. @param string $domain @param array $record @return void
[ "Save", "the", "DNS", "record", "to", "the", "database", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Dns.php#L87-L99
eyewitness/eye
app/Monitors/Dns.php
Dns.compareDnsRecords
protected function compareDnsRecords($original, $new) { $differences['original'] = $original; $differences['new'] = $new; foreach ($original as $original_id => $original_record) { foreach ($new as $new_id => $new_record) { if ($original_record == $new_record) { unset($differences['original'][$original_id]); unset($differences['new'][$new_id]); } } } return $differences; }
php
protected function compareDnsRecords($original, $new) { $differences['original'] = $original; $differences['new'] = $new; foreach ($original as $original_id => $original_record) { foreach ($new as $new_id => $new_record) { if ($original_record == $new_record) { unset($differences['original'][$original_id]); unset($differences['new'][$new_id]); } } } return $differences; }
[ "protected", "function", "compareDnsRecords", "(", "$", "original", ",", "$", "new", ")", "{", "$", "differences", "[", "'original'", "]", "=", "$", "original", ";", "$", "differences", "[", "'new'", "]", "=", "$", "new", ";", "foreach", "(", "$", "ori...
Compare two DNS record arrays. We can not just do a normal array compare - because the arrays can appear to be different, even after sorting. The most reliable method turns out to be a simple reduction of arrays through individual compararions. @param array $original @param array $new @return array
[ "Compare", "two", "DNS", "record", "arrays", ".", "We", "can", "not", "just", "do", "a", "normal", "array", "compare", "-", "because", "the", "arrays", "can", "appear", "to", "be", "different", "even", "after", "sorting", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Dns.php#L113-L128
eyewitness/eye
app/Monitors/Dns.php
Dns.checkDnsChangeThreshold
protected function checkDnsChangeThreshold($domain) { for ($i=0; $i<5; $i++) { $record = $this->getDnsRecord($domain); if (! $this->hasDnsRecordChanged($domain, $record)) { return false; } } return true; }
php
protected function checkDnsChangeThreshold($domain) { for ($i=0; $i<5; $i++) { $record = $this->getDnsRecord($domain); if (! $this->hasDnsRecordChanged($domain, $record)) { return false; } } return true; }
[ "protected", "function", "checkDnsChangeThreshold", "(", "$", "domain", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "5", ";", "$", "i", "++", ")", "{", "$", "record", "=", "$", "this", "->", "getDnsRecord", "(", "$", "domain", "...
Because "get_dns_records()" can sometimes be unreliable (at times a certain record will fail to be retrieved with no error, thus only giving a partial result), we run the check extra times to be sure the results are valid. This significantly reduces the levels of "false positives" generated based upon thousands of real life monitoring tests run. @param string $domain @return bool
[ "Because", "get_dns_records", "()", "can", "sometimes", "be", "unreliable", "(", "at", "times", "a", "certain", "record", "will", "fail", "to", "be", "retrieved", "with", "no", "error", "thus", "only", "giving", "a", "partial", "result", ")", "we", "run", ...
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Dns.php#L141-L151
eyewitness/eye
app/Monitors/Dns.php
Dns.utf8_converter
protected function utf8_converter($array) { array_walk_recursive($array, function(&$item, $key){ if(! mb_detect_encoding($item, 'utf-8', true)){ $item = utf8_encode($item); } }); return $array; }
php
protected function utf8_converter($array) { array_walk_recursive($array, function(&$item, $key){ if(! mb_detect_encoding($item, 'utf-8', true)){ $item = utf8_encode($item); } }); return $array; }
[ "protected", "function", "utf8_converter", "(", "$", "array", ")", "{", "array_walk_recursive", "(", "$", "array", ",", "function", "(", "&", "$", "item", ",", "$", "key", ")", "{", "if", "(", "!", "mb_detect_encoding", "(", "$", "item", ",", "'utf-8'", ...
A special way to convert UTF8 encoding into JSON. Useful for dns provides like Google who sometimes return records with special chars in the records. See: https://stackoverflow.com/questions/12236459/convert-arrays-into-utf-8-php-json @param array $array @return array
[ "A", "special", "way", "to", "convert", "UTF8", "encoding", "into", "JSON", ".", "Useful", "for", "dns", "provides", "like", "Google", "who", "sometimes", "return", "records", "with", "special", "chars", "in", "the", "records", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Dns.php#L193-L202
eyewitness/eye
app/Monitors/Dns.php
Dns.sortArray
protected function sortArray(&$array, $sort_flags = SORT_REGULAR) { if (! is_array($array)) { return; } ksort($array, $sort_flags); foreach ($array as &$arr) { $this->sortArray($arr, $sort_flags); } }
php
protected function sortArray(&$array, $sort_flags = SORT_REGULAR) { if (! is_array($array)) { return; } ksort($array, $sort_flags); foreach ($array as &$arr) { $this->sortArray($arr, $sort_flags); } }
[ "protected", "function", "sortArray", "(", "&", "$", "array", ",", "$", "sort_flags", "=", "SORT_REGULAR", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "{", "return", ";", "}", "ksort", "(", "$", "array", ",", "$", "sort_flags",...
Recursive ksort function to sort array. See: https://gist.github.com/cdzombak/601849 @param array $array @return void
[ "Recursive", "ksort", "function", "to", "sort", "array", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Dns.php#L212-L223
eyewitness/eye
app/Http/Middleware/Authenticate.php
Authenticate.handle
public function handle($request, Closure $next) { if (session('eyewitness:auth') || app(Eye::class)->check($request)) { return $next($request); } return redirect()->route('eyewitness.login')->withWarning('Sorry - you must login to Eyewitness first.'); }
php
public function handle($request, Closure $next) { if (session('eyewitness:auth') || app(Eye::class)->check($request)) { return $next($request); } return redirect()->route('eyewitness.login')->withWarning('Sorry - you must login to Eyewitness first.'); }
[ "public", "function", "handle", "(", "$", "request", ",", "Closure", "$", "next", ")", "{", "if", "(", "session", "(", "'eyewitness:auth'", ")", "||", "app", "(", "Eye", "::", "class", ")", "->", "check", "(", "$", "request", ")", ")", "{", "return",...
Authenticate a user for Eyewitness. @param \Illuminate\Http\Request $request @param \Closure $next @return mixed
[ "Authenticate", "a", "user", "for", "Eyewitness", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Middleware/Authenticate.php#L17-L24
eyewitness/eye
database/migrations/2017_12_01_000001_create_eyewitness_io_statuses_table.php
CreateEyewitnessIoStatusesTable.up
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_statuses', function (Blueprint $table) { $table->increments('id'); $table->string('monitor', 191); $table->boolean('healthy'); $table->timestamp('updated_at')->useCurrent(); }); }
php
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_statuses', function (Blueprint $table) { $table->increments('id'); $table->string('monitor', 191); $table->boolean('healthy'); $table->timestamp('updated_at')->useCurrent(); }); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "connection", "(", "config", "(", "'eyewitness.eyewitness_database_connection'", ")", ")", "->", "create", "(", "'eyewitness_io_statuses'", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$",...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/database/migrations/2017_12_01_000001_create_eyewitness_io_statuses_table.php#L14-L22
eyewitness/eye
app/Commands/BackgroundRunCommand.php
BackgroundRunCommand.handle
public function handle() { if (! $event = $this->findEventMutex($this->argument('id'))) { $this->error('No scheduled event could be found that matches the given id.'); return; } $this->runEvent($event, $this->option('force')); }
php
public function handle() { if (! $event = $this->findEventMutex($this->argument('id'))) { $this->error('No scheduled event could be found that matches the given id.'); return; } $this->runEvent($event, $this->option('force')); }
[ "public", "function", "handle", "(", ")", "{", "if", "(", "!", "$", "event", "=", "$", "this", "->", "findEventMutex", "(", "$", "this", "->", "argument", "(", "'id'", ")", ")", ")", "{", "$", "this", "->", "error", "(", "'No scheduled event could be f...
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/BackgroundRunCommand.php#L59-L67
eyewitness/eye
app/Notifications/Messages/Queue/PendingCountOk.php
PendingCountOk.meta
public function meta() { return [ 'Connection' => e($this->meta['queue']->connection), 'Queue' => e($this->meta['queue']->tube), 'Driver' => e($this->meta['queue']->driver), 'Your threshold' => e($this->meta['queue']->alert_pending_jobs_greater_than), 'Actual pending job count' => e($this->meta['pending_job_count']), ]; }
php
public function meta() { return [ 'Connection' => e($this->meta['queue']->connection), 'Queue' => e($this->meta['queue']->tube), 'Driver' => e($this->meta['queue']->driver), 'Your threshold' => e($this->meta['queue']->alert_pending_jobs_greater_than), 'Actual pending job count' => e($this->meta['pending_job_count']), ]; }
[ "public", "function", "meta", "(", ")", "{", "return", "[", "'Connection'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'queue'", "]", "->", "connection", ")", ",", "'Queue'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'queue'", "]", "->...
Any meta information for the message. @return array
[ "Any", "meta", "information", "for", "the", "message", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Messages/Queue/PendingCountOk.php#L44-L53
eyewitness/eye
app/Commands/PollCommand.php
PollCommand.handle
public function handle() { if (config('eyewitness.monitor_scheduler')) { $this->eye->scheduler()->poll(); } if (config('eyewitness.monitor_queue')) { $this->eye->queue()->poll(); } if (config('eyewitness.monitor_database')) { $this->eye->database()->poll(); } if ($this->option('force')) { $this->eye->composer()->poll(); $this->eye->dns()->poll(); } $this->eye->debug()->poll(); $this->info('Eyewitness poll complete.'); }
php
public function handle() { if (config('eyewitness.monitor_scheduler')) { $this->eye->scheduler()->poll(); } if (config('eyewitness.monitor_queue')) { $this->eye->queue()->poll(); } if (config('eyewitness.monitor_database')) { $this->eye->database()->poll(); } if ($this->option('force')) { $this->eye->composer()->poll(); $this->eye->dns()->poll(); } $this->eye->debug()->poll(); $this->info('Eyewitness poll complete.'); }
[ "public", "function", "handle", "(", ")", "{", "if", "(", "config", "(", "'eyewitness.monitor_scheduler'", ")", ")", "{", "$", "this", "->", "eye", "->", "scheduler", "(", ")", "->", "poll", "(", ")", ";", "}", "if", "(", "config", "(", "'eyewitness.mo...
Execute the console command. @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/PollCommand.php#L57-L79
eyewitness/eye
database/migrations/2017_12_01_000004_create_eyewitness_io_notification_severities_table.php
CreateEyewitnessIoNotificationSeveritiesTable.up
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_notification_severities', function (Blueprint $table) { $table->increments('id'); $table->string('namespace', 191)->index(); $table->string('notification', 191)->index(); $table->string('severity', 191); }); Severity::insert([ ['namespace' => 'Scheduler', 'notification' => 'Fast', 'severity' => 'medium'], ['namespace' => 'Scheduler', 'notification' => 'Slow', 'severity' => 'medium'], ['namespace' => 'Scheduler', 'notification' => 'Missed', 'severity' => 'high'], ['namespace' => 'Scheduler', 'notification' => 'Overdue', 'severity' => 'high'], ['namespace' => 'Scheduler', 'notification' => 'Error', 'severity' => 'high'], ['namespace' => 'Scheduler', 'notification' => 'Working', 'severity' => 'high'], ['namespace' => 'DNS', 'notification' => 'Change', 'severity' => 'low'], ['namespace' => 'SSL', 'notification' => 'GradeChange', 'severity' => 'medium'], ['namespace' => 'SSL', 'notification' => 'Expiring', 'severity' => 'low'], ['namespace' => 'SSL', 'notification' => 'Invalid', 'severity' => 'high'], ['namespace' => 'SSL', 'notification' => 'Revoked', 'severity' => 'high'], ['namespace' => 'Debug', 'notification' => 'Enabled', 'severity' => 'high'], ['namespace' => 'Debug', 'notification' => 'Disabled', 'severity' => 'high'], ['namespace' => 'Composer', 'notification' => 'Safe', 'severity' => 'medium'], ['namespace' => 'Composer', 'notification' => 'Risk', 'severity' => 'medium'], ['namespace' => 'Database', 'notification' => 'Offline', 'severity' => 'high'], ['namespace' => 'Database', 'notification' => 'Online', 'severity' => 'high'], ['namespace' => 'Database', 'notification' => 'SizeOk', 'severity' => 'low'], ['namespace' => 'Database', 'notification' => 'SizeLarge', 'severity' => 'low'], ['namespace' => 'Database', 'notification' => 'SizeSmall', 'severity' => 'low'], ['namespace' => 'Queue', 'notification' => 'Failed', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'Offline', 'severity' => 'high'], ['namespace' => 'Queue', 'notification' => 'Online', 'severity' => 'high'], ['namespace' => 'Queue', 'notification' => 'FailedCountExceeded', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'FailedCountOk', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'PendingCountExceeded', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'PendingCountOk', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'WaitLong', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'WaitOk', 'severity' => 'medium'], ['namespace' => 'Custom', 'notification' => 'Passed', 'severity' => 'medium'], ['namespace' => 'Custom', 'notification' => 'Failed', 'severity' => 'medium'], ]); }
php
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_notification_severities', function (Blueprint $table) { $table->increments('id'); $table->string('namespace', 191)->index(); $table->string('notification', 191)->index(); $table->string('severity', 191); }); Severity::insert([ ['namespace' => 'Scheduler', 'notification' => 'Fast', 'severity' => 'medium'], ['namespace' => 'Scheduler', 'notification' => 'Slow', 'severity' => 'medium'], ['namespace' => 'Scheduler', 'notification' => 'Missed', 'severity' => 'high'], ['namespace' => 'Scheduler', 'notification' => 'Overdue', 'severity' => 'high'], ['namespace' => 'Scheduler', 'notification' => 'Error', 'severity' => 'high'], ['namespace' => 'Scheduler', 'notification' => 'Working', 'severity' => 'high'], ['namespace' => 'DNS', 'notification' => 'Change', 'severity' => 'low'], ['namespace' => 'SSL', 'notification' => 'GradeChange', 'severity' => 'medium'], ['namespace' => 'SSL', 'notification' => 'Expiring', 'severity' => 'low'], ['namespace' => 'SSL', 'notification' => 'Invalid', 'severity' => 'high'], ['namespace' => 'SSL', 'notification' => 'Revoked', 'severity' => 'high'], ['namespace' => 'Debug', 'notification' => 'Enabled', 'severity' => 'high'], ['namespace' => 'Debug', 'notification' => 'Disabled', 'severity' => 'high'], ['namespace' => 'Composer', 'notification' => 'Safe', 'severity' => 'medium'], ['namespace' => 'Composer', 'notification' => 'Risk', 'severity' => 'medium'], ['namespace' => 'Database', 'notification' => 'Offline', 'severity' => 'high'], ['namespace' => 'Database', 'notification' => 'Online', 'severity' => 'high'], ['namespace' => 'Database', 'notification' => 'SizeOk', 'severity' => 'low'], ['namespace' => 'Database', 'notification' => 'SizeLarge', 'severity' => 'low'], ['namespace' => 'Database', 'notification' => 'SizeSmall', 'severity' => 'low'], ['namespace' => 'Queue', 'notification' => 'Failed', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'Offline', 'severity' => 'high'], ['namespace' => 'Queue', 'notification' => 'Online', 'severity' => 'high'], ['namespace' => 'Queue', 'notification' => 'FailedCountExceeded', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'FailedCountOk', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'PendingCountExceeded', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'PendingCountOk', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'WaitLong', 'severity' => 'medium'], ['namespace' => 'Queue', 'notification' => 'WaitOk', 'severity' => 'medium'], ['namespace' => 'Custom', 'notification' => 'Passed', 'severity' => 'medium'], ['namespace' => 'Custom', 'notification' => 'Failed', 'severity' => 'medium'], ]); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "connection", "(", "config", "(", "'eyewitness.eyewitness_database_connection'", ")", ")", "->", "create", "(", "'eyewitness_io_notification_severities'", ",", "function", "(", "Blueprint", "$", "table", ")"...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/database/migrations/2017_12_01_000004_create_eyewitness_io_notification_severities_table.php#L15-L65
eyewitness/eye
app/Commands/Framework/LegacyWorkCommand.php
LegacyWorkCommand.runWorker
protected function runWorker($connection, $queue, $delay, $memory, $daemon = false) { if (! $daemon) { $this->worker->setCache($this->laravel['cache']->driver()); } $queue = $this->getQueue($queue, $connection); $connection = $this->getConnectionName($connection); foreach (explode(',', $queue) as $tube) { $this->worker->eyeQueues[] = Queue::firstOrCreate(['connection' => $connection, 'tube' => $tube, 'driver' => $this->getDriverName($connection), 'healthy' => 1]); } return parent::runWorker($connection, $queue, $delay, $memory, $daemon); }
php
protected function runWorker($connection, $queue, $delay, $memory, $daemon = false) { if (! $daemon) { $this->worker->setCache($this->laravel['cache']->driver()); } $queue = $this->getQueue($queue, $connection); $connection = $this->getConnectionName($connection); foreach (explode(',', $queue) as $tube) { $this->worker->eyeQueues[] = Queue::firstOrCreate(['connection' => $connection, 'tube' => $tube, 'driver' => $this->getDriverName($connection), 'healthy' => 1]); } return parent::runWorker($connection, $queue, $delay, $memory, $daemon); }
[ "protected", "function", "runWorker", "(", "$", "connection", ",", "$", "queue", ",", "$", "delay", ",", "$", "memory", ",", "$", "daemon", "=", "false", ")", "{", "if", "(", "!", "$", "daemon", ")", "{", "$", "this", "->", "worker", "->", "setCach...
This extends the Work Command for applications running Laravel version < 5.3.0. These were changes added to 5.3 onwards, so we are effectively just back porting the features to ensure consistency and adding the ability to effectively monitor what is required. We also intercept the run command and make sure we create a model to represent each queue tube for future tracking. @param string $connection @param string $queue @param int $delay @param int $memory @param bool $daemon @return array
[ "This", "extends", "the", "Work", "Command", "for", "applications", "running", "Laravel", "version", "<", "5", ".", "3", ".", "0", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/Framework/LegacyWorkCommand.php#L28-L45
eyewitness/eye
database/migrations/2017_12_01_000006_create_eyewitness_io_schedulers_table.php
CreateEyewitnessIoSchedulersTable.up
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_schedulers', function (Blueprint $table) { $table->increments('id'); $table->string('schedule', 191); $table->string('command', 191)->index(); $table->string('timezone', 191)->nullable()->default(null); $table->boolean('without_overlapping')->default(false); $table->boolean('run_in_background')->default(false); $table->boolean('on_one_server')->default(false); $table->string('mutex', 191)->unique()->index(); $table->boolean('healthy')->nullable()->default(null)->index(); $table->timestamp('next_run_due')->nullable()->default(null)->index(); $table->timestamp('next_check_due')->nullable()->default(null)->index(); $table->boolean('alert_on_missed')->default(true)->index(); $table->boolean('alert_on_fail')->default(true); $table->integer('alert_run_time_greater_than')->default(0); $table->integer('alert_run_time_less_than')->default(0); $table->timestamp('created_at')->useCurrent(); }); }
php
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_schedulers', function (Blueprint $table) { $table->increments('id'); $table->string('schedule', 191); $table->string('command', 191)->index(); $table->string('timezone', 191)->nullable()->default(null); $table->boolean('without_overlapping')->default(false); $table->boolean('run_in_background')->default(false); $table->boolean('on_one_server')->default(false); $table->string('mutex', 191)->unique()->index(); $table->boolean('healthy')->nullable()->default(null)->index(); $table->timestamp('next_run_due')->nullable()->default(null)->index(); $table->timestamp('next_check_due')->nullable()->default(null)->index(); $table->boolean('alert_on_missed')->default(true)->index(); $table->boolean('alert_on_fail')->default(true); $table->integer('alert_run_time_greater_than')->default(0); $table->integer('alert_run_time_less_than')->default(0); $table->timestamp('created_at')->useCurrent(); }); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "connection", "(", "config", "(", "'eyewitness.eyewitness_database_connection'", ")", ")", "->", "create", "(", "'eyewitness_io_schedulers'", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/database/migrations/2017_12_01_000006_create_eyewitness_io_schedulers_table.php#L14-L34
eyewitness/eye
app/Monitors/Debug.php
Debug.poll
public function poll() { if (! app()->environment('production')) { $this->eye->status()->setHealthy('debug'); return; } if (config('app.debug')) { if ($this->eye->status()->isHealthy('debug')) { $this->eye->notifier()->alert(new Enabled); } $this->eye->status()->setSick('debug'); } else { if ($this->eye->status()->isSick('debug')) { $this->eye->notifier()->alert(new Disabled); } $this->eye->status()->setHealthy('debug'); } }
php
public function poll() { if (! app()->environment('production')) { $this->eye->status()->setHealthy('debug'); return; } if (config('app.debug')) { if ($this->eye->status()->isHealthy('debug')) { $this->eye->notifier()->alert(new Enabled); } $this->eye->status()->setSick('debug'); } else { if ($this->eye->status()->isSick('debug')) { $this->eye->notifier()->alert(new Disabled); } $this->eye->status()->setHealthy('debug'); } }
[ "public", "function", "poll", "(", ")", "{", "if", "(", "!", "app", "(", ")", "->", "environment", "(", "'production'", ")", ")", "{", "$", "this", "->", "eye", "->", "status", "(", ")", "->", "setHealthy", "(", "'debug'", ")", ";", "return", ";", ...
Poll the Debug for its checks. @return void
[ "Poll", "the", "Debug", "for", "its", "checks", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Debug.php#L15-L35
eyewitness/eye
app/Repo/Model.php
Model.handleGlobalScope
protected static function handleGlobalScope($type) { if (Eye::laravelVersionIs('>=', '5.2.0')) { static::addGlobalScope('type', function (Builder $builder) use ($type) { $builder->where('type', $type); }); } else { static::addGlobalScope(new TypeLegacy($type)); } }
php
protected static function handleGlobalScope($type) { if (Eye::laravelVersionIs('>=', '5.2.0')) { static::addGlobalScope('type', function (Builder $builder) use ($type) { $builder->where('type', $type); }); } else { static::addGlobalScope(new TypeLegacy($type)); } }
[ "protected", "static", "function", "handleGlobalScope", "(", "$", "type", ")", "{", "if", "(", "Eye", "::", "laravelVersionIs", "(", "'>='", ",", "'5.2.0'", ")", ")", "{", "static", "::", "addGlobalScope", "(", "'type'", ",", "function", "(", "Builder", "$...
Add a global scope to the model. But we have to handle the different scenario, as Laravel 5.1 has a different way compared to all other versions. @param string $type @return void
[ "Add", "a", "global", "scope", "to", "the", "model", ".", "But", "we", "have", "to", "handle", "the", "different", "scenario", "as", "Laravel", "5", ".", "1", "has", "a", "different", "way", "compared", "to", "all", "other", "versions", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Repo/Model.php#L47-L57
eyewitness/eye
app/EyeServiceProvider.php
EyeServiceProvider.boot
public function boot() { $this->eye = app(Eye::class); $this->loadTools(); $this->loadRoutes(); $this->loadViews(); $this->loadConsole(); }
php
public function boot() { $this->eye = app(Eye::class); $this->loadTools(); $this->loadRoutes(); $this->loadViews(); $this->loadConsole(); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "eye", "=", "app", "(", "Eye", "::", "class", ")", ";", "$", "this", "->", "loadTools", "(", ")", ";", "$", "this", "->", "loadRoutes", "(", ")", ";", "$", "this", "->", "loadViews",...
Bootstrap the package. @return void
[ "Bootstrap", "the", "package", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/EyeServiceProvider.php#L57-L65
eyewitness/eye
app/EyeServiceProvider.php
EyeServiceProvider.loadRoutes
protected function loadRoutes() { if ($this->eye->laravelVersionIs('>=', '5.4.0')) { Route::aliasMiddleware('eyewitness_auth', Authenticate::class); } else { Route::middleware('eyewitness_auth', Authenticate::class); } if (! $this->app->routesAreCached()) { require __DIR__.'/../routes/web.php'; require __DIR__.'/../routes/assets.php'; require __DIR__.'/../routes/api.php'; require __DIR__.'/../routes/auth.php'; } }
php
protected function loadRoutes() { if ($this->eye->laravelVersionIs('>=', '5.4.0')) { Route::aliasMiddleware('eyewitness_auth', Authenticate::class); } else { Route::middleware('eyewitness_auth', Authenticate::class); } if (! $this->app->routesAreCached()) { require __DIR__.'/../routes/web.php'; require __DIR__.'/../routes/assets.php'; require __DIR__.'/../routes/api.php'; require __DIR__.'/../routes/auth.php'; } }
[ "protected", "function", "loadRoutes", "(", ")", "{", "if", "(", "$", "this", "->", "eye", "->", "laravelVersionIs", "(", "'>='", ",", "'5.4.0'", ")", ")", "{", "Route", "::", "aliasMiddleware", "(", "'eyewitness_auth'", ",", "Authenticate", "::", "class", ...
Load the package routes. @return void
[ "Load", "the", "package", "routes", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/EyeServiceProvider.php#L82-L96
eyewitness/eye
app/EyeServiceProvider.php
EyeServiceProvider.loadConsole
protected function loadConsole() { if (! $this->app->runningInConsole()) { return; } $this->publishes([__DIR__.'/../config/eyewitness.php' => config_path('eyewitness.php')]); if ($this->eye->laravelVersionIs('>=', '5.4.0')) { $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); } else { $this->publishes([__DIR__.'/../database/migrations/' => database_path('migrations')], 'eyewitness'); } $this->commands([BackgroundRunCommand::class, WitnessMakeCommand::class, RegenerateCommand::class, ComposerCommand::class, InstallCommand::class, CustomCommand::class, DebugCommand::class, PruneCommand::class, PollCommand::class, SslCommand::class, DnsCommand::class]); $this->loadEyewitnessSchedules(); $this->loadSchedulerMonitor(); $this->loadQueueMonitor(); }
php
protected function loadConsole() { if (! $this->app->runningInConsole()) { return; } $this->publishes([__DIR__.'/../config/eyewitness.php' => config_path('eyewitness.php')]); if ($this->eye->laravelVersionIs('>=', '5.4.0')) { $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); } else { $this->publishes([__DIR__.'/../database/migrations/' => database_path('migrations')], 'eyewitness'); } $this->commands([BackgroundRunCommand::class, WitnessMakeCommand::class, RegenerateCommand::class, ComposerCommand::class, InstallCommand::class, CustomCommand::class, DebugCommand::class, PruneCommand::class, PollCommand::class, SslCommand::class, DnsCommand::class]); $this->loadEyewitnessSchedules(); $this->loadSchedulerMonitor(); $this->loadQueueMonitor(); }
[ "protected", "function", "loadConsole", "(", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "runningInConsole", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../config/eyewitness.php'", "=...
Load the console. @return void
[ "Load", "the", "console", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/EyeServiceProvider.php#L113-L142
eyewitness/eye
app/EyeServiceProvider.php
EyeServiceProvider.loadEyewitnessSchedules
protected function loadEyewitnessSchedules() { $this->app->booted(function () { $schedule = $this->app->make(Schedule::class); if ($this->eye->laravelVersionIs('>=', '5.2.32') && config('eyewitness.enable_scheduler_background')) { $schedule->command('eyewitness:poll')->cron('* * * * *')->runInBackground(); $schedule->command('eyewitness:custom')->cron('* * * * *')->runInBackground(); $schedule->command('eyewitness:prune')->cron('56 1 * * *')->runInBackground(); } else { $schedule->command('eyewitness:poll')->cron('* * * * *'); $schedule->command('eyewitness:custom')->cron('* * * * *'); $schedule->command('eyewitness:prune')->cron('56 1 * * *'); } if (config('eyewitness.monitor_ssl')) { if ($this->eye->laravelVersionIs('>=', '5.2.32') && config('eyewitness.enable_scheduler_background')) { $schedule->command('eyewitness:monitor-ssl')->cron($this->eye->getMinuteSeed(1).' * * * *')->runInBackground(); $schedule->command('eyewitness:monitor-ssl --result')->cron($this->eye->getMinuteSeed(31).' * * * *')->runInBackground(); } else { $schedule->command('eyewitness:monitor-ssl')->cron($this->eye->getMinuteSeed(1).' * * * *'); $schedule->command('eyewitness:monitor-ssl --result')->cron($this->eye->getMinuteSeed(31).' * * * *'); } } if (config('eyewitness.monitor_dns')) { if ($this->eye->laravelVersionIs('>=', '5.2.32') && config('eyewitness.enable_scheduler_background')) { $schedule->command('eyewitness:monitor-dns')->cron($this->eye->getMinuteSeed(10).' * * * *')->runInBackground(); } else { $schedule->command('eyewitness:monitor-dns')->cron($this->eye->getMinuteSeed(10).' * * * *'); } } if (config('eyewitness.monitor_composer')) { if ($this->eye->laravelVersionIs('>=', '5.2.32') && config('eyewitness.enable_scheduler_background')) { $schedule->command('eyewitness:monitor-composer')->cron($this->eye->getMinuteSeed(20).' '.$this->eye->getHourSeed().' * * *')->runInBackground(); } else { $schedule->command('eyewitness:monitor-composer')->cron($this->eye->getMinuteSeed(20).' '.$this->eye->getHourSeed().' * * *'); } } }); }
php
protected function loadEyewitnessSchedules() { $this->app->booted(function () { $schedule = $this->app->make(Schedule::class); if ($this->eye->laravelVersionIs('>=', '5.2.32') && config('eyewitness.enable_scheduler_background')) { $schedule->command('eyewitness:poll')->cron('* * * * *')->runInBackground(); $schedule->command('eyewitness:custom')->cron('* * * * *')->runInBackground(); $schedule->command('eyewitness:prune')->cron('56 1 * * *')->runInBackground(); } else { $schedule->command('eyewitness:poll')->cron('* * * * *'); $schedule->command('eyewitness:custom')->cron('* * * * *'); $schedule->command('eyewitness:prune')->cron('56 1 * * *'); } if (config('eyewitness.monitor_ssl')) { if ($this->eye->laravelVersionIs('>=', '5.2.32') && config('eyewitness.enable_scheduler_background')) { $schedule->command('eyewitness:monitor-ssl')->cron($this->eye->getMinuteSeed(1).' * * * *')->runInBackground(); $schedule->command('eyewitness:monitor-ssl --result')->cron($this->eye->getMinuteSeed(31).' * * * *')->runInBackground(); } else { $schedule->command('eyewitness:monitor-ssl')->cron($this->eye->getMinuteSeed(1).' * * * *'); $schedule->command('eyewitness:monitor-ssl --result')->cron($this->eye->getMinuteSeed(31).' * * * *'); } } if (config('eyewitness.monitor_dns')) { if ($this->eye->laravelVersionIs('>=', '5.2.32') && config('eyewitness.enable_scheduler_background')) { $schedule->command('eyewitness:monitor-dns')->cron($this->eye->getMinuteSeed(10).' * * * *')->runInBackground(); } else { $schedule->command('eyewitness:monitor-dns')->cron($this->eye->getMinuteSeed(10).' * * * *'); } } if (config('eyewitness.monitor_composer')) { if ($this->eye->laravelVersionIs('>=', '5.2.32') && config('eyewitness.enable_scheduler_background')) { $schedule->command('eyewitness:monitor-composer')->cron($this->eye->getMinuteSeed(20).' '.$this->eye->getHourSeed().' * * *')->runInBackground(); } else { $schedule->command('eyewitness:monitor-composer')->cron($this->eye->getMinuteSeed(20).' '.$this->eye->getHourSeed().' * * *'); } } }); }
[ "protected", "function", "loadEyewitnessSchedules", "(", ")", "{", "$", "this", "->", "app", "->", "booted", "(", "function", "(", ")", "{", "$", "schedule", "=", "$", "this", "->", "app", "->", "make", "(", "Schedule", "::", "class", ")", ";", "if", ...
Load the eyewitness schedules into the scheduler. We use the config seeds to help spread workload across different times for every installation. This is kind to the servers, and to the 3rd party APIs. @return void
[ "Load", "the", "eyewitness", "schedules", "into", "the", "scheduler", ".", "We", "use", "the", "config", "seeds", "to", "help", "spread", "workload", "across", "different", "times", "for", "every", "installation", ".", "This", "is", "kind", "to", "the", "ser...
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/EyeServiceProvider.php#L151-L192
eyewitness/eye
app/EyeServiceProvider.php
EyeServiceProvider.registerFailingQueueHandler
protected function registerFailingQueueHandler() { if ($this->eye->laravelVersionIs('>=', '5.2.0')) { app(QueueManager::class)->failing(function (JobFailed $e) { $this->eye->queue()->failedQueue($e->connectionName, $e->job->resolveName(), $e->job->getQueue()); }); } else { app(QueueManager::class)->failing(function ($connection, $job, $data) { $this->eye->queue()->failedQueue($connection, $this->eye->queue()->resolveLegacyName($job), $job->getQueue()); }); } }
php
protected function registerFailingQueueHandler() { if ($this->eye->laravelVersionIs('>=', '5.2.0')) { app(QueueManager::class)->failing(function (JobFailed $e) { $this->eye->queue()->failedQueue($e->connectionName, $e->job->resolveName(), $e->job->getQueue()); }); } else { app(QueueManager::class)->failing(function ($connection, $job, $data) { $this->eye->queue()->failedQueue($connection, $this->eye->queue()->resolveLegacyName($job), $job->getQueue()); }); } }
[ "protected", "function", "registerFailingQueueHandler", "(", ")", "{", "if", "(", "$", "this", "->", "eye", "->", "laravelVersionIs", "(", "'>='", ",", "'5.2.0'", ")", ")", "{", "app", "(", "QueueManager", "::", "class", ")", "->", "failing", "(", "functio...
Register a failing queue hander. We need to take the Laravel version into account, because <=5.1 fires a different failing event to >=5.2. @return void
[ "Register", "a", "failing", "queue", "hander", ".", "We", "need", "to", "take", "the", "Laravel", "version", "into", "account", "because", "<", "=", "5", ".", "1", "fires", "a", "different", "failing", "event", "to", ">", "=", "5", ".", "2", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/EyeServiceProvider.php#L232-L247
eyewitness/eye
app/EyeServiceProvider.php
EyeServiceProvider.registerQueueWorker
protected function registerQueueWorker() { $this->app->singleton('queue.worker', function () { if ($this->eye->laravelVersionIs('>=', '5.3.0')) { return new Worker($this->app['queue'], $this->app['events'], $this->app[ExceptionHandler::class]); } else { return new WorkerLegacy($this->app['queue'], $this->app['queue.failer'], $this->app['events']); } }); }
php
protected function registerQueueWorker() { $this->app->singleton('queue.worker', function () { if ($this->eye->laravelVersionIs('>=', '5.3.0')) { return new Worker($this->app['queue'], $this->app['events'], $this->app[ExceptionHandler::class]); } else { return new WorkerLegacy($this->app['queue'], $this->app['queue.failer'], $this->app['events']); } }); }
[ "protected", "function", "registerQueueWorker", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'queue.worker'", ",", "function", "(", ")", "{", "if", "(", "$", "this", "->", "eye", "->", "laravelVersionIs", "(", "'>='", ",", "'5.3.0'", ...
Register a new queue worker. This allows us to capture heartbeats of the queue actually working. We need to take the Laravel version into account, because <=5.2 uses a different worker construct compared to >=5.3. @return void
[ "Register", "a", "new", "queue", "worker", ".", "This", "allows", "us", "to", "capture", "heartbeats", "of", "the", "queue", "actually", "working", ".", "We", "need", "to", "take", "the", "Laravel", "version", "into", "account", "because", "<", "=", "5", ...
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/EyeServiceProvider.php#L257-L266
eyewitness/eye
app/EyeServiceProvider.php
EyeServiceProvider.registerWorkCommand
protected function registerWorkCommand() { $this->app->extend('command.queue.work', function () { if ($this->eye->laravelVersionIs('>=', '5.3.0')) { return new WorkCommand($this->app['queue.worker']); } else { return new LegacyWorkCommand($this->app['queue.worker']); } }); }
php
protected function registerWorkCommand() { $this->app->extend('command.queue.work', function () { if ($this->eye->laravelVersionIs('>=', '5.3.0')) { return new WorkCommand($this->app['queue.worker']); } else { return new LegacyWorkCommand($this->app['queue.worker']); } }); }
[ "protected", "function", "registerWorkCommand", "(", ")", "{", "$", "this", "->", "app", "->", "extend", "(", "'command.queue.work'", ",", "function", "(", ")", "{", "if", "(", "$", "this", "->", "eye", "->", "laravelVersionIs", "(", "'>='", ",", "'5.3.0'"...
Register a new queue:work command. @return void
[ "Register", "a", "new", "queue", ":", "work", "command", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/EyeServiceProvider.php#L273-L282
eyewitness/eye
database/migrations/2017_12_01_000009_create_eyewitness_io_history_queue_table.php
CreateEyewitnessIoHistoryQueueTable.up
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_history_queue', function (Blueprint $table) { $table->increments('id'); $table->integer('queue_id')->unsigned()->index(); $table->integer('pending_count')->unsigned()->default(0); $table->integer('failed_count')->unsigned()->default(0); $table->integer('exception_count')->unsigned()->default(0); $table->decimal('sonar_time', 10,2)->unsigned()->default(0); $table->integer('sonar_count')->unsigned()->default(0); $table->decimal('process_time', 10,2)->unsigned()->default(0); $table->integer('process_count')->unsigned()->default(0); $table->integer('idle_time')->unsigned()->default(0); $table->integer('sonar_deployed')->nullable()->default(null); $table->integer('hour'); $table->date('date'); }); }
php
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_history_queue', function (Blueprint $table) { $table->increments('id'); $table->integer('queue_id')->unsigned()->index(); $table->integer('pending_count')->unsigned()->default(0); $table->integer('failed_count')->unsigned()->default(0); $table->integer('exception_count')->unsigned()->default(0); $table->decimal('sonar_time', 10,2)->unsigned()->default(0); $table->integer('sonar_count')->unsigned()->default(0); $table->decimal('process_time', 10,2)->unsigned()->default(0); $table->integer('process_count')->unsigned()->default(0); $table->integer('idle_time')->unsigned()->default(0); $table->integer('sonar_deployed')->nullable()->default(null); $table->integer('hour'); $table->date('date'); }); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "connection", "(", "config", "(", "'eyewitness.eyewitness_database_connection'", ")", ")", "->", "create", "(", "'eyewitness_io_history_queue'", ",", "function", "(", "Blueprint", "$", "table", ")", "{", ...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/database/migrations/2017_12_01_000009_create_eyewitness_io_history_queue_table.php#L14-L31
eyewitness/eye
app/Notifications/Drivers/Hipchat.php
Hipchat.fire
public function fire($recipient, $message) { $headers = [ 'connect_timeout' => 30, 'timeout' => 30, 'verify' => false, 'debug' => false, 'Content-Type' => 'application/json', 'Authorization' => 'Bearer '.$recipient->meta['token'], ]; $body = [ 'color' => $message->isError() ? 'red' : 'green', 'notify' => ($message->severity() === 'high' && $message->isError()) ? true : false, 'from' => 'Eyewitness.io', 'message_format' => 'html', 'message' => '<b>'.config('app.name', 'Your Application').': '.$message->title().'</b><br/>'.$message->markupDescription(), ]; try { app(Client::class)->post('https://api.hipchat.com/v2/room/'.$recipient->address.'/notification', [ 'body' => json_encode($body), 'headers' => $headers ]); } catch (Exception $e) { app(Eye::class)->logger()->error('Unable to send Hipchat notification', $e); } }
php
public function fire($recipient, $message) { $headers = [ 'connect_timeout' => 30, 'timeout' => 30, 'verify' => false, 'debug' => false, 'Content-Type' => 'application/json', 'Authorization' => 'Bearer '.$recipient->meta['token'], ]; $body = [ 'color' => $message->isError() ? 'red' : 'green', 'notify' => ($message->severity() === 'high' && $message->isError()) ? true : false, 'from' => 'Eyewitness.io', 'message_format' => 'html', 'message' => '<b>'.config('app.name', 'Your Application').': '.$message->title().'</b><br/>'.$message->markupDescription(), ]; try { app(Client::class)->post('https://api.hipchat.com/v2/room/'.$recipient->address.'/notification', [ 'body' => json_encode($body), 'headers' => $headers ]); } catch (Exception $e) { app(Eye::class)->logger()->error('Unable to send Hipchat notification', $e); } }
[ "public", "function", "fire", "(", "$", "recipient", ",", "$", "message", ")", "{", "$", "headers", "=", "[", "'connect_timeout'", "=>", "30", ",", "'timeout'", "=>", "30", ",", "'verify'", "=>", "false", ",", "'debug'", "=>", "false", ",", "'Content-Typ...
Fire a notification. @param \Eyewitness\Eye\Repo\Notifications\Recipient $recipient @param \Eyewitness\Eye\Notifications\Messages\MessageInterface $message @return void
[ "Fire", "a", "notification", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Drivers/Hipchat.php#L18-L45
eyewitness/eye
app/Http/Controllers/QueueController.php
QueueController.show
public function show($id) { $queue = Queue::findOrFail($id); return view('eyewitness::queue.show')->withEye(app(Eye::class)) ->withQueue($queue) ->withTransformer(new ChartTransformer); }
php
public function show($id) { $queue = Queue::findOrFail($id); return view('eyewitness::queue.show')->withEye(app(Eye::class)) ->withQueue($queue) ->withTransformer(new ChartTransformer); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "queue", "=", "Queue", "::", "findOrFail", "(", "$", "id", ")", ";", "return", "view", "(", "'eyewitness::queue.show'", ")", "->", "withEye", "(", "app", "(", "Eye", "::", "class", ")", ")"...
Show the queue. @param integer $id @return \Illuminate\Http\Response
[ "Show", "the", "queue", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/QueueController.php#L22-L29
eyewitness/eye
app/Http/Controllers/QueueController.php
QueueController.update
public function update(Request $request, $id) { $queue = Queue::findOrFail($id); $this->validate($request, [ 'alert_on_failed_job' => 'required|boolean', 'alert_heartbeat_greater_than' => 'required|numeric|min:0|max:99999', 'alert_pending_jobs_greater_than' => 'required|numeric|min:0|max:99999', 'alert_failed_jobs_greater_than' => 'required|numeric|min:0|max:99999', 'alert_wait_time_greater_than' => 'required|numeric|min:0|max:99999', ]); $queue->fill($request->only(['alert_on_failed_job', 'alert_heartbeat_greater_than', 'alert_pending_jobs_greater_than', 'alert_failed_jobs_greater_than', 'alert_wait_time_greater_than'])); $queue->save(); return redirect(route('eyewitness.queues.show', $queue->id).'#settings')->withSuccess('The queue configuration has been updated.'); }
php
public function update(Request $request, $id) { $queue = Queue::findOrFail($id); $this->validate($request, [ 'alert_on_failed_job' => 'required|boolean', 'alert_heartbeat_greater_than' => 'required|numeric|min:0|max:99999', 'alert_pending_jobs_greater_than' => 'required|numeric|min:0|max:99999', 'alert_failed_jobs_greater_than' => 'required|numeric|min:0|max:99999', 'alert_wait_time_greater_than' => 'required|numeric|min:0|max:99999', ]); $queue->fill($request->only(['alert_on_failed_job', 'alert_heartbeat_greater_than', 'alert_pending_jobs_greater_than', 'alert_failed_jobs_greater_than', 'alert_wait_time_greater_than'])); $queue->save(); return redirect(route('eyewitness.queues.show', $queue->id).'#settings')->withSuccess('The queue configuration has been updated.'); }
[ "public", "function", "update", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "queue", "=", "Queue", "::", "findOrFail", "(", "$", "id", ")", ";", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'alert_on_failed_job'", ...
Update the queue. @param Request $request @param integer $id @return \Illuminate\Http\Response
[ "Update", "the", "queue", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/QueueController.php#L38-L54
eyewitness/eye
app/Http/Controllers/QueueController.php
QueueController.destroy
public function destroy($id) { $queue = Queue::findOrFail($id); $queue->history()->delete(); $queue->delete(); return redirect(route('eyewitness.dashboard').'#queue')->withSuccess('The queue has been deleted.'); }
php
public function destroy($id) { $queue = Queue::findOrFail($id); $queue->history()->delete(); $queue->delete(); return redirect(route('eyewitness.dashboard').'#queue')->withSuccess('The queue has been deleted.'); }
[ "public", "function", "destroy", "(", "$", "id", ")", "{", "$", "queue", "=", "Queue", "::", "findOrFail", "(", "$", "id", ")", ";", "$", "queue", "->", "history", "(", ")", "->", "delete", "(", ")", ";", "$", "queue", "->", "delete", "(", ")", ...
Destroy the queue. @param integer $id @return \Illuminate\Http\Response
[ "Destroy", "the", "queue", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/QueueController.php#L62-L70
eyewitness/eye
app/Status.php
Status.isHealthy
public function isHealthy($monitor) { $result = $this->getStatus($monitor); if (is_null($result)) { return false; } return $result->healthy; }
php
public function isHealthy($monitor) { $result = $this->getStatus($monitor); if (is_null($result)) { return false; } return $result->healthy; }
[ "public", "function", "isHealthy", "(", "$", "monitor", ")", "{", "$", "result", "=", "$", "this", "->", "getStatus", "(", "$", "monitor", ")", ";", "if", "(", "is_null", "(", "$", "result", ")", ")", "{", "return", "false", ";", "}", "return", "$"...
Determine if the given monitor is healthy. @param string $monitor @return bool
[ "Determine", "if", "the", "given", "monitor", "is", "healthy", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Status.php#L42-L51
eyewitness/eye
app/Status.php
Status.isSick
public function isSick($monitor) { $result = $this->getStatus($monitor); if (is_null($result)) { return false; } return (! $result->healthy); }
php
public function isSick($monitor) { $result = $this->getStatus($monitor); if (is_null($result)) { return false; } return (! $result->healthy); }
[ "public", "function", "isSick", "(", "$", "monitor", ")", "{", "$", "result", "=", "$", "this", "->", "getStatus", "(", "$", "monitor", ")", ";", "if", "(", "is_null", "(", "$", "result", ")", ")", "{", "return", "false", ";", "}", "return", "(", ...
Determine if the given monitor is sick. @param string $monitor @return bool
[ "Determine", "if", "the", "given", "monitor", "is", "sick", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Status.php#L59-L68
eyewitness/eye
app/Status.php
Status.setStatus
public function setStatus($monitor, $status) { Statuses::where('monitor', $monitor)->delete(); Statuses::create(['monitor' => $monitor, 'healthy' => $status]); $this->status = Statuses::all(); }
php
public function setStatus($monitor, $status) { Statuses::where('monitor', $monitor)->delete(); Statuses::create(['monitor' => $monitor, 'healthy' => $status]); $this->status = Statuses::all(); }
[ "public", "function", "setStatus", "(", "$", "monitor", ",", "$", "status", ")", "{", "Statuses", "::", "where", "(", "'monitor'", ",", "$", "monitor", ")", "->", "delete", "(", ")", ";", "Statuses", "::", "create", "(", "[", "'monitor'", "=>", "$", ...
Set the status of a specific monitor @param string $monitor @param bool $status @return void
[ "Set", "the", "status", "of", "a", "specific", "monitor" ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Status.php#L114-L122
eyewitness/eye
app/Http/Controllers/Settings/SeverityController.php
SeverityController.update
public function update(Request $request) { if ($request->has('notification')) { foreach ($request->notification as $id => $severity) { if (in_array(strtolower($severity), ['low', 'medium', 'high', 'disabled'])) { Severity::where('id', $id)->update(['severity' => strtolower($severity)]); } } } return redirect(route('eyewitness.settings.index').'#severity')->withSuccess('The notification severity settings have been updated.'); }
php
public function update(Request $request) { if ($request->has('notification')) { foreach ($request->notification as $id => $severity) { if (in_array(strtolower($severity), ['low', 'medium', 'high', 'disabled'])) { Severity::where('id', $id)->update(['severity' => strtolower($severity)]); } } } return redirect(route('eyewitness.settings.index').'#severity')->withSuccess('The notification severity settings have been updated.'); }
[ "public", "function", "update", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "request", "->", "has", "(", "'notification'", ")", ")", "{", "foreach", "(", "$", "request", "->", "notification", "as", "$", "id", "=>", "$", "severity", ")", ...
Update the notifications list. It is a little ineffiecient, but the reality is this will occur very infrequently. @param Request $request @return \Illuminate\Http\Response
[ "Update", "the", "notifications", "list", ".", "It", "is", "a", "little", "ineffiecient", "but", "the", "reality", "is", "this", "will", "occur", "very", "infrequently", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/Settings/SeverityController.php#L18-L29
eyewitness/eye
app/Notifications/Messages/Ssl/GradeChange.php
GradeChange.meta
public function meta() { return [ 'Domain' => e($this->meta['domain']), 'Old grade' => e($this->meta['old_grade']), 'New grade' => e($this->meta['new_grade']), ]; }
php
public function meta() { return [ 'Domain' => e($this->meta['domain']), 'Old grade' => e($this->meta['old_grade']), 'New grade' => e($this->meta['new_grade']), ]; }
[ "public", "function", "meta", "(", ")", "{", "return", "[", "'Domain'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'domain'", "]", ")", ",", "'Old grade'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'old_grade'", "]", ")", ",", "'New gr...
Any meta information for the message. @return array
[ "Any", "meta", "information", "for", "the", "message", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Messages/Ssl/GradeChange.php#L34-L41
eyewitness/eye
app/Commands/Framework/WorkCommand.php
WorkCommand.runWorker
protected function runWorker($connection, $queue) { foreach (explode(',', $queue) as $tube) { $this->worker->eyeQueues[] = Queue::firstOrCreate(['connection' => $connection, 'tube' => $tube, 'driver' => $this->getDriverName($connection), 'healthy' => 1]); } return parent::runWorker($connection, $queue); }
php
protected function runWorker($connection, $queue) { foreach (explode(',', $queue) as $tube) { $this->worker->eyeQueues[] = Queue::firstOrCreate(['connection' => $connection, 'tube' => $tube, 'driver' => $this->getDriverName($connection), 'healthy' => 1]); } return parent::runWorker($connection, $queue); }
[ "protected", "function", "runWorker", "(", "$", "connection", ",", "$", "queue", ")", "{", "foreach", "(", "explode", "(", "','", ",", "$", "queue", ")", "as", "$", "tube", ")", "{", "$", "this", "->", "worker", "->", "eyeQueues", "[", "]", "=", "Q...
Here we intercept the run command and make sure we create a model to represent each queue tube for future tracking. @param string $connection @param string $queue @return array
[ "Here", "we", "intercept", "the", "run", "command", "and", "make", "sure", "we", "create", "a", "model", "to", "represent", "each", "queue", "tube", "for", "future", "tracking", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Commands/Framework/WorkCommand.php#L18-L28
eyewitness/eye
app/Monitors/Scheduler.php
Scheduler.poll
public function poll() { $this->checkForNewSchedulers(); foreach ($this->getMissedSchedules() as $scheduler) { $this->notifyIfChanges($scheduler); $this->setNextSchedule($scheduler); } foreach ($this->getOverdueNoExitSchedules() as $history) { $history->output = "No finish ping received by Eyewitness"; $history->exitcode = 1; $history->save(); if ($history->scheduler->alert_on_fail || ($history->scheduler->alert_run_time_greater_than > 0)) { $this->eye->notifier()->alert(new Overdue(['scheduler' => $history->scheduler])); } } foreach ($this->getConditionalSchedules() as $scheduler) { if ($this->hasNotRunInGivenTimeframe($scheduler)) { $this->notifyIfChanges($scheduler); } } }
php
public function poll() { $this->checkForNewSchedulers(); foreach ($this->getMissedSchedules() as $scheduler) { $this->notifyIfChanges($scheduler); $this->setNextSchedule($scheduler); } foreach ($this->getOverdueNoExitSchedules() as $history) { $history->output = "No finish ping received by Eyewitness"; $history->exitcode = 1; $history->save(); if ($history->scheduler->alert_on_fail || ($history->scheduler->alert_run_time_greater_than > 0)) { $this->eye->notifier()->alert(new Overdue(['scheduler' => $history->scheduler])); } } foreach ($this->getConditionalSchedules() as $scheduler) { if ($this->hasNotRunInGivenTimeframe($scheduler)) { $this->notifyIfChanges($scheduler); } } }
[ "public", "function", "poll", "(", ")", "{", "$", "this", "->", "checkForNewSchedulers", "(", ")", ";", "foreach", "(", "$", "this", "->", "getMissedSchedules", "(", ")", "as", "$", "scheduler", ")", "{", "$", "this", "->", "notifyIfChanges", "(", "$", ...
Poll the scheduler for its checks. @return void
[ "Poll", "the", "scheduler", "for", "its", "checks", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Scheduler.php#L23-L47
eyewitness/eye
app/Monitors/Scheduler.php
Scheduler.notifyIfChanges
protected function notifyIfChanges($scheduler) { if (is_null($scheduler->healthy)) { return; } if ($this->wasUpAndIsNowDown($scheduler)) { $scheduler->healthy = false; $scheduler->save(); if ($scheduler->alert_on_missed) { $this->eye->notifier()->alert(new Missed(['scheduler' => $scheduler])); } } }
php
protected function notifyIfChanges($scheduler) { if (is_null($scheduler->healthy)) { return; } if ($this->wasUpAndIsNowDown($scheduler)) { $scheduler->healthy = false; $scheduler->save(); if ($scheduler->alert_on_missed) { $this->eye->notifier()->alert(new Missed(['scheduler' => $scheduler])); } } }
[ "protected", "function", "notifyIfChanges", "(", "$", "scheduler", ")", "{", "if", "(", "is_null", "(", "$", "scheduler", "->", "healthy", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "wasUpAndIsNowDown", "(", "$", "scheduler", ")", ...
Check if the status of the scheduler has changed, and send a notification accordingly if needed. @param \Eyewitness\Eye\Repo\Scheduler $scheduler @return void
[ "Check", "if", "the", "status", "of", "the", "scheduler", "has", "changed", "and", "send", "a", "notification", "accordingly", "if", "needed", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Scheduler.php#L86-L100
eyewitness/eye
app/Monitors/Scheduler.php
Scheduler.getScheduledEvents
public function getScheduledEvents() { $schedule = app(Schedule::class); $events = array_map(function ($event) { $e = $this->convertEvent($event); return [ 'schedule' => $e->expression, 'command' => $e->getCommandName(), 'timezone' => $e->timezone, 'mutex' => $e->mutexName(), 'run_in_background' => $e->runInBackground, 'without_overlapping' => $e->withoutOverlapping, 'on_one_server' => $e->onOneServer, 'next_run_due' => $e->getNextRunDue($e->expression, $e->timezone), 'next_check_due' => $e->getNextCheckDue($e->expression, $e->timezone) ]; }, $schedule->events()); return $events; }
php
public function getScheduledEvents() { $schedule = app(Schedule::class); $events = array_map(function ($event) { $e = $this->convertEvent($event); return [ 'schedule' => $e->expression, 'command' => $e->getCommandName(), 'timezone' => $e->timezone, 'mutex' => $e->mutexName(), 'run_in_background' => $e->runInBackground, 'without_overlapping' => $e->withoutOverlapping, 'on_one_server' => $e->onOneServer, 'next_run_due' => $e->getNextRunDue($e->expression, $e->timezone), 'next_check_due' => $e->getNextCheckDue($e->expression, $e->timezone) ]; }, $schedule->events()); return $events; }
[ "public", "function", "getScheduledEvents", "(", ")", "{", "$", "schedule", "=", "app", "(", "Schedule", "::", "class", ")", ";", "$", "events", "=", "array_map", "(", "function", "(", "$", "event", ")", "{", "$", "e", "=", "$", "this", "->", "conver...
Get a list of all scheduled events and their cron frequency. @return array
[ "Get", "a", "list", "of", "all", "scheduled", "events", "and", "their", "cron", "frequency", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Scheduler.php#L152-L172
eyewitness/eye
app/Monitors/Scheduler.php
Scheduler.checkForNewSchedulers
public function checkForNewSchedulers() { $current = SchedulerRepo::all(); foreach($this->getScheduledEvents() as $event) { if (count($current->where('mutex', $event['mutex'])) < 1) { $command = new SchedulerRepo; $command->fill($event); $command->save(); } } }
php
public function checkForNewSchedulers() { $current = SchedulerRepo::all(); foreach($this->getScheduledEvents() as $event) { if (count($current->where('mutex', $event['mutex'])) < 1) { $command = new SchedulerRepo; $command->fill($event); $command->save(); } } }
[ "public", "function", "checkForNewSchedulers", "(", ")", "{", "$", "current", "=", "SchedulerRepo", "::", "all", "(", ")", ";", "foreach", "(", "$", "this", "->", "getScheduledEvents", "(", ")", "as", "$", "event", ")", "{", "if", "(", "count", "(", "$...
Check for any new schedulers, and add them to the database. @return void
[ "Check", "for", "any", "new", "schedulers", "and", "add", "them", "to", "the", "database", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Scheduler.php#L179-L190
eyewitness/eye
database/migrations/2017_12_01_000002_create_eyewitness_io_history_monitors_table.php
CreateEyewitnessIoHistoryMonitorsTable.up
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_history_monitors', function (Blueprint $table) { $table->increments('id'); $table->string('type', 191); $table->string('meta', 191); $table->string('value', 191)->nullable()->default(null); $table->text('record'); $table->timestamp('created_at')->useCurrent(); }); }
php
public function up() { Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_history_monitors', function (Blueprint $table) { $table->increments('id'); $table->string('type', 191); $table->string('meta', 191); $table->string('value', 191)->nullable()->default(null); $table->text('record'); $table->timestamp('created_at')->useCurrent(); }); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "connection", "(", "config", "(", "'eyewitness.eyewitness_database_connection'", ")", ")", "->", "create", "(", "'eyewitness_io_history_monitors'", ",", "function", "(", "Blueprint", "$", "table", ")", "{"...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/database/migrations/2017_12_01_000002_create_eyewitness_io_history_monitors_table.php#L14-L24
eyewitness/eye
app/Queue/Jobs/SonarBase.php
SonarBase.handle
public function handle() { $end_time = round((microtime(true) - $this->created)*1000); try { Cache::forget('eyewitness_q_sonar_deployed_'.$this->queue_id); Cache::put('eyewitness_q_current_wait_time_'.$this->queue_id, $end_time, 180); Cache::add('eyewitness_q_sonar_time_'.$this->queue_id, 0, 180); Cache::increment('eyewitness_q_sonar_time_'.$this->queue_id, $end_time); Cache::add('eyewitness_q_sonar_count_'.$this->queue_id, 0, 180); Cache::increment('eyewitness_q_sonar_count_'.$this->queue_id); } catch (Exception $e) { app(Eye::class)->logger()->error('Error during Sonar Handling', $e->getMessage(), ['queue_id' => $this->queue_id, 'end_time' => $end_time, 'created_time' => $this->created]); } $queue = Queue::find($this->queue_id); $queue->current_wait_time = round($end_time/1000, 2); $queue->save(); }
php
public function handle() { $end_time = round((microtime(true) - $this->created)*1000); try { Cache::forget('eyewitness_q_sonar_deployed_'.$this->queue_id); Cache::put('eyewitness_q_current_wait_time_'.$this->queue_id, $end_time, 180); Cache::add('eyewitness_q_sonar_time_'.$this->queue_id, 0, 180); Cache::increment('eyewitness_q_sonar_time_'.$this->queue_id, $end_time); Cache::add('eyewitness_q_sonar_count_'.$this->queue_id, 0, 180); Cache::increment('eyewitness_q_sonar_count_'.$this->queue_id); } catch (Exception $e) { app(Eye::class)->logger()->error('Error during Sonar Handling', $e->getMessage(), ['queue_id' => $this->queue_id, 'end_time' => $end_time, 'created_time' => $this->created]); } $queue = Queue::find($this->queue_id); $queue->current_wait_time = round($end_time/1000, 2); $queue->save(); }
[ "public", "function", "handle", "(", ")", "{", "$", "end_time", "=", "round", "(", "(", "microtime", "(", "true", ")", "-", "$", "this", "->", "created", ")", "*", "1000", ")", ";", "try", "{", "Cache", "::", "forget", "(", "'eyewitness_q_sonar_deploye...
Execute the job. @return void
[ "Execute", "the", "job", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Queue/Jobs/SonarBase.php#L63-L85
eyewitness/eye
app/Http/Controllers/NotificationsController.php
NotificationsController.show
public function show(Request $request, $id) { $notification = History::findOrFail($id); return view('eyewitness::notifications.show')->withNotification($notification); }
php
public function show(Request $request, $id) { $notification = History::findOrFail($id); return view('eyewitness::notifications.show')->withNotification($notification); }
[ "public", "function", "show", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "notification", "=", "History", "::", "findOrFail", "(", "$", "id", ")", ";", "return", "view", "(", "'eyewitness::notifications.show'", ")", "->", "withNotification...
Show the given notification. @param Request $request @param integer $id @return \Illuminate\Http\Response
[ "Show", "the", "given", "notification", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/NotificationsController.php#L19-L24
eyewitness/eye
app/Http/Controllers/NotificationsController.php
NotificationsController.update
public function update(Request $request, $id) { $notification = History::findOrFail($id); $notification->acknowledged = true; $notification->save(); return redirect(route('eyewitness.dashboard').'#notifications')->withSuccess('The notification has been acknowledged.'); }
php
public function update(Request $request, $id) { $notification = History::findOrFail($id); $notification->acknowledged = true; $notification->save(); return redirect(route('eyewitness.dashboard').'#notifications')->withSuccess('The notification has been acknowledged.'); }
[ "public", "function", "update", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "notification", "=", "History", "::", "findOrFail", "(", "$", "id", ")", ";", "$", "notification", "->", "acknowledged", "=", "true", ";", "$", "notification",...
Acknowledge the given notification. @param Request $request @param integer $id @return \Illuminate\Http\Response
[ "Acknowledge", "the", "given", "notification", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/NotificationsController.php#L33-L41
eyewitness/eye
app/Tools/ChartTransformer.php
ChartTransformer.generateScheduler
public function generateScheduler($scheduler) { if (count($this->scheduler)) { return $this->scheduler; } $history = Scheduler::where('scheduler_id', $scheduler->id)->get()->groupBy(function($item) { return $item->created_at->format('Y-m-d'); })->map(function ($row) { return round($row->avg('time_to_run'), 2); }); // Fill the array gaps - because the chart wont populate correctly without 0 values for($i=20; $i>=0; $i--) { $this->scheduler['day'][] = Carbon::now($scheduler->timezone)->subDay($i)->format('d'); if (isset($history[Carbon::now($scheduler->timezone)->subDay($i)->format('Y-m-d')])) { $this->scheduler['count'][] = $history[Carbon::now($scheduler->timezone)->subDay($i)->format('Y-m-d')]; } else { $this->scheduler['count'][] = 0; } } return $this->scheduler; }
php
public function generateScheduler($scheduler) { if (count($this->scheduler)) { return $this->scheduler; } $history = Scheduler::where('scheduler_id', $scheduler->id)->get()->groupBy(function($item) { return $item->created_at->format('Y-m-d'); })->map(function ($row) { return round($row->avg('time_to_run'), 2); }); // Fill the array gaps - because the chart wont populate correctly without 0 values for($i=20; $i>=0; $i--) { $this->scheduler['day'][] = Carbon::now($scheduler->timezone)->subDay($i)->format('d'); if (isset($history[Carbon::now($scheduler->timezone)->subDay($i)->format('Y-m-d')])) { $this->scheduler['count'][] = $history[Carbon::now($scheduler->timezone)->subDay($i)->format('Y-m-d')]; } else { $this->scheduler['count'][] = 0; } } return $this->scheduler; }
[ "public", "function", "generateScheduler", "(", "$", "scheduler", ")", "{", "if", "(", "count", "(", "$", "this", "->", "scheduler", ")", ")", "{", "return", "$", "this", "->", "scheduler", ";", "}", "$", "history", "=", "Scheduler", "::", "where", "("...
Get the scheduler data and transform it into the required format for our charts. @param \Eyewitness\Eye\Repo\Scheduler $scheduler @return array
[ "Get", "the", "scheduler", "data", "and", "transform", "it", "into", "the", "required", "format", "for", "our", "charts", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/ChartTransformer.php#L49-L73
eyewitness/eye
app/Tools/ChartTransformer.php
ChartTransformer.generateCustom
public function generateCustom($witness) { if (isset($this->custom[$witness->getSafeName()])) { return $this->custom[$witness->getSafeName()]; } $history = CustomHistory::where('meta', $witness->getSafeName())->get()->groupBy(function($item) { return $item->created_at->format('Y-m-d'); })->map(function ($row) { return round($row->filter(function($item) { return (! is_null($item->value)); })->avg('value'), 2); }); // Fill the array gaps - because the chart wont populate correctly without 0 values for($i=20; $i>=0; $i--) { $this->custom[$witness->getSafeName()]['day'][] = Carbon::now()->subDay($i)->format('d'); if (isset($history[Carbon::now()->subDay($i)->format('Y-m-d')])) { $this->custom[$witness->getSafeName()]['count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]; } else { $this->custom[$witness->getSafeName()]['count'][] = 0; } } return $this->custom[$witness->getSafeName()]; }
php
public function generateCustom($witness) { if (isset($this->custom[$witness->getSafeName()])) { return $this->custom[$witness->getSafeName()]; } $history = CustomHistory::where('meta', $witness->getSafeName())->get()->groupBy(function($item) { return $item->created_at->format('Y-m-d'); })->map(function ($row) { return round($row->filter(function($item) { return (! is_null($item->value)); })->avg('value'), 2); }); // Fill the array gaps - because the chart wont populate correctly without 0 values for($i=20; $i>=0; $i--) { $this->custom[$witness->getSafeName()]['day'][] = Carbon::now()->subDay($i)->format('d'); if (isset($history[Carbon::now()->subDay($i)->format('Y-m-d')])) { $this->custom[$witness->getSafeName()]['count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]; } else { $this->custom[$witness->getSafeName()]['count'][] = 0; } } return $this->custom[$witness->getSafeName()]; }
[ "public", "function", "generateCustom", "(", "$", "witness", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "custom", "[", "$", "witness", "->", "getSafeName", "(", ")", "]", ")", ")", "{", "return", "$", "this", "->", "custom", "[", "$", "w...
Get the witness data and transform it into the required format for our charts. @param \Eyewitness\Eye\Monitors\Custom $witness @return array
[ "Get", "the", "witness", "data", "and", "transform", "it", "into", "the", "required", "format", "for", "our", "charts", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/ChartTransformer.php#L81-L107
eyewitness/eye
app/Tools/ChartTransformer.php
ChartTransformer.generateDatabase
public function generateDatabase($connection) { if (isset($this->database[$connection])) { return $this->database[$connection]; } $history = Database::where('meta', $connection)->get()->groupBy(function($item) { return $item->created_at->format('Y-m-d'); })->map(function ($row) { return round($row->avg('value'), 2); }); // Fill the array gaps - because the chart wont populate correctly without 0 values for($i=20; $i>=0; $i--) { $this->database[$connection]['day'][] = Carbon::now()->subDay($i)->format('d'); if (isset($history[Carbon::now()->subDay($i)->format('Y-m-d')])) { $this->database[$connection]['count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]; } else { $this->database[$connection]['count'][] = 0; } } return $this->database[$connection]; }
php
public function generateDatabase($connection) { if (isset($this->database[$connection])) { return $this->database[$connection]; } $history = Database::where('meta', $connection)->get()->groupBy(function($item) { return $item->created_at->format('Y-m-d'); })->map(function ($row) { return round($row->avg('value'), 2); }); // Fill the array gaps - because the chart wont populate correctly without 0 values for($i=20; $i>=0; $i--) { $this->database[$connection]['day'][] = Carbon::now()->subDay($i)->format('d'); if (isset($history[Carbon::now()->subDay($i)->format('Y-m-d')])) { $this->database[$connection]['count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]; } else { $this->database[$connection]['count'][] = 0; } } return $this->database[$connection]; }
[ "public", "function", "generateDatabase", "(", "$", "connection", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "database", "[", "$", "connection", "]", ")", ")", "{", "return", "$", "this", "->", "database", "[", "$", "connection", "]", ";", ...
Get the database data and transform it into the required format for our charts. @param \Eyewitness\Eye\Repo\Monitors\Database $connection @return array
[ "Get", "the", "database", "data", "and", "transform", "it", "into", "the", "required", "format", "for", "our", "charts", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/ChartTransformer.php#L115-L139
eyewitness/eye
app/Tools/ChartTransformer.php
ChartTransformer.generateQueue
public function generateQueue($queue) { if (isset($this->queue[$queue->id])) { return $this->queue[$queue->id]; } $history = Queue::where('queue_id', $queue->id)->get()->groupBy(function($item) { return $item->date->format('Y-m-d'); })->map(function ($row) { return [ 'avg_wait_time' => $this->calculateAvg($row->sum('sonar_time'), $row->sum('sonar_count')), 'avg_process_time' => $this->calculateAvg($row->sum('process_time'), $row->sum('process_count')), 'total_process_count' => $row->sum('process_count'), 'avg_pending_count' => round($row->avg('pending_count')), 'idle_time' => $this->calculateTotal($row->sum('idle_time')), 'exception_count' => $this->calculateTotal($row->sum('exception_count')) ]; }); // Fill the array gaps - because the chart wont populate correctly without 0 values for($i=14; $i>=0; $i--) { $this->queue[$queue->id]['day'][] = Carbon::now()->subDay($i)->format('d'); if (isset($history[Carbon::now()->subDay($i)->format('Y-m-d')])) { $this->queue[$queue->id]['avg_wait_time'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['avg_wait_time']; $this->queue[$queue->id]['avg_process_time'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['avg_process_time']; $this->queue[$queue->id]['avg_pending_count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['avg_pending_count']; $this->queue[$queue->id]['total_process_count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['total_process_count']; $this->queue[$queue->id]['idle_time'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['idle_time']; $this->queue[$queue->id]['exception_count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['exception_count']; } else { $this->queue[$queue->id]['avg_wait_time'][] = 0; $this->queue[$queue->id]['avg_process_time'][] = 0; $this->queue[$queue->id]['avg_pending_count'][] = 0; $this->queue[$queue->id]['total_process_count'][] = 0; $this->queue[$queue->id]['idle_time'][] = 0; $this->queue[$queue->id]['exception_count'][] = 0; } } return $this->queue[$queue->id]; }
php
public function generateQueue($queue) { if (isset($this->queue[$queue->id])) { return $this->queue[$queue->id]; } $history = Queue::where('queue_id', $queue->id)->get()->groupBy(function($item) { return $item->date->format('Y-m-d'); })->map(function ($row) { return [ 'avg_wait_time' => $this->calculateAvg($row->sum('sonar_time'), $row->sum('sonar_count')), 'avg_process_time' => $this->calculateAvg($row->sum('process_time'), $row->sum('process_count')), 'total_process_count' => $row->sum('process_count'), 'avg_pending_count' => round($row->avg('pending_count')), 'idle_time' => $this->calculateTotal($row->sum('idle_time')), 'exception_count' => $this->calculateTotal($row->sum('exception_count')) ]; }); // Fill the array gaps - because the chart wont populate correctly without 0 values for($i=14; $i>=0; $i--) { $this->queue[$queue->id]['day'][] = Carbon::now()->subDay($i)->format('d'); if (isset($history[Carbon::now()->subDay($i)->format('Y-m-d')])) { $this->queue[$queue->id]['avg_wait_time'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['avg_wait_time']; $this->queue[$queue->id]['avg_process_time'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['avg_process_time']; $this->queue[$queue->id]['avg_pending_count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['avg_pending_count']; $this->queue[$queue->id]['total_process_count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['total_process_count']; $this->queue[$queue->id]['idle_time'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['idle_time']; $this->queue[$queue->id]['exception_count'][] = $history[Carbon::now()->subDay($i)->format('Y-m-d')]['exception_count']; } else { $this->queue[$queue->id]['avg_wait_time'][] = 0; $this->queue[$queue->id]['avg_process_time'][] = 0; $this->queue[$queue->id]['avg_pending_count'][] = 0; $this->queue[$queue->id]['total_process_count'][] = 0; $this->queue[$queue->id]['idle_time'][] = 0; $this->queue[$queue->id]['exception_count'][] = 0; } } return $this->queue[$queue->id]; }
[ "public", "function", "generateQueue", "(", "$", "queue", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "queue", "[", "$", "queue", "->", "id", "]", ")", ")", "{", "return", "$", "this", "->", "queue", "[", "$", "queue", "->", "id", "]", ...
Get the database data and transform it into the required format for our charts. @param \Eyewitness\Eye\Repo\Queue $queue @return array
[ "Get", "the", "database", "data", "and", "transform", "it", "into", "the", "required", "format", "for", "our", "charts", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Tools/ChartTransformer.php#L147-L188
eyewitness/eye
app/Notifications/Messages/Queue/WaitLong.php
WaitLong.meta
public function meta() { return [ 'Connection' => e($this->meta['queue']->connection), 'Queue' => e($this->meta['queue']->tube), 'Driver' => e($this->meta['queue']->driver), 'Your threshold' => e($this->meta['queue']->alert_wait_time_greater_than).'s', 'Actual job wait time' => e($this->meta['queue']->current_wait_time).'s', ]; }
php
public function meta() { return [ 'Connection' => e($this->meta['queue']->connection), 'Queue' => e($this->meta['queue']->tube), 'Driver' => e($this->meta['queue']->driver), 'Your threshold' => e($this->meta['queue']->alert_wait_time_greater_than).'s', 'Actual job wait time' => e($this->meta['queue']->current_wait_time).'s', ]; }
[ "public", "function", "meta", "(", ")", "{", "return", "[", "'Connection'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'queue'", "]", "->", "connection", ")", ",", "'Queue'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'queue'", "]", "->...
Any meta information for the message. @return array
[ "Any", "meta", "information", "for", "the", "message", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Messages/Queue/WaitLong.php#L44-L53
eyewitness/eye
app/Notifications/Messages/Scheduler/Error.php
Error.meta
public function meta() { return [ 'Command' => e($this->meta['scheduler']->command), 'Schedule' => e($this->meta['scheduler']->schedule), 'Exit Code' => e($this->meta['exitcode']) ]; }
php
public function meta() { return [ 'Command' => e($this->meta['scheduler']->command), 'Schedule' => e($this->meta['scheduler']->schedule), 'Exit Code' => e($this->meta['exitcode']) ]; }
[ "public", "function", "meta", "(", ")", "{", "return", "[", "'Command'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'scheduler'", "]", "->", "command", ")", ",", "'Schedule'", "=>", "e", "(", "$", "this", "->", "meta", "[", "'scheduler'", "]", ...
Any meta information for the message. @return array
[ "Any", "meta", "information", "for", "the", "message", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Notifications/Messages/Scheduler/Error.php#L34-L41
eyewitness/eye
app/Http/Controllers/Settings/RecipientController.php
RecipientController.destroy
public function destroy(Request $request, $id) { $recipient = Recipient::findOrFail($id); $recipient->delete(); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The recipient has been deleted. They will not receive any further notifications from Eyewitness.'); }
php
public function destroy(Request $request, $id) { $recipient = Recipient::findOrFail($id); $recipient->delete(); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The recipient has been deleted. They will not receive any further notifications from Eyewitness.'); }
[ "public", "function", "destroy", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "recipient", "=", "Recipient", "::", "findOrFail", "(", "$", "id", ")", ";", "$", "recipient", "->", "delete", "(", ")", ";", "return", "redirect", "(", "...
Delete the given recipient. @param int $id @return \Illuminate\Http\Response
[ "Delete", "the", "given", "recipient", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/Settings/RecipientController.php#L32-L38
eyewitness/eye
app/Http/Controllers/Settings/RecipientController.php
RecipientController.pushover
public function pushover(Request $request) { $this->validate($request, [ 'pushoverkey' => 'required|string|min:1|max:80', 'pushoverapi' => 'required|string|min:1|max:80', 'low' => 'required|boolean', 'medium' => 'required|boolean', 'high' => 'required|boolean', ]); Recipient::create([ 'type' => 'pushover', 'address' => $request->pushoverkey, 'meta' => ['token' => $request->pushoverapi], 'low' => $request->low, 'medium' => $request->medium, 'high' => $request->high, ]); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The Pushover recipient has been created. You can now click the button on the recipient and instantly send a "test notification" to ensure it is working.'); }
php
public function pushover(Request $request) { $this->validate($request, [ 'pushoverkey' => 'required|string|min:1|max:80', 'pushoverapi' => 'required|string|min:1|max:80', 'low' => 'required|boolean', 'medium' => 'required|boolean', 'high' => 'required|boolean', ]); Recipient::create([ 'type' => 'pushover', 'address' => $request->pushoverkey, 'meta' => ['token' => $request->pushoverapi], 'low' => $request->low, 'medium' => $request->medium, 'high' => $request->high, ]); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The Pushover recipient has been created. You can now click the button on the recipient and instantly send a "test notification" to ensure it is working.'); }
[ "public", "function", "pushover", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'pushoverkey'", "=>", "'required|string|min:1|max:80'", ",", "'pushoverapi'", "=>", "'required|string|min:1|max:80'", ",", "'...
Create a PushOver recipient. @param Request $request @return \Illuminate\Http\Response
[ "Create", "a", "PushOver", "recipient", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/Settings/RecipientController.php#L112-L132
eyewitness/eye
app/Http/Controllers/Settings/RecipientController.php
RecipientController.hipchat
public function hipchat(Request $request) { $this->validate($request, [ 'hipchattoken' => 'required|string|min:1|max:80', 'roomid' => 'required|string|min:4|max:7', 'low' => 'required|boolean', 'medium' => 'required|boolean', 'high' => 'required|boolean', ]); Recipient::create([ 'type' => 'hipchat', 'address' => $request->roomid, 'meta' => ['token' => $request->hipchattoken], 'low' => $request->low, 'medium' => $request->medium, 'high' => $request->high, ]); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The HipChat recipient has been created. You can send a test notification to ensure it is working by click on the button next to the recipient.'); }
php
public function hipchat(Request $request) { $this->validate($request, [ 'hipchattoken' => 'required|string|min:1|max:80', 'roomid' => 'required|string|min:4|max:7', 'low' => 'required|boolean', 'medium' => 'required|boolean', 'high' => 'required|boolean', ]); Recipient::create([ 'type' => 'hipchat', 'address' => $request->roomid, 'meta' => ['token' => $request->hipchattoken], 'low' => $request->low, 'medium' => $request->medium, 'high' => $request->high, ]); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The HipChat recipient has been created. You can send a test notification to ensure it is working by click on the button next to the recipient.'); }
[ "public", "function", "hipchat", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'hipchattoken'", "=>", "'required|string|min:1|max:80'", ",", "'roomid'", "=>", "'required|string|min:4|max:7'", ",", "'low'",...
Create a HipChat recipient. @param Request $request @return \Illuminate\Http\Response
[ "Create", "a", "HipChat", "recipient", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/Settings/RecipientController.php#L166-L186
eyewitness/eye
app/Http/Controllers/Settings/RecipientController.php
RecipientController.webhook
public function webhook(Request $request) { $this->validate($request, [ 'webhook' => 'required|url', 'low' => 'required|boolean', 'medium' => 'required|boolean', 'high' => 'required|boolean', ]); Recipient::create([ 'type' => 'webhook', 'address' => $request->webhook, 'low' => $request->low, 'medium' => $request->medium, 'high' => $request->high, ]); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The Webhook recipient has been created. You can now click the button on the recipient and instantly send a "test notification" to ensure it is working.'); }
php
public function webhook(Request $request) { $this->validate($request, [ 'webhook' => 'required|url', 'low' => 'required|boolean', 'medium' => 'required|boolean', 'high' => 'required|boolean', ]); Recipient::create([ 'type' => 'webhook', 'address' => $request->webhook, 'low' => $request->low, 'medium' => $request->medium, 'high' => $request->high, ]); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The Webhook recipient has been created. You can now click the button on the recipient and instantly send a "test notification" to ensure it is working.'); }
[ "public", "function", "webhook", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'webhook'", "=>", "'required|url'", ",", "'low'", "=>", "'required|boolean'", ",", "'medium'", "=>", "'required|boolean'",...
Create a Webhook recipient. @param Request $request @return \Illuminate\Http\Response
[ "Create", "a", "Webhook", "recipient", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/Settings/RecipientController.php#L194-L212
eyewitness/eye
app/Http/Controllers/Settings/RecipientController.php
RecipientController.nexmo
public function nexmo(Request $request) { $this->validate($request, [ 'nexmo_phone' => 'required|string', 'nexmo_api_key' => 'required|string', 'nexmo_api_secret' => 'required|string', 'low' => 'required|boolean', 'medium' => 'required|boolean', 'high' => 'required|boolean', ]); Recipient::create([ 'type' => 'nexmo', 'address' => $request->nexmo_phone, 'meta' => [ 'api_key' => $request->nexmo_api_key, 'api_secret' => $request->nexmo_api_secret, ], 'low' => $request->low, 'medium' => $request->medium, 'high' => $request->high, ]); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The Nexmo recipient has been created. You can now click the button on the recipient and instantly send a "test notification" to ensure it is working.'); }
php
public function nexmo(Request $request) { $this->validate($request, [ 'nexmo_phone' => 'required|string', 'nexmo_api_key' => 'required|string', 'nexmo_api_secret' => 'required|string', 'low' => 'required|boolean', 'medium' => 'required|boolean', 'high' => 'required|boolean', ]); Recipient::create([ 'type' => 'nexmo', 'address' => $request->nexmo_phone, 'meta' => [ 'api_key' => $request->nexmo_api_key, 'api_secret' => $request->nexmo_api_secret, ], 'low' => $request->low, 'medium' => $request->medium, 'high' => $request->high, ]); return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The Nexmo recipient has been created. You can now click the button on the recipient and instantly send a "test notification" to ensure it is working.'); }
[ "public", "function", "nexmo", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'nexmo_phone'", "=>", "'required|string'", ",", "'nexmo_api_key'", "=>", "'required|string'", ",", "'nexmo_api_secret'", "=>",...
Create a Nexmo recipient. @param Request $request @return \Illuminate\Http\Response
[ "Create", "a", "Nexmo", "recipient", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Http/Controllers/Settings/RecipientController.php#L220-L244
eyewitness/eye
app/Monitors/Custom.php
Custom.history
public function history() { if (is_null($this->history)) { $this->history = History::where('meta', $this->getSafeName()) ->latest() ->get(); } return $this->history; }
php
public function history() { if (is_null($this->history)) { $this->history = History::where('meta', $this->getSafeName()) ->latest() ->get(); } return $this->history; }
[ "public", "function", "history", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "history", ")", ")", "{", "$", "this", "->", "history", "=", "History", "::", "where", "(", "'meta'", ",", "$", "this", "->", "getSafeName", "(", ")", ")"...
Return an eloquent respresentation of the Witness history. @return \Eyewitness\Eye\Repo\History\Custom
[ "Return", "an", "eloquent", "respresentation", "of", "the", "Witness", "history", "." ]
train
https://github.com/eyewitness/eye/blob/5f81f75209a68953242a0c6b33f4c860bb1b392a/app/Monitors/Custom.php#L162-L171