Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Cpu Load Health Check

Cpu Load Health Check Laravel Package

spatie/cpu-load-health-check

Laravel Health check for monitoring CPU load. Configure thresholds (e.g., average load over the last 5 minutes) and get notifications when load is too high. Integrates seamlessly with spatie/laravel-health.

View on GitHub
Deep Wiki
Context7

A Laravel Health check to monitor CPU load

Frequently asked questions about Cpu Load Health Check
How do I add CPU load monitoring to my Laravel Health dashboard?
Install the package via Composer (`composer require spatie/cpu-load-health-check`), then register the check in your `AppServiceProvider` using `Health::checks([CpuLoadCheck::new()->failWhenLoadIsHigherInTheLast5Minutes(1.2)])`. Replace `1.2` with your desired threshold. The check will appear in your Laravel Health dashboard.
What Laravel versions does this package support?
This package is compatible with Laravel 8.x and 9.x, including the latest LTS versions. It requires PHP 8.1 or higher. Check the [Laravel Health docs](https://spatie.be/docs/laravel-health) for full compatibility details.
Can I configure custom time windows for CPU load checks?
Yes. Use methods like `failWhenLoadIsHigherInTheLastMinute()`, `failWhenLoadIsHigherInTheLast5Minutes()`, or `failWhenLoadIsHigherInTheLast15Minutes()` to set the time window for averaging CPU load. For example, `CpuLoadCheck::new()->failWhenLoadIsHigherInTheLast5Minutes(1.5)`.
Will this package work with Laravel Queues or cron jobs?
Yes, the CPU load check runs independently of HTTP requests, so it works with queued jobs and cron tasks. However, ensure your thresholds account for spikes from batch processing or scheduled tasks to avoid false positives.
How do I integrate CPU load alerts with Slack or email?
Configure notifications in your `config/health.php` file. Use the `notifications` key to specify channels like Slack or email. The package leverages Laravel Health’s notification system, so ensure you’ve set up your preferred channels in the Laravel Health configuration.
Does this package work in multi-server deployments?
This package checks CPU load on the local server only. For multi-server monitoring, you’ll need to run Laravel Health on each server or aggregate metrics externally (e.g., using Prometheus or a custom script). Consider tools like Grafana for cluster-wide visibility.
How do I test CPU load thresholds in staging before production?
Start with conservative thresholds (e.g., `1.0` for 5 minutes) and gradually adjust based on staging workloads. Use Laravel’s `Health::check()` method to manually trigger checks during testing. Monitor false positives and refine thresholds to match your app’s typical CPU usage patterns.
Can I use this package without Laravel Health?
No, this package is designed specifically for Laravel Health. It requires the `spatie/laravel-health` package as a dependency. If you’re not already using Laravel Health, you’ll need to install it first (`composer require spatie/laravel-health`).
What happens if CPU load spikes temporarily (e.g., during backups)?
The package uses averaging over your configured time window (e.g., 5 minutes), so short spikes may not trigger alerts. For example, a 10-second spike won’t fail if the average over 5 minutes stays below your threshold. Adjust the time window or threshold to match your use case.
Are there alternatives for CPU monitoring in Laravel?
Yes. For lightweight checks, consider `spatie/laravel-health` with custom checks or third-party tools like `blackfire/php` for deep profiling. For production-grade monitoring, cloud providers (AWS CloudWatch, GCP Operations) or APM tools (Datadog, New Relic) offer broader observability, including CPU metrics and alerts.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport