diff --git a/cmd/converge/prometheus.go b/cmd/converge/prometheus.go index 99db458..d5db9d3 100644 --- a/cmd/converge/prometheus.go +++ b/cmd/converge/prometheus.go @@ -70,6 +70,7 @@ var ( }, []string{ "agent_guid", + "agent_address", "agent_id", "agent_username", "agent_hostname", @@ -85,6 +86,7 @@ var ( Help: "A flexible gauge with dynamic labels, always set to 1", }, []string{"client_guid", + "client_address", "client_id", "agent_id", "agent_guid", @@ -101,6 +103,7 @@ var ( func agentLabels(agent models.Agent) prometheus.Labels { return prometheus.Labels{ "agent_guid": agent.Guid, + "agent_address": agent.RemoteAddr, "agent_id": agent.PublicId, "agent_username": agent.EnvironmentInfo.Username, "agent_hostname": agent.EnvironmentInfo.Hostname, @@ -113,6 +116,7 @@ func agentLabels(agent models.Agent) prometheus.Labels { func clientLabels(client models.Client) prometheus.Labels { return prometheus.Labels{ "client_guid": client.Guid, + "client_address": client.RemoteAddr, "client_id": client.ClientId, "agent_id": client.PublicId, "agent_guid": client.AgentGuid, diff --git a/cmd/templaterender/render.go b/cmd/templaterender/render.go index 9e9cd38..9bc04e6 100644 --- a/cmd/templaterender/render.go +++ b/cmd/templaterender/render.go @@ -81,9 +81,10 @@ func main() { state := models.State{} agent := models.Agent{ - Guid: strconv.Itoa(rand.Int()), - PublicId: "id", - StartTime: time.Now().In(japan), + Guid: strconv.Itoa(rand.Int()), + RemoteAddr: "10.220.1.3:3333", + PublicId: "id", + StartTime: time.Now().In(japan), EnvironmentInfo: comms.EnvironmentInfo{ Username: "ci", Hostname: "container123", diff --git a/pkg/comms/agentserver.go b/pkg/comms/agentserver.go index 03c7c40..5c61296 100644 --- a/pkg/comms/agentserver.go +++ b/pkg/comms/agentserver.go @@ -11,7 +11,7 @@ import ( const MESSAGE_TIMEOUT = 10 * time.Second type CommChannel struct { - // a separet connection outside of the ssh session + // a separate connection outside of the ssh session SideChannel GOBChannel Session *yamux.Session } diff --git a/pkg/models/agent.go b/pkg/models/agent.go index 2db66da..41eedc2 100644 --- a/pkg/models/agent.go +++ b/pkg/models/agent.go @@ -6,9 +6,12 @@ import ( ) type Agent struct { - Guid string - PublicId string - StartTime time.Time + Guid string + RemoteAddr string + PublicId string + StartTime time.Time + + // TODO add remote address. EnvironmentInfo comms.EnvironmentInfo ExpiryTime time.Time diff --git a/pkg/server/admin/admin.go b/pkg/server/admin/admin.go index f65e6a4..e25ba25 100644 --- a/pkg/server/admin/admin.go +++ b/pkg/server/admin/admin.go @@ -34,6 +34,7 @@ func newAgent(commChannel comms.CommChannel, publicId string, agentInfo comms.En return &agentConnection{ Agent: models.Agent{ Guid: strconv.Itoa(rand.Int()), + RemoteAddr: commChannel.Session.RemoteAddr().String(), PublicId: publicId, StartTime: time.Now(), EnvironmentInfo: agentInfo,