pyfsr.cli.appliance.host¶
pyfsr appliance host — OS-level resource metrics (mem / swap / load / RSS / disk).
Typed wrappers over free / ps / /proc/loadavg / df so callers get
structured values instead of awk-ing command output. None of these need sudo.
The headline call is snapshot(), which gathers mem, swap, load, per-pattern
process RSS, and (optionally) disk in one SSH round-trip and returns a typed
HostSnapshot — the parsing every troubleshooting script otherwise
re-implements lives here, tested once.
Attributes¶
Classes¶
Memory + swap, in MB (parsed from |
|
1/5/15-minute load averages (from |
|
Aggregate resident memory for processes whose command line matches |
|
Filesystem usage for a path, in MB (from |
|
One consistent sample of host resources (see |
Functions¶
|
Memory + swap usage in MB. |
|
1/5/15-minute load averages. |
|
Summed/peak RSS (MB) and count for processes whose command line matches |
|
Filesystem usage (MB) for |
|
One consistent sample of mem, swap, load, per-pattern process RSS, and disk. |
Module Contents¶
- class pyfsr.cli.appliance.host.ProcRss[source]¶
Aggregate resident memory for processes whose command line matches
pattern.
- class pyfsr.cli.appliance.host.HostSnapshot[source]¶
One consistent sample of host resources (see
snapshot()).
- pyfsr.cli.appliance.host.meminfo(transport: pyfsr.cli.appliance.transport.Transport) MemInfo[source]¶
Memory + swap usage in MB.
Raises
TransportErrorif the command produced no usable output (a real host always reports a non-zero total).
- pyfsr.cli.appliance.host.loadavg(transport: pyfsr.cli.appliance.transport.Transport) LoadAvg[source]¶
1/5/15-minute load averages.
- pyfsr.cli.appliance.host.process_rss(transport: pyfsr.cli.appliance.transport.Transport, pattern: str) ProcRss[source]¶
Summed/peak RSS (MB) and count for processes whose command line matches
pattern.patternis a Python regex matched against each process’s full argv (e.g.r"celery\b.*worker"). Far less brittle than theps | awk '/[c]elery/'one-liners scripts copy around.
- pyfsr.cli.appliance.host.disk(transport: pyfsr.cli.appliance.transport.Transport, path: str = '/opt/cyops') DiskUsage[source]¶
Filesystem usage (MB) for
path.
- pyfsr.cli.appliance.host.snapshot(transport: pyfsr.cli.appliance.transport.Transport, *, procs: dict[str, str] | None = None, disk_path: str | None = None) HostSnapshot[source]¶
One consistent sample of mem, swap, load, per-pattern process RSS, and disk.
Gathers everything in a single SSH round-trip (so the numbers are coherent) and returns a typed
HostSnapshot.procsmaps a label → regex (defaults toDEFAULT_PROC_PATTERNS:celerydandintegrations); passdisk_pathto include a filesystem.