Skip to main content

Machine

Struct Machine 

Source
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: Duration

How 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: u64

How many slices this worker has run since it started.

§id: String

What this machine calls itself: its hostname and this process.

Not the name the graph gave it. A worker does not know that namew1 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

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Machine

Source§

fn clone(&self) -> Machine

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Machine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Machine

Source§

fn default() -> Machine

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Machine

Source§

fn eq(&self, other: &Machine) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Machine

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.