Add organization/site/tags support for machine grouping
- Added organization, site, tags columns to connect_machines table - Agent now sends org/site/tags from embedded config in AgentStatus - Server stores org/site/tags metadata in database - Enables grouping machines by client/site/tag in dashboard
This commit is contained in:
@@ -313,6 +313,16 @@ async fn handle_agent_connection(
|
||||
} else {
|
||||
Some(status.agent_version.clone())
|
||||
};
|
||||
let organization = if status.organization.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(status.organization.clone())
|
||||
};
|
||||
let site = if status.site.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(status.site.clone())
|
||||
};
|
||||
sessions_status.update_agent_status(
|
||||
session_id,
|
||||
Some(status.os_version.clone()),
|
||||
@@ -321,6 +331,9 @@ async fn handle_agent_connection(
|
||||
status.display_count,
|
||||
status.is_streaming,
|
||||
agent_version.clone(),
|
||||
organization.clone(),
|
||||
site.clone(),
|
||||
status.tags.clone(),
|
||||
).await;
|
||||
|
||||
// Update version in database if present
|
||||
@@ -328,8 +341,19 @@ async fn handle_agent_connection(
|
||||
let _ = crate::db::releases::update_machine_version(db.pool(), &agent_id, version).await;
|
||||
}
|
||||
|
||||
info!("Agent status update: {} - streaming={}, uptime={}s, version={:?}",
|
||||
status.hostname, status.is_streaming, status.uptime_secs, agent_version);
|
||||
// Update organization/site/tags in database if present
|
||||
if let Some(ref db) = db {
|
||||
let _ = crate::db::machines::update_machine_metadata(
|
||||
db.pool(),
|
||||
&agent_id,
|
||||
organization.as_deref(),
|
||||
site.as_deref(),
|
||||
&status.tags,
|
||||
).await;
|
||||
}
|
||||
|
||||
info!("Agent status update: {} - streaming={}, uptime={}s, version={:?}, org={:?}, site={:?}",
|
||||
status.hostname, status.is_streaming, status.uptime_secs, agent_version, organization, site);
|
||||
}
|
||||
Some(proto::message::Payload::Heartbeat(_)) => {
|
||||
// Update heartbeat timestamp
|
||||
|
||||
Reference in New Issue
Block a user