Library for connecting to remote linux systems and reading key performance and other metrics. Maybe useful for periodic checking remote machine state and logging situations with wrong values.
It uses classes called "monitors" for checking metrics. After connecting to remote host by ssh, monitor runs linux command and parse output for getting information.
- Memory
- Usage percent
- Disk
- Usage percent (by mount path)
- File (by absolute path)
- Size
- Modify time
- Content
- Last lines
- Header lines
- PHP >= 7.2
- ext-ssh2
composer require perf2k2/monitre
$logger = new Logger();
$server = new Connection('ip', new PasswordAuthenticator('user', 'password'));
$memoryMonitor = new MemoryUsageMonitor($server);
if ($memoryMonitor->getUsagePercent() > 90) {
$logger->warning('High memory usage!');
}
$diskMonitor = new DiskUsageMonitor($server);
if ($diskMonitor->getUsagePercent() > 90) {
$logger->warning('High disk usage!');
}
$fileMonitor = new FileMonitor($server, '/path/to/file');
if ($fileMonitor->getSize()->asMegabytes() > 100) {
$logger->warning('File too large!');
}