Tracking your website’s uptime and SSL certificate validity has never been easier with AppPulse. Built specifically for Laravel, this package offers a powerful, flexible solution to monitor website performance without friction.
Explore the package on GitHub:
🔗 AppPulse on GitHub
Key Features of AppPulse
- Uptime Tracking: Log and monitor response times to ensure site availability.
- SSL Certificate Validation: Detect SSL expiry in advance and act before downtime.
- Event-Driven Notifications: Developers can hook into events to trigger custom actions.
- Queue and Scheduler: Use Laravel’s queue system for smooth, asynchronous checks.
- Highly Configurable: Define how often checks are performed and manage event listeners directly from the configuration.
How to Install AppPulse
- Install via Composer:
composer require cleaniquecoders/app-pulse
- Publish Configuration and Migrations:
php artisan vendor:publish --tag="app-pulse-config"
php artisan vendor:publish --tag="app-pulse-migrations"
php artisan migrate
- Set up Laravel’s Scheduler:
Add the following cron entry to your server to ensure checks run automatically:
* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
The package will handle all checks according to the interval specified in the configuration.
Usage
Creating a Monitor Record
use CleaniqueCoders\AppPulse\Models\Monitor;
$monitor = Monitor::create([
'owner_type' => \App\Models\User::class, // The owner model
'owner_id' => 1, // Owner ID (e.g., User or Application)
'url' => 'https://example.com', // URL to monitor
'interval' => 5, // Check interval in minutes
'ssl_check' => true, // Enable SSL monitoring
]);
Running Checks Manually
To trigger the checks for all monitors:
php artisan monitor:check-status
Event-Driven Architecture
AppPulse allows developers to extend its functionality by registering custom event listeners. You can configure which listeners should handle the events directly from the configuration file.
Here’s an example configuration:
<?php
use CleaniqueCoders\AppPulse\Events\MonitorUptimeChanged;
use CleaniqueCoders\AppPulse\Events\SslStatusChanged;
return [
'events' => [
MonitorUptimeChanged::class => [
\App\Listeners\HandleUptimeChange::class,
],
SslStatusChanged::class => [
\App\Listeners\HandleSslAlert::class,
],
],
'scheduler' => [
'interval' => env('APP_PULSE_SCHEDULER_INTERVAL', 10), // Run every 10 minutes
'queue' => env('APP_PULSE_SCHEDULER_QUEUE', 'default'), // Queue to use
'chunk' => env('APP_PULSE_SCHEDULER_CHUNK', 100), // Monitors per batch
],
];
When the uptime or SSL status changes, the configured listeners will be triggered.
Conclusion
AppPulse offers a simple but powerful way to monitor websites, combining uptime tracking, SSL validation, and Laravel's event-driven architecture. Developers can easily customize behavior through events and manage all configurations via a simple config file.
Visit the GitHub repository to explore more or contribute:
🔗 AppPulse on GitHub
Enjoy using AppPulse and keep your websites up and running smoothly! 🚀
Photo by Artur Łuczka on Unsplash
Top comments (0)