1. Go to this page and download the library: Download net-os/laravel-vitals 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/ */
net-os / laravel-vitals example snippets
use NetOs\Vitals\Checks;
use NetOs\Vitals\Facades\Vitals;
use NetOs\Vitals\Tenancy\TenantReference;
Vitals::central([
Checks\DatabaseCheck::new(),
Checks\CacheCheck::new(),
Checks\RedisCheck::new()->failWhenMemoryAboveMb(500),
Checks\DiskSpaceCheck::new()->warnWhenUsedAbove(80)->failWhenUsedAbove(90),
Checks\FailedJobsCheck::new(),
Checks\HorizonCheck::new(),
Checks\SchedulerHeartbeatCheck::new()->everyMinute(),
Checks\DebugModeCheck::new(),
Checks\EnvironmentCheck::new(),
Checks\OptimizedAppCheck::new(),
]);
Vitals::tenant([
Checks\TenantDatabaseCheck::new(),
Checks\PendingMigrationsCheck::new()->hourly(),
DeviceSyncCheck::new()->onlyFor(fn (TenantReference $tenant) => $tenant->model->hasDevices()),
]);
use NetOs\Vitals\Check;
use NetOs\Vitals\Result;
class Auth0SyncCheck extends Check
{
public function run(): Result
{
$lastSync = SyncLog::latest()->first();
if ($lastSync === null) {
return Result::warning('No sync has run yet');
}
return $lastSync->succeeded
? Result::ok("Synced {$lastSync->users} users")
: Result::failed($lastSync->error)->meta(['last_sync' => $lastSync->created_at->toDateTimeString()]);
}
}