perf2k2/monitre

PHP library for remote linux monitoring/diagnostic with no installation needed

0.2.0 2019-10-08 19:52 UTC

This package is auto-updated.

Last update: 2024-04-09 05:54:33 UTC


README

Build Status

About

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.

How it works

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.

List of monitors

  • Memory
    • Usage percent
  • Disk
    • Usage percent (by mount path)
  • File (by absolute path)
    • Size
    • Modify time
    • Content
    • Last lines
    • Header lines

Requirements

  • PHP >= 7.2
  • ext-ssh2

Installation

composer require perf2k2/monitre

Usage

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