Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
4681e0c694 |
@@ -34,8 +34,8 @@ pub async fn get_available_container(docker: &Docker) -> Vec<DockerContainer> {
|
|||||||
container.id.as_ref()?; // Skip if no ID
|
container.id.as_ref()?; // Skip if no ID
|
||||||
|
|
||||||
let id = container.id?;
|
let id = container.id?;
|
||||||
let short_string_id = if id.len() > 12 { &id[..12] } else { &id };
|
let short_id = if id.len() > 12 { &id[..12] } else { &id };
|
||||||
let short_id: u32 = short_string_id.trim().parse().unwrap();
|
//let short_id: u32 = short_string_id.trim().parse().unwrap();
|
||||||
|
|
||||||
let name = container.names
|
let name = container.names
|
||||||
.and_then(|names| names.into_iter().next())
|
.and_then(|names| names.into_iter().next())
|
||||||
@@ -59,7 +59,7 @@ pub async fn get_available_container(docker: &Docker) -> Vec<DockerContainer> {
|
|||||||
println!(" - ID: {}, Image: {:?}, Name: {}", short_id, container.image, name);
|
println!(" - ID: {}, Image: {:?}, Name: {}", short_id, container.image, name);
|
||||||
|
|
||||||
Some(DockerContainer {
|
Some(DockerContainer {
|
||||||
ID: short_id,
|
ID: short_id.to_string(),
|
||||||
image,
|
image,
|
||||||
Name: name,
|
Name: name,
|
||||||
Status: status,
|
Status: status,
|
||||||
|
@@ -63,7 +63,7 @@ impl DockerContainer {
|
|||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// * `Result<u32, Box<dyn Error + Send + Sync>>` - Container ID as integer.
|
/// * `Result<u32, Box<dyn Error + Send + Sync>>` - Container ID as integer.
|
||||||
pub async fn get_docker_container_id(container: DockerContainer) -> Result<u32, Box<dyn Error + Send + Sync>> {
|
pub async fn get_docker_container_id(container: DockerContainer) -> Result<String, Box<dyn Error + Send + Sync>> {
|
||||||
Ok(container.ID)
|
Ok(container.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,7 +109,7 @@ impl Collector {
|
|||||||
ram_load: hardware.memory.current_load.unwrap_or_default(),
|
ram_load: hardware.memory.current_load.unwrap_or_default(),
|
||||||
ram_size: hardware.memory.total_size.unwrap_or_default(),
|
ram_size: hardware.memory.total_size.unwrap_or_default(),
|
||||||
disk_size: hardware.disk.total_size.unwrap_or_default(),
|
disk_size: hardware.disk.total_size.unwrap_or_default(),
|
||||||
disk_usage: hardware.disk.total_used.unwrap_or_default(),
|
disk_usage: hardware.disk.total_usage.unwrap_or_default(),
|
||||||
disk_temp: 0.0, // not supported
|
disk_temp: 0.0, // not supported
|
||||||
net_rx: hardware.network.rx_rate.unwrap_or_default(),
|
net_rx: hardware.network.rx_rate.unwrap_or_default(),
|
||||||
net_tx: hardware.network.tx_rate.unwrap_or_default(),
|
net_tx: hardware.network.tx_rate.unwrap_or_default(),
|
||||||
|
@@ -187,7 +187,7 @@ pub struct Acknowledgment {
|
|||||||
/// - `_cpu_load`: CPU usage as a percentage (**0.0–100.0**)
|
/// - `_cpu_load`: CPU usage as a percentage (**0.0–100.0**)
|
||||||
#[derive(Debug, Serialize, Clone)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
pub struct DockerContainer {
|
pub struct DockerContainer {
|
||||||
pub ID: u32,
|
pub ID: String,
|
||||||
pub image: String,
|
pub image: String,
|
||||||
pub Name: String,
|
pub Name: String,
|
||||||
pub Status: String, // "running";"stopped";others
|
pub Status: String, // "running";"stopped";others
|
||||||
|
Reference in New Issue
Block a user