All Projects → brightmachine → Scrutiny

brightmachine / Scrutiny

Licence: mit
Ensure your laravel-based project is running in the correct server environment

Projects that are alternatives of or similar to Scrutiny

Laracms
LaraCMS 是在学习 laravel ( web 开发实战进阶 + 实战构架 API 服务器) 过程中产生的一个业余作品,试图通过简单的方式,快速构建一套基本的企业站同时保留很灵活的扩展能力和优雅的代码方式,当然这些都得益Laravel的优秀设计。同时LaraCMS 也是一个学习Laravel 不错的参考示例。
Stars: ✭ 588 (+1533.33%)
Mutual labels:  laravel, laravel5
Laravel Widgetize
A minimal package to help you make your laravel application cleaner and faster.
Stars: ✭ 791 (+2097.22%)
Mutual labels:  laravel, laravel5
Lang
List of 78 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.
Stars: ✭ 6,285 (+17358.33%)
Mutual labels:  laravel, laravel5
Laravel Google Cloud Storage
A Google Cloud Storage filesystem for Laravel
Stars: ✭ 415 (+1052.78%)
Mutual labels:  laravel, laravel5
Laravel Restaurant Pos
Restaurant POS
Stars: ✭ 27 (-25%)
Mutual labels:  laravel, laravel5
Framework
The truly Laravel E-commerce Framework
Stars: ✭ 456 (+1166.67%)
Mutual labels:  laravel, laravel5
Twitter
Twitter API for Laravel 5.5+, 6.x, 7.x & 8.x
Stars: ✭ 755 (+1997.22%)
Mutual labels:  laravel, laravel5
Laravel Recaptcha
Google ReCaptcha package for Laravel
Stars: ✭ 273 (+658.33%)
Mutual labels:  laravel, laravel5
Blade Migrations Laravel
An intelligent alternative version of Laravel 5/6 Database Migrations - uses raw-sql syntax, transactions, auto-rollback, UP-DOWN-UP testing
Stars: ✭ 25 (-30.56%)
Mutual labels:  laravel, laravel5
Barryvanveen
📰 Personal blog of Barry van Veen. Focuses on Laravel Framework, website optimization and natural computing.
Stars: ✭ 24 (-33.33%)
Mutual labels:  laravel, laravel5
Laravel Blade
This package adds syntax definitions for the Laravel Blade engine.
Stars: ✭ 395 (+997.22%)
Mutual labels:  laravel, laravel5
Easyhttp
A Laravel HTTP-client to make HTTP request easier and log requests and responses
Stars: ✭ 20 (-44.44%)
Mutual labels:  laravel, laravel5
Coastercms
The repository for Coaster CMS (coastercms.org), a full featured, Laravel based Content Management System
Stars: ✭ 380 (+955.56%)
Mutual labels:  laravel, laravel5
Fullycms
Fully CMS - Multi Language Content Management System - Laravel
Stars: ✭ 465 (+1191.67%)
Mutual labels:  laravel, laravel5
Laravel5 Jsonapi
Laravel 5 JSON API Transformer Package
Stars: ✭ 313 (+769.44%)
Mutual labels:  laravel, laravel5
Laravel User Verification
PHP package built for Laravel 5.* to easily handle a user email verification and validate the email
Stars: ✭ 755 (+1997.22%)
Mutual labels:  laravel, laravel5
Api Generator
PHP-code generator for Laravel framework, with complete support of JSON-API data format
Stars: ✭ 244 (+577.78%)
Mutual labels:  laravel, laravel5
Cors
🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.
Stars: ✭ 266 (+638.89%)
Mutual labels:  laravel, laravel5
Angular5.2 Laravel5.6
Angular 5.2 and Laravel 5.6 Authentication and CRUD
Stars: ✭ 17 (-52.78%)
Mutual labels:  laravel, laravel5
Foocart
A Laravel 5 eCommerce application with integrated Stripe payments.
Stars: ✭ 8 (-77.78%)
Mutual labels:  laravel, laravel5

Scrutiny

Scrutiny helps your Laravel 5.1+ project ensure that its current server environment is configured and running as planned.

Latest Stable Version Total Downloads License

Problem

Have you ever been in the situation where you've moved servers and forgotten to:

  1. Get your queue running?
  2. Add the cron job to run your schedule?
  3. Install an obscure program that your reporting uses once a month?
  4. Enable a PHP extension that you need for an API?

This is the scenario Scrutiny was built to address – use the availability monitor you have setup (like pingdom) to also monitor other important aspects of your environment.

This means your availability monitor notifies you of any problems with your server environment setup instead of waiting for your clients or customers to tell you something is wrong.

Installation

To install through composer, add the following to your composer.json file:

{
    "require": {
        "brightmachine/scrutiny": "~1.0"
    }
}

And then run composer install from the terminal.

Quick Installation

The installation instructions can be simplified using the following:

composer require "brightmachine/scrutiny=~1.0"

Add the Service Provider

Open config/app.php and the scrutiny service provider to :

