pub struct Machine {
pub up: Duration,
pub busy: Option<f64>,
pub cores: Option<usize>,
pub memory: Option<f64>,
pub served: u64,
pub id: String,
}Expand description
What one machine looks like right now.
A struct and not an enum: these are not alternatives but a snapshot, every
one of them measured at the same instant. None is nobody measured it
and never zero — a kernel that keeps no load average is not an idle machine.
Fields§
§up: DurationHow long this worker process has been up.
Its own monotonic clock and never a wall clock: two machines’ wall clocks disagree by minutes on a cluster as a matter of course. What the reader gets is a duration, and when is stamped by whoever writes it.
busy: Option<f64>The run queue against the number of cores, so two machines of different sizes can be compared.
The ratio and not the raw load, because a load of 8 is a busy laptop and
an idle compute node. Machine::cores is beside it for whoever wants
to undo the division.
cores: Option<usize>How many cores it divided by.
memory: Option<f64>What fraction of memory is in use.
Against what the kernel says is available rather than what is free: page cache is not memory anybody is short of, and counting it as used is how a perfectly healthy machine reads as full.
served: u64How many slices this worker has run since it started.
id: StringWhat this machine calls itself: its hostname and this process.
Not the name the graph gave it. A worker does not know that name —
w1 is the client’s word, which is why the client attributes a fact. A
reading written to a store has no client to attribute it, so it is filed
under something the worker can know on its own, and whoever reads joins
the two by seeing the same id on a reading that did come down a
wire.
Implementations§
Source§impl Machine
impl Machine
Sourcepub fn here(up: Duration, served: u64) -> Self
pub fn here(up: Duration, served: u64) -> Self
A reading of the machine this is running on.
Everything comes from /proc, which is Linux. Elsewhere the fields are
None and say so by being None — a worker on a laptop still reports
its uptime and how much it has served.
Sourcepub fn said(&self) -> Fact
pub fn said(&self) -> Fact
This reading as the fact that crosses, already flat.
Named machine, which is what it will be written down as and what a
reader filters on. A field that was not measured is absent rather
than empty: a reader that finds no busy has to be able to tell this
kernel does not say from nothing is running.
Sourcepub fn read(pairs: &[(String, String)]) -> Self
pub fn read(pairs: &[(String, String)]) -> Self
A reading, back out of the pairs said wrote.
Here and not wherever it is read: two halves of one format in two crates drift, and the day a field is added the writer and the reader would each look right and disagree about what a reading is.
What is not there is None, which is the rule the other half writes
by. A field that is there and will not parse is treated the same way,
on purpose — refusing all of it would throw away the uptime for the sake
of the load average.