mirror of
https://codeberg.org/icewind/palantir.git
synced 2026-06-03 18:24:08 +02:00
windows stuff
This commit is contained in:
parent
d12b70d11e
commit
0bb314e5d3
14 changed files with 602 additions and 102 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use crate::data::{DiskStats, DiskUsage};
|
||||
use crate::{Error, MultiSensorSource, Result, SensorData};
|
||||
use ahash::{AHashSet, AHasher};
|
||||
use regex::Regex;
|
||||
|
|
@ -10,32 +11,6 @@ use std::mem::MaybeUninit;
|
|||
|
||||
pub mod zfs;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct DiskStats {
|
||||
pub interface: String,
|
||||
pub bytes_sent: u64,
|
||||
pub bytes_received: u64,
|
||||
}
|
||||
|
||||
impl SensorData for DiskStats {
|
||||
fn write<W: Write>(&self, mut w: W, hostname: &str) {
|
||||
if self.bytes_received > 0 || self.bytes_sent > 0 {
|
||||
writeln!(
|
||||
&mut w,
|
||||
"disk_sent{{host=\"{}\", disk=\"{}\"}} {}",
|
||||
hostname, self.interface, self.bytes_sent
|
||||
)
|
||||
.ok();
|
||||
writeln!(
|
||||
&mut w,
|
||||
"disk_received{{host=\"{}\", disk=\"{}\"}} {}",
|
||||
hostname, self.interface, self.bytes_received
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DiskStatSource {
|
||||
source: File,
|
||||
buff: String,
|
||||
|
|
@ -100,32 +75,6 @@ impl Iterator for DiskStatParser<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DiskUsage {
|
||||
pub name: String,
|
||||
pub size: u64,
|
||||
pub free: u64,
|
||||
}
|
||||
|
||||
impl SensorData for DiskUsage {
|
||||
fn write<W: Write>(&self, mut w: W, hostname: &str) {
|
||||
if self.size > 0 {
|
||||
writeln!(
|
||||
&mut w,
|
||||
"disk_size{{host=\"{}\", disk=\"{}\"}} {}",
|
||||
hostname, self.name, self.size
|
||||
)
|
||||
.ok();
|
||||
writeln!(
|
||||
&mut w,
|
||||
"disk_free{{host=\"{}\", disk=\"{}\"}} {}",
|
||||
hostname, self.name, self.free
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DiskUsageSource {
|
||||
source: File,
|
||||
buff: String,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::data::{GpuMemory, GpuUsage};
|
||||
use crate::linux::hwmon::FileSource;
|
||||
use std::borrow::Cow;
|
||||
use std::fs::read_to_string;
|
||||
use std::str::FromStr;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
|
@ -41,7 +42,7 @@ pub fn utilization() -> impl Iterator<Item = GpuUsage> {
|
|||
];
|
||||
let drm = sources.into_iter().flat_map(|(system, usage)| {
|
||||
Some(GpuUsage {
|
||||
system,
|
||||
system: Cow::Borrowed(system),
|
||||
usage: usage?,
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use crate::data::{GpuMemory, GpuUsage};
|
|||
use nvml_wrapper::enum_wrappers::device::TemperatureSensor;
|
||||
use nvml_wrapper::{Device, Nvml};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::borrow::Cow;
|
||||
|
||||
static NVIDIA: Lazy<Option<Nvml>> = Lazy::new(|| Nvml::init().ok());
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ pub fn utilization() -> impl Iterator<Item = GpuUsage> {
|
|||
};
|
||||
sources.into_iter().flat_map(|(system, usage)| {
|
||||
Some(GpuUsage {
|
||||
system,
|
||||
system: Cow::Borrowed(system),
|
||||
usage: usage?,
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue