MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

Hub

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

class

Hub

Hub.php:43

One project's fleet, watched from this machine: the servers and the sites (targets) its deploy.json declares, the probes run on them, what they saw and what went wrong.

class MMO\admin\monitoring\Hub
Namespace
MMO\admin\monitoring
A hub is a folder holding a `hub.json` (scripts/new-hub.php makes one per project). It declares nothing new about the fleet -- the deployment declarations already say which machine hosts which client, how to reach it and where each site lives -- so a server added to `deploy.json` is watched at the next collection: ```json { "name": "my.oviepro", "title": "my.oviepro · fleet", "declarations": ["~/dev/src/my.oviepro/deploy.json"], "interval": 300, "retention": 30, "probes": {"database": {"engine": "mongodb"}, "logs": {"files": ["{folder}/shared/logs.log"]}}, "rules": [{"metric": "disk.*.usedPercent", "warning": 75, "critical": 90}], "notify": [{"type": "desktop", "level": "critical"}], "exclude": ["old-client"], "links": {"Board": "http://localhost/my.oviepro/developer/boards"} } ``` Paths may start with `~/` (your home), `{hub}` (the hub's folder) or `{tmp}`; a relative one is the hub's. Every server is reached exactly as a deployment reaches it: its ssh alias, your agent, the project's credentials file. The hub's own secrets -- what a probe needs that a deployment does not: the application's `metricsToken`, a `databaseUri` with a password -- are in `hub.credentials.json` beside it (mode 0600, ignored by git), by target name, `*` for every target: `{"*": {"metricsToken": "..."}, "client1": {"databaseUri": "mongodb://..."}}`.
$hub = Hub::FromFile('~/hubs/my.oviepro/hub.json'); $hub->collect(); // every probe on every server and site, kept in {hub}/data $hub->overview(); // what the dashboard shows

Index

CREDENTIALS
FILENAME
KEY_METRICSprobe => the metrics a summary shows of it (the page's cards, status)
PROBESname => class: the probes every hub has; hub.json adds its own with {"class": "..."}
config
credentials
errors
filename
folder
incidents
monitor
probes
rules
stores
transport
collect($subjects, $probes, $progress, $time)Run the probes on the subjects, judge, keep, open and resolve incidents.
debugName()
deployments($target, $count)What was deployed: this machine's history (mmo.admin's sync, and every release made from here), and what the release probe last read of each target's own journal -- so a hub knows the deployments…
describeProbes()
Expand($path, $folder) static
FromFile($filename) static
getConfig()
getDeclarations()
getDescription()
getErrors()
getFilename()
getFolder()
getIncidents()
getInterval()
getLinks()
getMonitorStore()
getName()
getNotifier()
getProbes()
getRules()
getServers()
getStores()
getSubject($id)
getSubjects()
getTargets()
getTitle()
getTransport()
housekeeping()Prune what is older than the retention, once a day.
isExcluded($name)
overview($series)What the dashboard shows: every server and target with its status and the key metrics of each probe, the open incidents, and a day of the main curves.
path($path)
rates($reading, $previous)Turn counters into rates: db.ops read twice is db.opsPerSec.
reach($subject, $unreachable)
secret($target, $key)
setTransport($transport)
subject($id, $range, $points)Everything about one server or target: its latest readings in full, its curves, its incidents, and its targets or its deployments.
SubjectId($subject) static
summary($id, $readings, $stale)
__construct($config, $folder, $filename)

Constants4

CREDENTIALS

const CREDENTIALS = 'hub.credentials.json'

FILENAME

const FILENAME = 'hub.json'

KEY_METRICS

probe => the metrics a summary shows of it (the page's cards, status)

const KEY_METRICS = […6 items]

PROBES

name => class: the probes every hub has; hub.json adds its own with {"class": "..."}

const PROBES = […6 items]

Properties11

config

protected array $config
Type
array

credentials

protected ?MMO\admin\helpers\Credentials $credentials = null
Type
null | Credentials

errors

protected array $errors = []
Type
array

filename

protected ?string $filename
Type
null | string

folder

protected string $folder
Type
string

incidents

protected ?MMO\admin\monitoring\Incidents $incidents = null
Type
null | Incidents

monitor

protected ?MMO\admin\monitoring\MonitorStore $monitor = null
Type
null | MonitorStore

probes

protected ?array $probes = null
Type
null | array

rules

protected ?MMO\admin\monitoring\Rules $rules = null
Type
null | Rules

stores

protected ?array $stores = null
Type
null | array

transport

protected ?MMO\admin\monitoring\iHttpTransport $transport = null
Type
null | iHttpTransport

Methods39

collect($subjects, $probes, $progress, $time)

Hub.php:278

Run the probes on the subjects, judge, keep, open and resolve incidents.

function collect( ?array $subjects = null, ?array $probes = null, ?callable $progress = null, ?int $time = null ): arrayServers are reached once each: a server that does not answer makes every probe of its targets that needs its shell `unknown` (the server itself is the critical one), without trying again for each. The http probes still run: they ask from here, and say what the users see.
$subjects = nullnull | arrayids or names (null: every one)
$probes = nullnull | arraynames (null: every enabled one)
$progress = nullnull | callablefn(Reading $reading) after each reading
$time = nullnull | intwhen, for readings of the past (a demo's history); null: now
returnsarraylist<Reading>, skipped: bool, seconds: float, events: list<array>} skipped: another collection holds the lock, nothing was done

deployments($target, $count)

Hub.php:501

What was deployed: this machine's history (mmo.admin's sync, and every release made from here), and what the release probe last read of each target's own journal -- so a hub knows the deployments made from another machine without a sync.

function deployments(?string $target = null, int $count = 50): array
$target = nullnull | stringonly this target's
$count = 50int
returnsarraynewest first

describeProbes()

Hub.php:420
function describeProbes(): array
returnsarrayarray{kind: string, description: string, enabled: bool}>

Expand($path, $folder)

staticHub.php:109
static function Expand(string $path, string $folder): string
$pathstring
$folderstring
returnsstring$path with ~/, {hub} and {tmp} (the system's temporary folder) expanded, absolute: relative to $folder

FromFile($filename)

staticHub.php:99
static function FromFile(string $filename): self
$filenamestringa hub.json (// comments allowed), or the folder holding one
returnsself
throwswhen it is missing or is not JSON

getDeclarations()

Hub.php:136
function getDeclarations(): array
returnsarraythe deployment declarations the fleet is read from

getErrors()

Hub.php:141
function getErrors(): array
returnsarraystring> declaration => why it could not be read: a hub still shows the others

getInterval()

Hub.php:130
function getInterval(): int
returnsintseconds between two collections: what watch waits, and how old a reading is before it is stale

getProbes()

Hub.php:214
function getProbes(): array
returnsarrayaProbe> name => probe, the enabled ones and the others

getRules()

Hub.php:231
function getRules(): MMO\admin\monitoring\Rules
returnsRules

getServers()

Hub.php:165
function getServers(): array
returnsarrayServer> name => server, every declaration's

getStores()

Hub.php:147
function getStores(): array
returnsarrayone per declaration that could be read

getSubject($id)

Hub.php:206
function getSubject(string $id): MMO\admin\entities\Server|MMO\admin\entities\Target
$idstringserver:ovh1, target:client1, or a bare name (a server first)
returnsServer | Target
throws

getSubjects()

Hub.php:194
function getSubjects(): array
returnsarrayServer|Target> id => subject: the servers, then the targets

getTargets()

Hub.php:176
function getTargets(): array
returnsarrayTarget> name => target, every declaration's, but the excluded and the disabled ones

getTransport()

Hub.php:242
function getTransport(): MMO\admin\monitoring\iHttpTransport
returnsiHttpTransportwhat asks the sites: hub.json's transport (a class name), else curl

housekeeping()

Hub.php:360

Prune what is older than the retention, once a day.

protected function housekeeping(): void
returnsvoid

overview($series)

Hub.php:375

What the dashboard shows: every server and target with its status and the key metrics of each probe, the open incidents, and a day of the main curves.

function overview(bool $series = true): array
$series = trueboolwhether to add the curves (a command line summary does not draw them)
returnsarray

rates($reading, $previous)

Hub.php:349

Turn counters into rates: db.ops read twice is db.opsPerSec. A counter that went down was reset (a restart): no rate this time.

function rates( MMO\admin\monitoring\Reading $reading, ?MMO\admin\monitoring\Reading $previous ): void
$readingReadingfilled
$previousnull | Reading
returnsvoid

reach($subject, $unreachable)

Hub.php:327
protected function reach( MMO\admin\entities\Server|MMO\admin\entities\Target $subject, array &$unreachable ): ?string
$subjectServer | Target
$unreachablearray
returnsnull | stringwhy the subject's shell cannot be used, null when it can

secret($target, $key)

Hub.php:257
function secret(string $target, string $key): ?string
$targetstringa target's name
$keystringmetricsToken, databaseUri...
returnsnull | stringthe target's own, else the one for every target (*), from CREDENTIALS

setTransport($transport)

Hub.php:250
function setTransport(MMO\admin\monitoring\iHttpTransport $transport): void
$transportiHttpTransport
returnsvoid

subject($id, $range, $points)

Hub.php:462

Everything about one server or target: its latest readings in full, its curves, its incidents, and its targets or its deployments.

function subject(string $id, int $range = 86400, int $points = 120): array
$idstring
$range = 86400intseconds of curves
$points = 120inthow many points per curve
returnsarray
throws

SubjectId($subject)

staticHub.php:117
static function SubjectId(MMO\admin\entities\Server|MMO\admin\entities\Target $subject): string
$subjectServer | Target
returnsstringthe id of a subject: server:{name} or target:{name}

summary($id, $readings, $stale)

Hub.php:432
protected function summary(string $id, array $readings, int $stale): array
$idstring
$readingsarray
$staleintbefore this, a reading is stale
returnsarraystring, status: string, stale: bool, time: int|null, probes: array, facts: array}

__construct($config, $folder, $filename)

Hub.php:84
function __construct(array $config, string $folder, ?string $filename = null)
$configarraywhat hub.json holds
$folderstringthe hub's folder: {hub}, and where relative paths start
$filename = nullnull | stringfor messages