This repository has been archived by the owner on Sep 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 234
/
agent.go
82 lines (74 loc) · 3.47 KB
/
agent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Contributor: Julien Vehent [email protected] [:ulfr]
package mig /* import "github.com/mozilla/mig" */
import "time"
// Various agent status values
const (
AgtStatusOnline string = "online"
AgtStatusDestroyed string = "destroyed"
AgtStatusOffline string = "offline"
AgtStatusIdle string = "idle"
)
// 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"`
Mode string `json:"mode"`
Version string `json:"version,omitempty"`
PID int `json:"pid,omitempty"`
LoaderName string `json:"loadername,omitempty"`
StartTime time.Time `json:"starttime,omitempty"`
DestructionTime time.Time `json:"destructiontime,omitempty"`
HeartBeatTS time.Time `json:"heartbeatts,omitempty"`
RefreshTS time.Time `json:"refreshts,omitempty"`
Status string `json:"status,omitempty"`
Authorized bool `json:"authorized,omitempty"`
Env AgentEnv `json:"environment,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
}
// AgentEnv stores basic information of the endpoint
type AgentEnv struct {
Init string `json:"init,omitempty"`
Ident string `json:"ident,omitempty"`
OS string `json:"os,omitempty"`
Arch string `json:"arch,omitempty"`
IsProxied bool `json:"isproxied"`
Proxy string `json:"proxy,omitempty"`
Addresses []string `json:"addresses,omitempty"`
PublicIP string `json:"publicip,omitempty"`
AWS AgentEnvAWS `json:"aws,omitempty"`
Modules []string `json:"modules,omitempty"`
}
// AgentEnvAWS stores AWS specific agent environment values
type AgentEnvAWS struct {
InstanceID string `json:"instanceid,omitempty"`
LocalIPV4 string `json:"localipv4,omitempty"`
AMIID string `json:"amiid,omitempty"`
InstanceType string `json:"instancetype,omitempty"`
}
// AgentsStats stores information about the global MIG environment, primarily used
// in command line tools and the API/scheduler
type AgentsStats struct {
Timestamp time.Time `json:"timestamp"`
OnlineAgents float64 `json:"onlineagents"`
OnlineAgentsByVersion []AgentsVersionsSum `json:"onlineagentsbyversion"`
OnlineEndpoints float64 `json:"onlineendpoints"`
IdleAgents float64 `json:"idleagents"`
IdleAgentsByVersion []AgentsVersionsSum `json:"idleagentsbyversion"`
IdleEndpoints float64 `json:"idleendpoints"`
NewEndpoints float64 `json:"newendpoints"`
MultiAgentsEndpoints float64 `json:"multiagentsendpoints"`
DisappearedEndpoints float64 `json:"disappearedendpoints"`
FlappingEndpoints float64 `json:"flappingendpoints"`
}
// AgentsVersionsSum stores information on the count of agents at a specific version
// level, primarily used in command line tools and the API/scheduler
type AgentsVersionsSum struct {
Version string `json:"version"`
Count float64 `json:"count"`
}