Skip to main content

AgentStatusReport

Struct AgentStatusReport 

Source
pub struct AgentStatusReport {
Show 13 fields pub agent_id: String, pub instance_id: String, pub version: String, pub memory_bytes: Option<u64>, pub cpu_percent: Option<f64>, pub cpu_cores: Option<u32>, pub admin_latency_ms: Option<u64>, pub work_state_changes: Option<Vec<AgentWorkStateChange>>, pub discovery_policy_version: Option<i64>, pub local_work: Option<AgentLocalWork>, pub uplink_state: Option<AgentUplinkState>, pub certificate_status: Option<AgentCertificateStatus>, pub machine_profile: Option<HostProfile>,
}

Fields§

§agent_id: String§instance_id: String§version: String§memory_bytes: Option<u64>

Own resident-set size in bytes reported by the agent.

§cpu_percent: Option<f64>

Agent 进程自身 CPU 占用,单核口径(100% = 占满一个核;多线程进程可 >100)。

它只统计 agent 进程自己的 CPU 时间(getrusage(RUSAGE_SELF)),不含它拉起的子进程。

§cpu_cores: Option<u32>

Agent 所在机器的逻辑核数(available_parallelism)。

为什么必须和 cpu_percent 同一份上报带上来:cpu_percent 是单核口径, 而运维看图时真正常问的是「这台机器被它占了百分之几」——那是 cpu_percent / 核数。 少了核数,右侧那个数既算不出来、也无法复核(4 核上的 13% 和 64 核上的 13% 完全不是一回事)。

为什么让 agent 报原始值、而不是它自己算好整机占比:沿用本仓已有的取舍 (与 discovery_policy_version、事实摘要 digest 同理)——agent 只交原始事实 (自己的 CPU 时间、自己的核数),换算只留一处,在网关。agent 自算的派生值 一旦算法退化,下游没有任何一层能发现。

§admin_latency_ms: Option<u64>

Measured round-trip latency to the admin control plane in milliseconds.

§work_state_changes: Option<Vec<AgentWorkStateChange>>

自上次上报以来的工作状态变化(paused/resumed),非告警、非失败。

§discovery_policy_version: Option<i64>

本机实际生效的发现方向策略版本;None = 还没拿到策略表(在用内建默认周期)。

为什么必须由 agent 上报、而不是网关自己记账:网关知道自己发布了哪一版, 但不知道某台机器拉到并应用了哪一版 —— 拉取可能失败、可能还没到轮询节拍、 也可能拿到后被夹取。而运维要回答的正是那句「我改了策略,哪些机器还没生效」。

§local_work: Option<AgentLocalWork>

本机工作内容视图(state/work.json 的子集):我手里有哪些工作、各自在采哪些文件、 一次性工作做到哪一步。

为什么必须由 agent 上报:网关知道自己授权了什么,但「真的在采哪些文件」只有 agent 知道(本机手工加的输入、暂停、某条来源今天接不接得了)。网关侧只存最近一份。 None = 这台 agent 还没报过(旧版本 agent 不发这个字段)。

§uplink_state: Option<AgentUplinkState>

本机实际生效的采集输出状态(见 AgentUplinkState)。

为什么必须由 agent 上报:网关知道自己下发了「启用 + 目标」,但不知道 agent 生效成了什么 —— grant 可能还没拉到、可能被本机总闸拦住、可能目标连不上。 运维要回答的正是那句「这台为什么不上送」。

None = 这台 agent 还没报过(旧版本 agent 不发这个字段)—— 落库后保持上一次的值 (与 local_work 同口径)。

§certificate_status: Option<AgentCertificateStatus>

本机客户端证书状态(mTLS);还没有证书时 None。

为什么要 agent 上报:证书与到期时间只有本机知道(服务端在握手期就验完了, 而过期证书根本进不来);而「哪些机器快到期 / 已过期需重装」正是运维要提前看到的 (见 docs/design/agent-identity-mtls.md §5.5)。

None = 这台 agent 还没报过 / 没证书 —— 落库后保持上一次的值(与其他可选字段同口径)。

§machine_profile: Option<HostProfile>

机器画像(机器名 / node_id / machine_id / 网卡地址)—— 注册表里「这是哪台机器」的展示来源。

为什么由状态上报带(而不是只靠注册):凭证书首触重建登记时,机器画像全是空的 (证书只承载稳定身份),原设计指望「后续状态上报补齐」,但那条通道以前没有这些字段 —— 于是经证书注册的机器在管理面永远只剩一个 ID。这里把注册时的 HostProfile 原样带上。

None = 老版本 agentd 没带 —— 落库后保持上一次的值(与 local_work / uplink_state 同口径)。

Trait Implementations§

Source§

impl Clone for AgentStatusReport

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentStatusReport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AgentStatusReport

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for AgentStatusReport

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AgentStatusReport

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AgentStatusReport

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.