MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

aProbe

MMO\admin\monitoring · 1 symbol · generated 27 Oct 2026

class

aProbe

aProbe.php:28

One way of looking at a server or a target: what a hub runs, for every subject it applies to, at every collection.

abstract class MMO\admin\monitoring\aProbe
Namespace
MMO\admin\monitoring
A probe only ever reads. It runs one command (or one request) per subject, which prints everything it needs in sections (`@@name` lines, [`Sections`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/aProbe.md#aprobe-sections)), so that a server across the world costs one round trip, not twenty. Its options come from the hub's `probes` (`hub.json`): every public property can be set there, `enabled` and `timeout` included -- `"database": {"engine": "mysql"}`. What it cannot see is `unknown`, not an error: a webspace without `ps`, a target without a database. What it sees wrong it says with [`Reading::raise`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/Reading.md#reading-raise); thresholds on numbers are the [`Rules`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/Rules.md#rules)' job, not the probe's.
class UptimeProbe extends aProbe { const string NAME = 'uptime'; protected function probe(Server|Target $subject, Reading $reading, ?Reading $previous): void { $reading->metric('uptime.days', (float)$this->shell($subject)->exec('cut -d" " -f1 /proc/uptime') / 86400); } }

Index

DESCRIPTIONwhat it is for, in a few words: shown by the hub
KINDwhat it looks at: SERVER or TARGET
NAMEthe probe's name: its key in hub.json and in every reading
SERVERa probe of servers
TARGETa probe of targets: the sites of the project, one per client
enabled
hub
timeout
appliesTo($subject)
collect($subject, $previous, $time)Look at a subject, never throwing: whatever goes wrong is in the reading.
debugName()
failure($e)
needsShell()
Number($value) static
Percent($part, $whole) static
probe($subject, $reading, $previous) abstractFill the reading.
run($subject, $script)Run a script on the subject, stopped after $timeout seconds where timeout exists (a webspace may lack it).
Sections($output) static
shell($subject)
__construct($options, $hub)

Constants5

DESCRIPTION

what it is for, in a few words: shown by the hub

const DESCRIPTION = ''

NAME

the probe's name: its key in hub.json and in every reading

const NAME = ''

SERVER

a probe of servers

const SERVER = 'server'

TARGET

a probe of targets: the sites of the project, one per client

const TARGET = 'target'

Properties3

enabled

bool $enabled = true
Type
bool

hub

protected ?MMO\admin\monitoring\Hub $hub
Type
null | Hub

timeout

int $timeout = 25
Type
int

Methods12

appliesTo($subject)

aProbe.php:62
function appliesTo(MMO\admin\entities\Server|MMO\admin\entities\Target $subject): bool
$subjectServer | Target
returnsboolwhether it looks at $subject: the right kind, and what it needs declared

collect($subject, $previous, $time)

aProbe.php:76

Look at a subject, never throwing: whatever goes wrong is in the reading.

function collect( MMO\admin\entities\Server|MMO\admin\entities\Target $subject, ?MMO\admin\monitoring\Reading $previous = null, ?int $time = null ): MMO\admin\monitoring\Reading
$subjectServer | Target
$previous = nullnull | Readingwhat it saw last time, for what is counted since then (a log's new lines)
$time = nullnull | intwhen, for a reading of the past (a demo's history); null: now
returnsReading

failure($e)

aProbe.php:98
protected function failure(Throwable $e): string
$eThrowable
returnsstringthe status of a probe that threw: it could not tell

needsShell()

aProbe.php:67
function needsShell(): bool
returnsboolwhether it reaches the subject through its shell: a server out of reach makes it unknown

Number($value)

staticaProbe.php:136
static function Number(mixed $value): ?float
$valuemixed
returnsnull | float$value as a number, null when it is not one

Percent($part, $whole)

staticaProbe.php:141
static function Percent(int|float|null $part, int|float|null $whole): ?float
$partint | float | null
$wholeint | float | null
returnsnull | float$part / $whole as a percentage, null without a whole

probe($subject, $reading, $previous)

abstractaProbe.php:95

Fill the reading.

abstract protected function probe( MMO\admin\entities\Server|MMO\admin\entities\Target $subject, MMO\admin\monitoring\Reading $reading, ?MMO\admin\monitoring\Reading $previous ): void
$subjectServer | Target
$readingReading
$previousnull | Reading
returnsvoid
throwsanything: collect makes it the reading's message

run($subject, $script)

aProbe.php:111

Run a script on the subject, stopped after $timeout seconds where timeout exists (a webspace may lack it).

protected function run( MMO\admin\entities\Server|MMO\admin\entities\Target $subject, string $script ): string
$subjectServer | Target
$scriptstringsh, several lines
returnsstringwhat it printed, stderr included

Sections($output)

staticaProbe.php:121
static function Sections(string $output): array
$outputstringwhat a script printed, sections starting with a @@name line
returnsarraystring> name => the lines after it, trimmed; what comes before the first section is ''

shell($subject)

aProbe.php:101
protected function shell(MMO\admin\entities\Server|MMO\admin\entities\Target $subject): MMO\core\server\ShellRunner
$subjectServer | Target
returnsShellRunnerthe subject's shell: the same connection for every probe of every target of a server

__construct($options, $hub)

aProbe.php:53
function __construct(array $options = [], ?MMO\admin\monitoring\Hub $hub = null)
$options = []array
$hub = nullnull | Hubthe hub running it: its secrets (Hub::secret)