PHP code example of sixtec / monitor

1. Go to this page and download the library: Download sixtec/monitor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sixtec / monitor example snippets


use Illuminate\Support\Facades\Http;
use Sixtec\Monitor\Contracts\Probe;
use Sixtec\Monitor\Result;

class AsaasProbe implements Probe
{
    public function check(): iterable
    {
        if (blank(config('services.asaas.key'))) {
            return; // not configured here: no component
        }

        $response = Http::timeout(5)->withToken(config('services.asaas.key'))->get('https://api.asaas.com/v3/myAccount');

        yield $response->successful()
            ? Result::ok('asaas', 'Asaas', 'API reachable', (int) ($response->handlerStats()['total_time'] * 1000))
            : Result::critical('asaas', 'Asaas', "API answered HTTP {$response->status()}");
    }
}

// config/sixtec-monitor.php
'extra_probes' => [App\Monitoring\AsaasProbe::class],
bash
# non-interactive
php artisan sixtec:monitor:install --key=sxs_... --mode=service
php artisan sixtec:monitor:install --key=sxs_... --mode=scheduler --cron-minutes=15
bash
php artisan vendor:publish --tag=sixtec-monitor-config