DEV Community

Cover image for Introducing AppPulse: A Laravel Monitoring Package for Uptime and SSL Checks
Nasrul Hazim Bin Mohamad
Nasrul Hazim Bin Mohamad

Posted on

Introducing AppPulse: A Laravel Monitoring Package for Uptime and SSL Checks

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

  1. Install via Composer:
   composer require cleaniquecoders/app-pulse
Enter fullscreen mode Exit fullscreen mode
  1. Publish Configuration and Migrations:
   php artisan vendor:publish --tag="app-pulse-config"
   php artisan vendor:publish --tag="app-pulse-migrations"
   php artisan migrate
Enter fullscreen mode Exit fullscreen mode
  1. 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
Enter fullscreen mode Exit fullscreen mode

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
]);
Enter fullscreen mode Exit fullscreen mode

Running Checks Manually

To trigger the checks for all monitors:

php artisan monitor:check-status
Enter fullscreen mode Exit fullscreen mode

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
    ],
];
Enter fullscreen mode Exit fullscreen mode

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)