MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

MonitorStore

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

class

MonitorStore

MonitorStore.php:26

Where a hub keeps what it saw: plain files in its data folder, nothing to install.

class MMO\admin\monitoring\MonitorStore
Namespace
MMO\admin\monitoring
``` {data}/latest.json subject => probe => the latest reading, details included {data}/series/{subject}/{YYYY-MM-DD}.jsonl one line per reading: time, probe, status, metrics (@see Reading::toPoint) {data}/incidents.json what went wrong, when, and when it stopped (@see Incidents) {data}/collect.lock held while a collection runs, so two never overlap ``` A series is split per subject and per day so that drawing one server's week reads seven small files, and forgetting what is older than [`$retention`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/MonitorStore.md#monitorstore-retention) is deleting folders. Every write goes to a temporary file renamed over the old one: a page reading `latest.json` while a collection writes it reads the old one or the new one, never half. What it keeps may include log lines -- which may name people -- so the folder is its owner's (0750, 0640).
$store = new MonitorStore('/home/me/hubs/my.oviepro/data'); $store->save([$reading]); $store->series('server:ovh1', ['load.1', 'memory.usedPercent'], time() - 86400);

Index

INCIDENTS
LATEST
SERIES
folder
latest
retention
createDir($folder)
debugName()
forget($subject)Forget a subject no longer declared: its latest readings (its series go with the retention).
getFolder()
getRetention()
incidents()
lastCollected()
latest($reload)
lock()Take the collection lock, without waiting: a collection started while another runs (a cron and a click) is skipped.
matches($name, $patterns)
metricNames($subject, $since, $until)
previous($subject, $probe)
prune($now)Forget what is older than the retention: series days, resolved incidents.
readJson($name)
readPoints($subject, $since, $until)
save($readings)Keep readings: as the latest of their subject and probe, and as a point of their subject's series.
saveIncidents($incidents)
series($subject, $metrics, $since, $until, $points)The values of some metrics of a subject over time, averaged into at most $points buckets: a week of readings every five minutes is two thousand points, which no chart needs.
seriesFolder($subject)
unlock($lock)
writeJson($name, $data)
__construct($folder, $retention)

Constants3

INCIDENTS

const INCIDENTS = 'incidents.json'

LATEST

const LATEST = 'latest.json'

SERIES

const SERIES = 'series'

Properties3

folder

protected string $folder
Type
string

latest

protected ?array $latest = null
Type
null | array

retention

protected int $retention
Type
int

Methods22

forget($subject)

MonitorStore.php:100

Forget a subject no longer declared: its latest readings (its series go with the retention).

function forget(string $subject): void
$subjectstring
returnsvoid

lock()

MonitorStore.php:239

Take the collection lock, without waiting: a collection started while another runs (a cron and a click) is skipped.

function lock()
returnsthe lock, held until unlock; null when another collection holds it

metricNames($subject, $since, $until)

MonitorStore.php:160
function metricNames(string $subject, int $since, ?int $until = null): array
$subjectstring
$sinceint
$until = nullnull | int
returnsarraythe metrics a subject's series holds over the period, sorted

previous($subject, $probe)

MonitorStore.php:59
function previous(string $subject, string $probe): ?MMO\admin\monitoring\Reading
$subjectstring
$probestring
returnsnull | Readingthe latest reading of $probe on $subject

prune($now)

MonitorStore.php:217

Forget what is older than the retention: series days, resolved incidents.

function prune(?int $now = null): array
$now = nullnull | int
returnsarrayint, incidents: int} how many were deleted

readPoints($subject, $since, $until)

MonitorStore.php:173
function readPoints(string $subject, int $since, int $until): Generator
$subjectstring
$sinceint
$untilint
returnsGeneratormixed>> the points ({t, p, s, m}) of a subject between two times, oldest first

save($readings)

MonitorStore.php:78

Keep readings: as the latest of their subject and probe, and as a point of their subject's series.

function save(array $readings): void
$readingsarray
returnsvoid

series($subject, $metrics, $since, $until, $points)

MonitorStore.php:122

The values of some metrics of a subject over time, averaged into at most $points buckets: a week of readings every five minutes is two thousand points, which no chart needs.

function series( string $subject, array $metrics, int $since, ?int $until = null, int $points = 120 ): array
$subjectstring
$metricsarraynames, or globs (disk.*.usedPercent)
$sinceinta unix timestamp
$until = nullnull | intnull: now
$points = 120inthow many buckets at most
returnsarrayint, to: int, step: int, times: list<int>, series: array<string, list<float|null>>, status: list<string|null>} status is the worst status of each bucket, every probe of the subject together

seriesFolder($subject)

MonitorStore.php:199
function seriesFolder(string $subject): string
$subjectstring
returnsstringthe folder of a subject's series: server:ovh1 is series/server~ovh1

__construct($folder, $retention)

MonitorStore.php:38
function __construct(string $folder, int $retention = 30)
$folderstringthe data folder, created when first written
$retention = 30inthow many days of series and of resolved incidents are kept