PHP code example of perf2k2 / monitre

1. Go to this page and download the library: Download perf2k2/monitre library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

perf2k2 / monitre example snippets


$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!');
}