Testing
This commit is contained in:
parent
42aaebf6a7
commit
bb69f0f31b
@ -208,9 +208,9 @@ impl SystemCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn determine_cpu_status(&self, cpu_load_5: f32) -> String {
|
fn determine_cpu_status(&self, cpu_load_5: f32) -> String {
|
||||||
if cpu_load_5 >= 8.0 {
|
if cpu_load_5 >= 10.0 {
|
||||||
"critical".to_string()
|
"critical".to_string()
|
||||||
} else if cpu_load_5 >= 5.0 {
|
} else if cpu_load_5 >= 9.0 {
|
||||||
"warning".to_string()
|
"warning".to_string()
|
||||||
} else {
|
} else {
|
||||||
"ok".to_string()
|
"ok".to_string()
|
||||||
|
|||||||
@ -208,15 +208,22 @@ impl App {
|
|||||||
.filter_map(|host| {
|
.filter_map(|host| {
|
||||||
self.host_states
|
self.host_states
|
||||||
.get(&host.name)
|
.get(&host.name)
|
||||||
.map(|state| HostDisplayData {
|
.and_then(|state| {
|
||||||
name: host.name.clone(),
|
// Only show hosts that have successfully connected at least once
|
||||||
last_success: state.last_success.clone(),
|
if state.last_success.is_some() {
|
||||||
last_error: state.last_error.clone(),
|
Some(HostDisplayData {
|
||||||
connection_status: state.connection_status.clone(),
|
name: host.name.clone(),
|
||||||
smart: state.smart.clone(),
|
last_success: state.last_success.clone(),
|
||||||
services: state.services.clone(),
|
last_error: state.last_error.clone(),
|
||||||
system: state.system.clone(),
|
connection_status: state.connection_status.clone(),
|
||||||
backup: state.backup.clone(),
|
smart: state.smart.clone(),
|
||||||
|
services: state.services.clone(),
|
||||||
|
system: state.system.clone(),
|
||||||
|
backup: state.backup.clone(),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
@ -410,91 +417,35 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_hosts(host: Option<&String>, config: Option<&AppConfig>) -> Vec<HostTarget> {
|
fn select_hosts(host: Option<&String>, _config: Option<&AppConfig>) -> Vec<HostTarget> {
|
||||||
let mut targets = Vec::new();
|
let mut targets = Vec::new();
|
||||||
|
|
||||||
|
// Known CMTEC infrastructure hosts for auto-discovery
|
||||||
|
let known_hosts = vec![
|
||||||
|
"cmbox", "labbox", "simonbox", "steambox", "srv01"
|
||||||
|
];
|
||||||
|
|
||||||
if let Some(filter) = host {
|
if let Some(filter) = host {
|
||||||
let normalized = filter.to_lowercase();
|
// If specific host requested, only connect to that one
|
||||||
|
|
||||||
if let Some(config) = config {
|
|
||||||
if let Some(entry) = config.hosts.hosts.iter().find(|candidate| {
|
|
||||||
candidate.enabled && candidate.name.to_lowercase() == normalized
|
|
||||||
}) {
|
|
||||||
return vec![entry.clone()];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vec![HostTarget::from_name(filter.clone())];
|
return vec![HostTarget::from_name(filter.clone())];
|
||||||
}
|
}
|
||||||
|
|
||||||
let local_host = Self::local_hostname();
|
let local_host = Self::local_hostname();
|
||||||
|
|
||||||
if let Some(config) = config {
|
// Always use auto-discovery - skip config files
|
||||||
if let Some(local) = local_host.as_ref() {
|
if let Some(local) = local_host.as_ref() {
|
||||||
if let Some(entry) = config.hosts.hosts.iter().find(|candidate| {
|
targets.push(HostTarget::from_name(local.clone()));
|
||||||
candidate.enabled && candidate.name.eq_ignore_ascii_case(local)
|
}
|
||||||
}) {
|
|
||||||
targets.push(entry.clone());
|
// Add all known hosts for auto-discovery
|
||||||
} else {
|
for hostname in known_hosts {
|
||||||
targets.push(HostTarget::from_name(local.clone()));
|
if targets
|
||||||
}
|
.iter()
|
||||||
}
|
.any(|existing| existing.name.eq_ignore_ascii_case(hostname))
|
||||||
|
{
|
||||||
for entry in &config.hosts.hosts {
|
continue;
|
||||||
if !entry.enabled {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if targets
|
|
||||||
.iter()
|
|
||||||
.any(|existing| existing.name.eq_ignore_ascii_case(&entry.name))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
targets.push(entry.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
if targets.len() <= 1 {
|
|
||||||
if let Some(default_host) = &config.hosts.default_host {
|
|
||||||
if !targets
|
|
||||||
.iter()
|
|
||||||
.any(|existing| existing.name.eq_ignore_ascii_case(default_host))
|
|
||||||
{
|
|
||||||
if let Some(entry) = config.hosts.hosts.iter().find(|candidate| {
|
|
||||||
candidate.enabled && candidate.name.eq_ignore_ascii_case(default_host)
|
|
||||||
}) {
|
|
||||||
targets.push(entry.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if targets.is_empty() {
|
|
||||||
if let Some(local) = local_host {
|
|
||||||
targets.push(HostTarget::from_name(local));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// No config file - use auto-discovery with known CMTEC hosts
|
|
||||||
let known_hosts = vec![
|
|
||||||
"cmbox", "labbox", "simonbox", "steambox", "srv01"
|
|
||||||
];
|
|
||||||
|
|
||||||
if let Some(local) = local_host.as_ref() {
|
|
||||||
targets.push(HostTarget::from_name(local.clone()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add all known hosts for auto-discovery
|
|
||||||
for hostname in known_hosts {
|
|
||||||
if targets
|
|
||||||
.iter()
|
|
||||||
.any(|existing| existing.name.eq_ignore_ascii_case(hostname))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
targets.push(HostTarget::from_name(hostname.to_string()));
|
|
||||||
}
|
}
|
||||||
|
targets.push(HostTarget::from_name(hostname.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if targets.is_empty() {
|
if targets.is_empty() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user