Remove hostname sending
This commit is contained in:
parent
58d53cab1e
commit
8824eb1ddb
1 changed files with 1 additions and 22 deletions
|
|
@ -67,8 +67,6 @@ pub struct AgentClient {
|
||||||
poller_registry: PollerRegistry,
|
poller_registry: PollerRegistry,
|
||||||
/// Counter for Phoenix transport heartbeat refs
|
/// Counter for Phoenix transport heartbeat refs
|
||||||
phx_heartbeat_ref: u64,
|
phx_heartbeat_ref: u64,
|
||||||
/// Cached hostname (computed once at startup, avoids blocking /proc reads)
|
|
||||||
cached_hostname: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AgentClient {
|
impl AgentClient {
|
||||||
|
|
@ -154,7 +152,6 @@ impl AgentClient {
|
||||||
monitoring_check_rx,
|
monitoring_check_rx,
|
||||||
poller_registry: PollerRegistry::new(),
|
poller_registry: PollerRegistry::new(),
|
||||||
phx_heartbeat_ref: 0,
|
phx_heartbeat_ref: 0,
|
||||||
cached_hostname: get_hostname(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -383,7 +380,7 @@ impl AgentClient {
|
||||||
async fn send_heartbeat(&mut self) -> Result<()> {
|
async fn send_heartbeat(&mut self) -> Result<()> {
|
||||||
let heartbeat = AgentHeartbeat {
|
let heartbeat = AgentHeartbeat {
|
||||||
version: crate::version::current_version().to_string(),
|
version: crate::version::current_version().to_string(),
|
||||||
hostname: self.cached_hostname.clone(),
|
hostname: String::new(),
|
||||||
uptime_seconds: get_uptime_seconds(),
|
uptime_seconds: get_uptime_seconds(),
|
||||||
ip_address: get_local_ip().unwrap_or_default(),
|
ip_address: get_local_ip().unwrap_or_default(),
|
||||||
};
|
};
|
||||||
|
|
@ -1299,17 +1296,6 @@ fn generate_agent_id() -> String {
|
||||||
format!("agent-{}", timestamp)
|
format!("agent-{}", timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get system hostname.
|
|
||||||
fn get_hostname() -> String {
|
|
||||||
// Try reading from /proc on Linux
|
|
||||||
if let Ok(hostname) = std::fs::read_to_string("/proc/sys/kernel/hostname") {
|
|
||||||
return hostname.trim().to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback to "unknown"
|
|
||||||
"unknown".to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get system uptime in seconds.
|
/// Get system uptime in seconds.
|
||||||
fn get_uptime_seconds() -> u64 {
|
fn get_uptime_seconds() -> u64 {
|
||||||
// Linux: read /proc/uptime (format: "uptime idle")
|
// Linux: read /proc/uptime (format: "uptime idle")
|
||||||
|
|
@ -1400,13 +1386,6 @@ mod tests {
|
||||||
let _ = uptime;
|
let _ = uptime;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_get_hostname() {
|
|
||||||
let hostname = get_hostname();
|
|
||||||
// Should return either the system hostname or "unknown"
|
|
||||||
assert!(!hostname.is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_base64_encode() {
|
fn test_base64_encode() {
|
||||||
assert_eq!(base64_encode(b"hello"), "aGVsbG8=");
|
assert_eq!(base64_encode(b"hello"), "aGVsbG8=");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue