Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
maantje committed Dec 10, 2023
0 parents commit ec5408a
Show file tree
Hide file tree
Showing 10 changed files with 9,163 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor
.env
.phpunit.result.cache
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) Jamie Schouten [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
126 changes: 126 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Database status card for Laravel Pulse

Get real-time insights into the status of your dabase

## Example

![example](example.png)

## Installation

Install the package using Composer:

```shell
composer require maantje/pulse-database
```

## Register the recorder

In your `pulse.php` configuration file, register the DatabaseRecorder with the desired settings:

```php
return [
// ...

'recorders' => [
\Maantje\Pulse\Database\Recorders\DatabaseRecorder::class => [
'connections' => [
'mysql_another' => [
'values' => [
'Connections',
'Threads_connected',
'Threads_running',
'Innodb_buffer_pool_reads',
'Innodb_buffer_pool_read_requests',
'Innodb_buffer_pool_pages_total',
'Max_used_connections'
],
'aggregates' => [
'avg' => [
'Threads_connected',
'Threads_running',
'Innodb_buffer_pool_reads',
'Innodb_buffer_pool_read_requests',
'Innodb_buffer_pool_pages_total',
],
'max' => [
//
],
'count' => [
//
],
],
],
'mysql' => [
'values' => [
'Connections',
'Threads_connected',
'Threads_running',
'Innodb_buffer_pool_reads',
'Innodb_buffer_pool_read_requests',
'Innodb_buffer_pool_pages_total',
'Max_used_connections'
],
'aggregates' => [
'avg' => [
'Threads_connected',
'Threads_running',
'Innodb_buffer_pool_reads',
'Innodb_buffer_pool_read_requests',
'Innodb_buffer_pool_pages_total',
],
'max' => [
//
],
'count' => [
//
],
],
]
]
],
]
]
```

Ensure you're running [the `pulse:check` command](https://laravel.com/docs/10.x/pulse#capturing-entries).

## Add to your dashboard

Integrate the card into your Pulse dashboard by [publish the vendor view](https://laravel.com/docs/10.x/pulse#dashboard-customization).
and then modifying the `dashboard.blade.php` file:

```diff
<x-pulse>
<livewire:pulse.servers cols="full" />

+ <livewire:database cols='6' title="Active threads" :values="['Threads_connected', 'Threads_running']" :graphs="[
+ 'avg' => ['Threads_connected' => '#ffffff', 'Threads_running' => '#3c5dff'],
+ ]" />

+ <livewire:database cols='6' title="Connections" :values="['Connections', 'Max_used_connections']" />

+ <livewire:database cols='full' title="Innodb" :values="['Innodb_buffer_pool_reads', 'Innodb_buffer_pool_read_requests', 'Innodb_buffer_pool_pages_total']" :graphs="[
+ 'avg' => ['Innodb_buffer_pool_reads' => '#ffffff', 'Innodb_buffer_pool_read_requests' => '#3c5dff'],
+ ]" />

<livewire:pulse.usage cols="4" rows="2" />

<livewire:pulse.queues cols="4" />

<livewire:pulse.cache cols="4" />

<livewire:pulse.slow-queries cols="8" />

<livewire:pulse.exceptions cols="6" />

<livewire:pulse.slow-requests cols="6" />

<livewire:pulse.slow-jobs cols="6" />

<livewire:pulse.slow-outgoing-requests cols="6" />

</x-pulse>
```

And that's it! Enjoy enhanced visibility into your database status on your Pulse dashboard.
34 changes: 34 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "maantje/pulse-database",
"description": "A Laravel Pulse card for database status",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Jamie Schouten",
"email": "[email protected]"
}
],
"require": {
"php": "^8.1",
"illuminate/support": "*",
"laravel/pulse": "^1.0.0@beta"
},
"require-dev": {
"orchestra/testbench": "^8",
"mockery/mockery": "^1.5.0",
"phpunit/phpunit": "^10"
},
"autoload": {
"psr-4": {
"Maantje\\Pulse\\Database\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Maantje\\Pulse\\Database\\DatabaseServiceProvider"
]
}
}
}
Loading

0 comments on commit ec5408a

Please sign in to comment.