PHPackages                             tivents/laravel-cron-monitor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. tivents/laravel-cron-monitor

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

tivents/laravel-cron-monitor
============================

Ein Laravel-Paket zur externen Überwachung von Cron-Jobs

0133PHPCI failing

Since Mar 6Pushed 2mo agoCompare

[ Source](https://github.com/tivents/laravel-external-cron-monitor)[ Packagist](https://packagist.org/packages/tivents/laravel-cron-monitor)[ RSS](/packages/tivents-laravel-cron-monitor/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Cron Monitor
====================

[](#laravel-cron-monitor)

[![Tests](https://github.com/tivents/laravel-cron-monitor/workflows/tests/badge.svg)](https://github.com/tivents/laravel-cron-monitor/actions)[![Latest Stable Version](https://camo.githubusercontent.com/d760e365d12cb8e1c305eb38d12bfa879444c9bb30419faed81c51398ad60009/68747470733a2f2f706f7365722e707567782e6f72672f746976656e74732f6c61726176656c2d63726f6e2d6d6f6e69746f722f762f737461626c65)](https://packagist.org/packages/tivents/laravel-cron-monitor)[![License](https://camo.githubusercontent.com/e6bfea59021c3f04524f233cd92f7572b95e752018f520b9d504f00a1a7161b9/68747470733a2f2f706f7365722e707567782e6f72672f746976656e74732f6c61726176656c2d63726f6e2d6d6f6e69746f722f6c6963656e7365)](https://packagist.org/packages/tivents/laravel-cron-monitor)

A Laravel package for external monitoring of scheduled tasks (cron jobs). This package automatically tracks the execution of your Laravel scheduled tasks and reports metrics to an external monitoring service.

Features
--------

[](#features)

- **Automatic Task Monitoring**: Automatically monitors all Laravel scheduled tasks
- **Performance Metrics**: Tracks execution time, memory usage, and system performance
- **Error Reporting**: Captures and reports failed tasks with exception details
- **External Reporting**: Sends monitoring data to external services via HTTP API
- **System Metrics**: Includes CPU usage, memory consumption, and system load
- **Configurable**: Easy configuration for different environments
- **Singleton Pattern**: Efficient resource usage with singleton design
- **Cross-Platform**: Works on Windows, Linux, and macOS

Installation
------------

[](#installation)

You can install the package via Composer:#

```
composer require tivents/laravel-cron-monitor
```

### Laravel Auto-Discovery

[](#laravel-auto-discovery)

The package will automatically register itself via Laravel's package auto-discovery feature.

For Laravel versions &lt; 5.5, you need to manually register the service provider in `config/app.php`:

```
'providers' => [ // Other Service Providers Tivents\CronMonitor\CronMonitorServiceProvider::class, ];
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=cron-monitor-config
```

This will create a `config/cron-monitor.php` file with the following structure:

```
env('CRON_MONITOR_API_KEY'),
'endpoint' => env('CRON_MONITOR_ENDPOINT'),
/* |-------------------------------------------------------------------------- | Performance Monitoring |-------------------------------------------------------------------------- */
'track_performance' => env('CRON_MONITOR_TRACK_PERFORMANCE', true),
'track_memory' => env('CRON_MONITOR_TRACK_MEMORY', true),
'track_cpu' => env('CRON_MONITOR_TRACK_CPU', true),
/* |-------------------------------------------------------------------------- | Alert Configuration |-------------------------------------------------------------------------- */
'alerts' => [
    'slack_webhook' => env('CRON_MONITOR_SLACK_WEBHOOK'),
    ],
];
```

### Environment Variables

[](#environment-variables)

Add the following variables to your `.env` file:

```
CRON_MONITOR_API_KEY=your-api-key-here
CRON_MONITOR_ENDPOINT=[https://your-monitoring-service.com/api/](https://your-monitoring-service.com/api/)
CRON_MONITOR_TRACK_PERFORMANCE=true
CRON_MONITOR_TRACK_MEMORY=true
CRON_MONITOR_TRACK_CPU=true
CRON_MONITOR_SLACK_WEBHOOK=[https://hooks.slack.com/services/your/slack/webhook](https://hooks.slack.com/services/your/slack/webhook)
```

Usage
-----

[](#usage)

Once installed and configured, the package will automatically monitor all your Laravel scheduled tasks. No additional code changes are required.

### Scheduled Tasks

[](#scheduled-tasks)

The package monitors these Laravel console events:

- `ScheduledTaskStarting` - When a task begins execution
- `ScheduledTaskFinished` - When a task completes successfully
- `ScheduledTaskFailed` - When a task fails with an exception

### Monitored Data

[](#monitored-data)

For each task execution, the following data is collected and sent to your monitoring service:

- **Basic Information**:

    - Task command/description
    - Application name
    - Execution timestamp
    - Task ID (unique identifier)
    - Status (finished/failed)
- **Performance Metrics**:

    - Duration in seconds and milliseconds
    - Memory usage (peak and current)
    - CPU usage (when available)
    - System load (Unix/Linux systems)
- **Error Details** (for failed tasks):

    - Exception message
    - Full error context

### Example Monitored Task

[](#example-monitored-task)

```
// In your app/Console/Kernel.php
protected function schedule(Schedule schedule) {
$schedule->command('emails:send') ->daily() ->at('08:00');
$schedule->command('backup:run')
         ->weekly()
         ->sundays()
         ->at('02:00');
}
```

Both of these tasks will be automatically monitored without any additional configuration.

API Payload Example
-------------------

[](#api-payload-example)

The package sends HTTP POST requests to your configured endpoint with payloads like this:

```
{
 "status": "finished",
 "command": "emails:send",
 "application": "MyApp",
 "timestamp": "2025-06-10T14:30:00+00:00",
 "task_id": "a1b2c3d4e5f6g7h8i9j0",
 "duration_seconds": 2.847,
 "duration_ms": 2847.23,
 "runtime": 2.8,
 "memory_peak_mb": 45.2,
 "memory_current_mb": 38.7,
 "cpu_usage": 15.3,
 "system_load": 0.8,
 "end_time": 1749582600.123
}
```

For failed tasks:

```
{
  "status": "failed",
  "command": "backup:run",
  "application": "MyApp",
  "timestamp": "2025-06-10T02:15:30+00:00",
  "task_id": "b2c3d4e5f6g7h8i9j0k1",
  "duration_seconds": 45.2,
  "duration_ms": 45200.0,
  "memory_peak_mb": 128.5,
  "memory_current_mb": 95.3,
  "exception": "Database connection timeout",
  "end_time": 1749582930.456
}
```

Commands
--------

[](#commands)

The package includes a command to check the status of your cron monitoring:

```
php artisan cron:status
```

This command will verify your configuration and test the connection to your monitoring service.

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Or run tests with coverage:

```
composer test-coverage
```

The package includes comprehensive tests for:

- Service provider registration
- Event listener functionality
- HTTP request handling
- Error scenarios
- Performance metric collection
- Cross-platform compatibility

Platform Support
----------------

[](#platform-support)

### Windows

[](#windows)

- CPU usage via `wmic` command
- Memory tracking
- Full task monitoring

### Linux/Unix

[](#linuxunix)

- CPU usage via `/proc/stat` and `ps` command
- System load via `sys_getloadavg()`
- Memory tracking
- Full task monitoring

### macOS

[](#macos)

- CPU usage via `ps` command
- System load tracking
- Memory tracking
- Full task monitoring

Error Handling
--------------

[](#error-handling)

The package includes robust error handling:

- **HTTP Failures**: If the monitoring service is unavailable, errors are logged locally
- **CPU Detection Failures**: Gracefully handles platforms where CPU usage cannot be determined
- **Memory Failures**: Continues operation even if memory metrics are unavailable
- **Exception Capture**: Failed tasks are still monitored and reported

All errors are logged to your Laravel log files for debugging.

Security
--------

[](#security)

- API keys are securely handled via environment variables
- HTTP requests include timeout protection (5 seconds default)
- No sensitive data is transmitted unless explicitly configured
- Local fallback logging for monitoring service outages

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to this project.

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for details on what has changed.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

Credits
-------

[](#credits)

- [Willi Helwig](https://github.com/willihelwig)
- [TIVENTS](https://github.com/tivents)
- [All Contributors](../../contributors)

Support
-------

[](#support)

If you discover any security vulnerabilities, please send an email to .

For questions and support, please use the [GitHub issues](https://github.com/tivents/laravel-cron-monitor/issues).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance57

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f2eb537a84c15513453d0268176d3b82daa6996668d7394c05d46b27916ae36e?d=identicon)[aldraHastur](/maintainers/aldraHastur)

---

Top Contributors

[![aldrahastur](https://avatars.githubusercontent.com/u/5844861?v=4)](https://github.com/aldrahastur "aldrahastur (29 commits)")

### Embed Badge

![Health badge](/badges/tivents-laravel-cron-monitor/health.svg)

```
[![Health](https://phpackages.com/badges/tivents-laravel-cron-monitor/health.svg)](https://phpackages.com/packages/tivents-laravel-cron-monitor)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[ekino/newrelic-bundle

Integrate New Relic into Symfony2

28111.2M8](/packages/ekino-newrelic-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
