Addes agent address and client address to the client and agent info.
This commit is contained in:
		
							parent
							
								
									ad72c41347
								
							
						
					
					
						commit
						061fabfd07
					
				| @ -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, | ||||
|  | ||||
| @ -82,6 +82,7 @@ func main() { | ||||
| 		state := models.State{} | ||||
| 		agent := models.Agent{ | ||||
| 			Guid:       strconv.Itoa(rand.Int()), | ||||
| 			RemoteAddr: "10.220.1.3:3333", | ||||
| 			PublicId:   "id", | ||||
| 			StartTime:  time.Now().In(japan), | ||||
| 			EnvironmentInfo: comms.EnvironmentInfo{ | ||||
|  | ||||
| @ -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 | ||||
| } | ||||
|  | ||||
| @ -7,9 +7,12 @@ import ( | ||||
| 
 | ||||
| type Agent struct { | ||||
| 	Guid       string | ||||
| 	RemoteAddr string | ||||
| 	PublicId   string | ||||
| 	StartTime  time.Time | ||||
| 
 | ||||
| 	// TODO add remote address.
 | ||||
| 
 | ||||
| 	EnvironmentInfo comms.EnvironmentInfo | ||||
| 	ExpiryTime      time.Time | ||||
| } | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user