diff --git a/conf/mig-agent-conf.go.inc b/conf/mig-agent-conf.go.inc index 1ba194b0..720824c6 100644 --- a/conf/mig-agent-conf.go.inc +++ b/conf/mig-agent-conf.go.inc @@ -16,6 +16,14 @@ import( _ "mig/modules/example" ) +// some tags that are useful to differentiate agents. You can add whatever +// you want in this struct, it will be sent by the agent in each heartbeat +var TAGS = struct { + Operator string `json:"operator"` +}{ + "MyFavoriteAdminTeam", +} + // restart the agent on failures, don't let it die var ISIMMORTAL bool = true diff --git a/src/mig/agent.go b/src/mig/agent.go index 50530b2d..fb671ba9 100644 --- a/src/mig/agent.go +++ b/src/mig/agent.go @@ -14,18 +14,19 @@ import ( // Agent stores the description of an agent and serves as a canvas // for heartbeat messages type Agent struct { - ID float64 `json:"id,omitempty"` - Name string `json:"name"` - QueueLoc string `json:"queueloc"` - OS string `json:"os,omitempty"` - Version string `json:"version,omitempty"` - PID int `json:"pid,omitempty"` - StartTime time.Time `json:"starttime,omitempty"` - DestructionTime time.Time `json:"destructiontime,omitempty"` - HeartBeatTS time.Time `json:"heartbeatts,omitempty"` - Status string `json:"status,omitempty"` - Authorized bool `json:"authorized,omitempty"` - Env AgentEnv `json:"environment,omitempty"` + ID float64 `json:"id,omitempty"` + Name string `json:"name"` + QueueLoc string `json:"queueloc"` + OS string `json:"os,omitempty"` + Version string `json:"version,omitempty"` + PID int `json:"pid,omitempty"` + StartTime time.Time `json:"starttime,omitempty"` + DestructionTime time.Time `json:"destructiontime,omitempty"` + HeartBeatTS time.Time `json:"heartbeatts,omitempty"` + Status string `json:"status,omitempty"` + Authorized bool `json:"authorized,omitempty"` + Env AgentEnv `json:"environment,omitempty"` + Tags interface{} `json:"tags,omitempty"` } // AgentEnv stores basic information of the endpoint diff --git a/src/mig/agent/agent.go b/src/mig/agent/agent.go index 5c966bbd..e3ddd8b0 100644 --- a/src/mig/agent/agent.go +++ b/src/mig/agent/agent.go @@ -531,6 +531,7 @@ func heartbeat(ctx Context) (err error) { QueueLoc: ctx.Agent.QueueLoc, StartTime: time.Now(), Env: ctx.Agent.Env, + Tags: ctx.Agent.Tags, } // loop forever diff --git a/src/mig/agent/context.go b/src/mig/agent/context.go index f1c34ea9..db88852a 100644 --- a/src/mig/agent/context.go +++ b/src/mig/agent/context.go @@ -35,6 +35,7 @@ type Context struct { Hostname, OS, QueueLoc, UID, BinPath, RunDir string Respawn bool Env mig.AgentEnv + Tags interface{} } Channels struct { // internal @@ -75,6 +76,7 @@ func Init(foreground, upgrade bool) (ctx Context, err error) { } ctx.Channels.Log <- mig.Log{Desc: "leaving initAgent()"}.Debug() }() + ctx.Agent.Tags = TAGS ctx.Logging, err = mig.InitLogger(LOGGINGCONF, "mig-agent") if err != nil {