Struct scaphandre::sensors::Topology[][src]

pub struct Topology {
    pub sockets: Vec<CPUSocket>,
    pub proc_tracker: ProcessTracker,
    pub stat_buffer: Vec<CPUStat>,
    pub record_buffer: Vec<Record>,
    pub buffer_max_kbytes: u16,
    pub domains_names: Option<Vec<String>>,
}
Expand description

Topology struct represents the whole CPUSocket architecture, from the electricity consumption point of view, including the potentially multiple CPUSocket sockets. Owns a vector of CPUSocket structs representing each socket.

Fields

sockets: Vec<CPUSocket>

The CPU sockets found on the host, represented as CPUSocket instances attached to this topology

proc_tracker: ProcessTracker

ProcessTrack instance that keeps track of processes running on the host and CPU stats associated

stat_buffer: Vec<CPUStat>

CPU usage stats buffer

record_buffer: Vec<Record>

Measurements of energy usage, stored as Record instances

buffer_max_kbytes: u16

Maximum size in memory for the recor_buffer

domains_names: Option<Vec<String>>

Sorted list of all domains names

Implementations

Instanciates Topology and returns the instance

Parses /proc/cpuinfo and creates instances of CPUCore.

Examples

use scaphandre::sensors::Topology;

if let Ok(cores) = Topology::generate_cpu_cores() {
    println!("There are {} cores on this host.", cores.len());
    for c in &cores {
        println!("Here is CPU Core number {}", c.attributes.get("processor").unwrap());
    }
}

Adds a Socket instance to self.sockets if and only if the socket id doesn’t exist already.

Returns a immutable reference to self.proc_tracker

Returns a mutable reference to self.sockets

Returns an immutable reference to self.sockets

Adds a Domain instance to a given socket, if and only if the domain id doesn’t exist already for the socket.

Generates CPUCore instances for the host and adds them to appropriate CPUSocket instance from self.sockets

Triggers ProcessTracker refresh on process stats and power consumption, CPU stats and cores power comsumption, CPU sockets stats and power consumption.

Gets currents stats and stores them as a CPUStat instance in self.stat_buffer

Returns a Record instance containing the difference (attribute by attribute, except timestamp which will be the timestamp from the last record) between the last (in time) record from self.record_buffer and the previous one

Returns a Record instance containing the power consumed between last and previous measurement, in microwatts.

Returns a CPUStat instance containing the difference between last and previous stats measurement (from stat_buffer), attribute by attribute.

Reads content from /proc/stat and extracts the stats of the whole CPU topology.

Returns the number of processes currently available

Returns the number of processes currently in a running state

Returns the number of processes currently blocked waiting

Returns the current number of context switches

Returns the power consumed between last and previous measurement for a given process ID, in microwatts

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Computes a new Record, stores it in the record_buffer and returns a clone of this record.

Removes (and thus drops) as many Record instances from the record_buffer as needed for record_buffer to not exceed ‘buffer_max_kbytes’

Returns a copy of the record_buffer

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more