Skip to content

Commit 84796ce

Browse files
committed
Fix #53
1 parent 6ba58d8 commit 84796ce

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"suggest": {
3636
"ext-apcu": "Required for the APCu dashboard.",
3737
"ext-redis": "Required for use the Redis dashboard.",
38+
"ext-sqlite3": "Required for metrics.",
3839
"ext-zend-opcache": "Required for use the OPCache dashboard.",
3940
"ext-zlib": "Required for encoding/decoding with gz* functions.",
4041
"predis/predis": "Required for use the Redis dashboard, when Redis extension is not installed."

src/Dashboards/Memcached/MemcachedTrait.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace RobiNN\Pca\Dashboards\Memcached;
1010

11+
use PDO;
1112
use RobiNN\Pca\Config;
1213
use RobiNN\Pca\Format;
1314
use RobiNN\Pca\Helpers;
@@ -485,6 +486,19 @@ private function items(): string {
485486
return $this->template->render('dashboards/memcached/memcached', ['items' => $items]);
486487
}
487488

489+
private function metrics(): string {
490+
if (!in_array('sqlite', PDO::getAvailableDrivers(), true)) {
491+
return $this->template->render('components/tabs', [
492+
'links' => [
493+
'keys' => 'Keys', 'commands_stats' => 'Commands Stats', 'slabs' => 'Slabs', 'items' => 'Items', 'metrics' => 'Metrics',
494+
],
495+
]).
496+
'Metrics are disabled because the PDO SQLite driver is not available. Install the sqlite3 extension for PHP.';
497+
}
498+
499+
return $this->template->render('dashboards/memcached/memcached');
500+
}
501+
488502
/**
489503
* @throws MemcachedException
490504
*/
@@ -508,6 +522,10 @@ private function mainDashboard(): string {
508522
return $this->items();
509523
}
510524

525+
if (Http::get('tab') === 'metrics') {
526+
return $this->metrics();
527+
}
528+
511529
$keys = $this->getAllKeys();
512530

513531
if (isset($_GET['export_btn'])) {

src/Dashboards/Redis/RedisTrait.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Exception;
1212
use JsonException;
13+
use PDO;
1314
use Predis\Client as Predis;
1415
use RobiNN\Pca\Config;
1516
use RobiNN\Pca\Dashboards\DashboardException;
@@ -572,7 +573,7 @@ private function dbSelect(): string {
572573
*/
573574
private function slowlog(): string {
574575
if (!$this->isCommandSupported('SLOWLOG')) {
575-
return $this->template->render('components/tabs', ['links' => ['keys' => 'Keys', 'slowlog' => 'Slow Log',],]).
576+
return $this->template->render('components/tabs', ['links' => ['keys' => 'Keys', 'slowlog' => 'Slow Log',]]).
576577
'Slowlog is disabled on your server.';
577578
}
578579

@@ -600,6 +601,15 @@ private function slowlog(): string {
600601
]);
601602
}
602603

604+
private function metrics(): string {
605+
if (!in_array('sqlite', PDO::getAvailableDrivers(), true)) {
606+
return $this->template->render('components/tabs', ['links' => ['keys' => 'Keys', 'slowlog' => 'Slow Log',]]).
607+
'Metrics are disabled because the PDO SQLite driver is not available. Install the sqlite3 extension for PHP.';
608+
}
609+
610+
return $this->template->render('dashboards/redis/redis');
611+
}
612+
603613
/**
604614
* @throws Exception
605615
*/
@@ -621,6 +631,10 @@ function (string $key, string $value, int $ttl): bool {
621631
return $this->slowlog();
622632
}
623633

634+
if (Http::get('tab') === 'metrics') {
635+
return $this->metrics();
636+
}
637+
624638
$keys = $this->getAllKeys();
625639

626640
if (isset($_GET['export_btn'])) {

0 commit comments

Comments
 (0)