package collector import ( "context" "mfd-monitor-agent/internal/snapshot" "mfd-monitor-agent/internal/status" ) // namedCollector 将稳定的采集器名称与采集函数绑定。 type namedCollector struct { name string fn func(context.Context, *status.HostStatus) error } // Name 返回用于快照错误记录的采集器名称。 func (c namedCollector) Name() string { return c.name } // Collect 执行绑定的采集函数。 func (c namedCollector) Collect(ctx context.Context, out *status.HostStatus) error { return c.fn(ctx, out) } // New 返回当前平台的默认采集器集合。 func New(hostID string) []snapshot.Collector { return []snapshot.Collector{ namedCollector{name: "system", fn: func(ctx context.Context, out *status.HostStatus) error { return collectSystem(ctx, hostID, out) }}, namedCollector{name: "network", fn: collectNetwork}, namedCollector{name: "resource", fn: collectResource}, namedCollector{name: "process", fn: collectProcesses}, namedCollector{name: "socket", fn: collectSockets}, } }