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

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,

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.


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


impl Topology[src]

pub fn new() -> Topology[src]

Instanciates Topology and returns the instance

pub fn generate_cpu_cores() -> Result<Vec<CPUCore>, String>[src]

Parses /proc/cpuinfo and creates instances of CPUCore.


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());

pub fn safe_add_socket(
    &mut self,
    socket_id: u16,
    domains: Vec<Domain>,
    attributes: Vec<Vec<HashMap<String, String>>>,
    counter_uj_path: String,
    buffer_max_kbytes: u16

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

pub fn get_proc_tracker(&self) -> &ProcessTracker[src]

Returns a immutable reference to self.proc_tracker

pub fn get_sockets(&mut self) -> &mut Vec<CPUSocket>[src]

Returns a mutable reference to self.sockets

pub fn get_sockets_passive(&self) -> &Vec<CPUSocket>[src]

Returns an immutable reference to self.sockets

pub fn safe_add_domain_to_socket(
    &mut self,
    socket_id: u16,
    domain_id: u16,
    name: &str,
    uj_counter: &str,
    buffer_max_kbytes: u16

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

pub fn add_cpu_cores(&mut self)[src]

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

pub fn refresh(&mut self)[src]

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

pub fn refresh_stats(&mut self)[src]

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

pub fn get_records_diff(&self) -> Option<Record>[src]

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

pub fn get_records_diff_power_microwatts(&self) -> Option<Record>[src]

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

pub fn get_stats_diff(&self) -> Option<CPUStat>[src]

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

pub fn read_stats(&self) -> Option<CPUStat>[src]

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

pub fn read_nb_process_total_count(&self) -> Option<u64>[src]

Returns the number of processes currently available

pub fn read_nb_process_running_current(&self) -> Option<u32>[src]

Returns the number of processes currently in a running state

pub fn read_nb_process_blocked_current(&self) -> Option<u32>[src]

Returns the number of processes currently blocked waiting

pub fn read_nb_context_switches_total_count(&self) -> Option<u64>[src]

Returns the current number of context switches

pub fn get_process_power_consumption_microwatts(&self, pid: i32) -> Option<u64>[src]

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

pub fn get_process_cpu_consumption_percentage(&self, pid: i32) -> Option<f64>[src]

Trait Implementations

impl Clone for Topology[src]

impl Debug for Topology[src]

impl Default for Topology[src]

impl RecordGenerator for Topology[src]

pub fn refresh_record(&mut self) -> Record[src]

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

pub fn clean_old_records(&mut self)[src]

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

pub fn get_records_passive(&self) -> Vec<Record>[src]

Returns a copy of the record_buffer

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,