pub struct ResourceUsage {
pub memory_usage_mb: usize,
pub total_memory_mb: usize,
pub process_memory_mb: Option<usize>,
pub cpu_usage_percent: f64,
pub cpu_usage_percent_valid: bool,
pub gpu_usage_percent: Option<f64>,
pub network_io_mbps: Option<f64>,
pub disk_io_mbps: Option<f64>,
pub active_threads: usize,
pub timestamp: Instant,
}Expand description
Current resource usage information
Fields§
§memory_usage_mb: usizeMemory usage in MB
total_memory_mb: usizeTotal system memory in MB (R2 fix). Populated from the real system
total at collection time so memory_usage_mb can be turned into an
honest percentage instead of assuming a fixed 1024 MB (1 GB) total,
which pinned memory_percent/memory_utilization above 100% (and
therefore alert severity at Emergency) on essentially every real
machine. 0 (the Default value) means “unknown”; callers must
treat that as “cannot compute a percentage”, not as “0 MB total”.
process_memory_mb: Option<usize>Memory this process is using, in MB, or None when the process
counters are unavailable.
memory_usage_mb/total_memory_mb are system-wide and only meaningful
as a ratio (which is what the memory alert thresholds compare). The
allocation budget, by contrast, is a per-process figure, so comparing
system-wide usage against it reports several hundred percent utilization
on any real machine — the same class of error as R2, one level up. That
comparison was inert only because start_monitoring was never called
and current_usage stayed all-zero; every budget consumer now reads this
field instead.
cpu_usage_percent: f64CPU usage percentage (0-100).
R1: this used to be the hardcoded literal 50.0. It is now the real
system-wide CPU usage read from a persistent sysinfo::System,
because CPU usage is a delta between two refreshes: a freshly built
System always reports 0. Until two refreshes at least
sysinfo::MINIMUM_CPU_UPDATE_INTERVAL apart have happened this field
holds 0.0 and cpu_usage_percent_valid is false; consumers must
check the flag rather than treating the placeholder as a measurement.
cpu_usage_percent_valid: boolWhether cpu_usage_percent holds a real measurement.
gpu_usage_percent: Option<f64>GPU usage percentage (0-100) if applicable. There is no pure-Rust,
vendor-neutral way to read this, so it stays None unless an external
probe supplies it.
network_io_mbps: Option<f64>Network I/O rate in MB/s, or None before two interface refreshes have
produced a usable byte delta (R1: this used to be the literal 1.0).
disk_io_mbps: Option<f64>Disk I/O rate in MB/s for this process, or None before two process
refreshes have produced a usable byte delta (R1: this used to be the
literal 5.0).
active_threads: usizeNumber of active threads
timestamp: InstantTimestamp of measurement
Implementations§
Source§impl ResourceUsage
impl ResourceUsage
Sourcepub fn process_memory(&self) -> Option<usize>
pub fn process_memory(&self) -> Option<usize>
Memory this process is using, in MB, when it could be measured.
Sourcepub fn cpu_usage(&self) -> Option<f64>
pub fn cpu_usage(&self) -> Option<f64>
Real CPU usage, or None when no valid measurement has been taken yet.
Sourcepub fn memory_usage_percent(&self) -> Option<f64>
pub fn memory_usage_percent(&self) -> Option<f64>
Real memory-usage percentage (R2), used / total * 100. Returns
None when total_memory_mb is unknown (0) rather than fabricating
a value against a wrong assumed total.
Trait Implementations§
Source§impl Clone for ResourceUsage
impl Clone for ResourceUsage
Source§fn clone(&self) -> ResourceUsage
fn clone(&self) -> ResourceUsage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResourceUsage
impl Debug for ResourceUsage
Source§impl Default for ResourceUsage
impl Default for ResourceUsage
Auto Trait Implementations§
impl Freeze for ResourceUsage
impl RefUnwindSafe for ResourceUsage
impl Send for ResourceUsage
impl Sync for ResourceUsage
impl Unpin for ResourceUsage
impl UnsafeUnpin for ResourceUsage
impl UnwindSafe for ResourceUsage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.