'providers' => [
    // …
    Scrutiny\ServiceProvider::class,
],

You are all setup – next step it to add your probes!

How it works

  1. In AppServiceProvider::boot(), configure the probes to check for all the things your environment needs in order to run
  2. Set up an uptime check in Pingdom to alert you if any of the probes fail to pass

How to configure the different probes

<?php
namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider 
{
    public function boot()
    {
        // …
        $this->configureScrutinyProbes();
    }
    
    public function register()
    {
    }
    
    protected function configureScrutinyProbes()
    {
        \Scrutiny\ProbeManager::configure()
            ->connectsToDatabase()
            ->executableIsInstalled('composer.phar')
            ->queueIsRunning(30, 'high')
            ->queueIsRunning(60, 'low')
            ;
    }
}


What probes are available

All probes are added through \Scrutiny\ProbeManager and calls can be chained:

\Scrutiny\ProbeManager::configure()->scheduleIsRunning()->queueIsRunning();

The following probes are available via \Scrutiny\ProbeManager::configure():

availableDiskSpace()

Ensure that you always have space available.

It works by finding the disk related to a given folder and checking its usage.

public availableDiskSpace( number $minPercentage [, string $diskFolder = null ] )
  • $minPercentage is the minimum amount of disk space that should be available
  • $diskFolder the folder used to find the disk. Defaults to the disk storing your laravel app.

callback()

If your use-case isn't supported out-of-the-box you can write your own custom probe.

When a probe is checked, 3 outcomes are possible:

  1. Skipped – if a \Scrutiny\ProbeSkippedException exception is thrown
  2. Failed – if any other exception is thrown
  3. Passed – if no exception is thrown
public callback( string $probeName , callable $callback )
  • $probeName the name of the probe used to report the results of the check
  • $callback the callback that runs your custom check

connectsToDatabase()

Check that you're able to connect to one of your databases configured on config/database.php.

public connectsToDatabase([ string $connectionName = null ])
  • $connectionName is the name of your database connection from config/database.php

connectsToHttp()

This probe checks that a given URL will return a 2xx response.

NB: Redirects will not be followed – only the first response will be considered.

public connectsToHttp( string $url [, array $params = array(), string $verb = 'GET' ] )
  • $url the URL to check, which can contain a username and password, e.g. https://[email protected]:example.com
  • $params an array of URL parameters to add to the request
  • $verb either GET or POST

executableIsInstalled()

This probe will search your path, and your current vendor/bin looking for a particular executable.

public executableIsInstalled( string $executableName )
  • $executableName the name of the executable to find

phpExtensionLoaded()

Check that a particular PHP extension is loaded.

public phpExtensionLoaded( string $extensionName )
  • $extensionName the name of the PHP extension to check

queueIsRunning()

This probe checks that your laravel queue is running.

public queueIsRunning( [ int $maxHandleTime = 300, $queue = null, $connection = null ] )
  • $maxHandleTime the maximum time in seconds that you give a job to run on the given queue
  • $queue if you run multiple queues on the same connection, this is the name of the queue to check
  • $connection if you run multiple connections, this is the one to check as configured in config/queue.php

scheduleIsRunning()

Make sure that the artisan schedule is being run.

public scheduleIsRunning()

Customising the name of your probe

By default, when scrutiny outputs details of your probe (e.g. if it fails, or in the history) it guesses a name based on the configuration setting.

If this default name would output sensitive information, such as API keys, then you'll want to set the name of the probe.

public named( string $identifier )

You override the name by calling ->named() after you set the probe:

\Scrutiny\ProbeManager::configure()
    ->connectsToHttp('https://api.example.com/me?api_key=12345678900987654321')
    ->named('example.com API');

Customising the executable search path

Certain probes will need to search for a certain executable on disk.

By default, scrutiny will search directories in your $PATH environment variable as well as your base_path() and your vendor/bin.

But this isn't always enough.

You can add directories to the path when you configure your probes:

\Scrutiny\ProbeManager::extraDirs([
    '/usr/local/bin/',
    '/var/www/bin',
]);

Debugging locally

Your configured probes are rate-limited to 1 check every minute.

This isn't what you want when first setting up your probes, so to bypass this locally set DEBUG=true in your .env file.


Artisan command

Run php artisan scrutiny:check-probes to check if your probes are passing.

This command is not rate-limited, so it's a good way to test immediately after making a change, or even as part of a deployment process.

The command will return 0 on success and 1 on failure.


How to configure pingdom

Configure a new check in pingdom with the following setting:

  1. Add an uptime check in pingdom to hit https://yourdomain.com/~scrutiny/check-probes where yourdomain.com is your production domain
  2. Scrutiny will return an HTTP status of 590 Some Tests Failed when something is awry – this is a custom code

Contributing

Any contribution is received with humility and gratitude.

Thank you if you're considering contributing an improvement to this project.

Process:

  1. Fork, change, create pull-request
  2. Tell us why/how your PR will benefit the project
  3. We may ask you for clarification, but we'll quickly let you know whether or not it's likely your change will be merged

😘 Xx

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].