Skip to content

Commit

Permalink
Add ConnectionCount and DriverTitle for monitoring commands
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jul 23, 2024
1 parent 046b92a commit 63b1794
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,9 @@ private static function lookupVersion(): string
return self::$version = 'error';
}
}

public function getDriverTitle()
{
return 'MongoDB';
}
}
11 changes: 11 additions & 0 deletions src/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace MongoDB\Laravel\Schema;

use Closure;
use Illuminate\Database\Connection;
use MongoDB\Model\CollectionInfo;
use MongoDB\Model\IndexInfo;

Expand Down Expand Up @@ -289,4 +290,14 @@ protected function getAllCollections()

return $collections;
}

public function getConnectionCount()
{
$status = $this->connection
->getMongoDB()
->command(['serverStatus' => 1])
->toArray();

return $status[0]['connections']['current'];
}
}

0 comments on commit 63b1794

Please sign in to comment.