idfx/laravel-disk-monitor

Monitor metrics of Laravel disk

0.0.1 2025-03-12 18:18 UTC

This package is auto-updated.

Last update: 2025-03-12 18:31:49 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Monitors the metrics of disks used by Laravel - Spatie package training.

Installation

You can install the package via composer:

composer require idfx/laravel-disk-monitor

You can publish and run the migrations with:

php artisan vendor:publish --tag="disk-monitor-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="disk-monitor-config"

This is the contents of the published config file:

return [
    /**
     * Name of the disk you want to monitor.
     */
    'disk_names' => [
        'local',
    ],
];

Finally, you should schedule the Spatie\DiskMonitor\Commands\RecordsDiskMetricsCommand to run daily.

// in app/Console/Kernel.php

use \Spatie\DiskMonitor\Commands\RecordsDiskMetricsCommand;

class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule)
    {
       // ...
        $schedule->command(RecordsDiskMetricsCommand::class)->daily();
    }
}

Optionally, you can publish the views using

php artisan vendor:publish --tag="disk-monitor-views"

Usage

You can view the amount of files each monitored disk has, in the disk_monitor_entries table.

If you want to view the statistics in the browser add this macro to your routes file.

// in a routes files

Route::diskMonitor('my-disk-monitor-url');

Now, you can see all statics when browsing /my-disk-monitor-url. Of course, you can use any url you want when using the diskMonitor route macro. We highly recommand using the auth middleware for this route, so guests can't see any data regarding your disks.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.