Added agent uid to the client info so that client and agent can be correlated in prometheus/grafana.
This commit is contained in:
parent
bd4e2c277b
commit
fc92286998
@ -113,7 +113,6 @@ func (pubkeys *AuthorizedPublicKeys) monitorAuthorizedKeysFile(authorizedPublicK
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
base := filepath.Base(event.Name)
|
base := filepath.Base(event.Name)
|
||||||
log.Println("CHANGE " + base + " " + authorizedPublicKeysFile + " " + filepath.Base(authorizedPublicKeysFile))
|
|
||||||
if base == filepath.Base(authorizedPublicKeysFile) {
|
if base == filepath.Base(authorizedPublicKeysFile) {
|
||||||
keys, errorKeys := pubkeys.Parse()
|
keys, errorKeys := pubkeys.Parse()
|
||||||
for _, errorKey := range errorKeys {
|
for _, errorKey := range errorKeys {
|
||||||
|
@ -64,6 +64,7 @@ var (
|
|||||||
[]string{"guid",
|
[]string{"guid",
|
||||||
"id",
|
"id",
|
||||||
"agentid",
|
"agentid",
|
||||||
|
"agentguid",
|
||||||
"sessiontype",
|
"sessiontype",
|
||||||
"username",
|
"username",
|
||||||
"hostname",
|
"hostname",
|
||||||
@ -91,6 +92,7 @@ func clientLabels(client models.Client) prometheus.Labels {
|
|||||||
"guid": client.Guid,
|
"guid": client.Guid,
|
||||||
"id": client.ClientId,
|
"id": client.ClientId,
|
||||||
"agentid": client.PublicId,
|
"agentid": client.PublicId,
|
||||||
|
"agentguid": client.AgentGuid,
|
||||||
"sessiontype": client.SessionType,
|
"sessiontype": client.SessionType,
|
||||||
"username": client.EnvironmentInfo.Username,
|
"username": client.EnvironmentInfo.Username,
|
||||||
"hostname": client.EnvironmentInfo.Hostname,
|
"hostname": client.EnvironmentInfo.Hostname,
|
||||||
|
@ -97,6 +97,7 @@ func main() {
|
|||||||
client := models.Client{
|
client := models.Client{
|
||||||
Guid: strconv.Itoa(rand.Int()),
|
Guid: strconv.Itoa(rand.Int()),
|
||||||
PublicId: "c1",
|
PublicId: "c1",
|
||||||
|
AgentGuid: "12342342",
|
||||||
ClientId: "3",
|
ClientId: "3",
|
||||||
StartTime: time.Now().In(japan),
|
StartTime: time.Now().In(japan),
|
||||||
SessionType: "sftp",
|
SessionType: "sftp",
|
||||||
|
@ -9,6 +9,7 @@ type Client struct {
|
|||||||
Guid string
|
Guid string
|
||||||
PublicId string
|
PublicId string
|
||||||
ClientId string
|
ClientId string
|
||||||
|
AgentGuid string
|
||||||
StartTime time.Time
|
StartTime time.Time
|
||||||
SessionType string
|
SessionType string
|
||||||
EnvironmentInfo comms.EnvironmentInfo
|
EnvironmentInfo comms.EnvironmentInfo
|
||||||
|
@ -44,11 +44,12 @@ func NewAgent(commChannel comms.CommChannel, publicId string, agentInfo comms.En
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(publicId string, clientConn iowrappers2.ReadWriteAddrCloser,
|
func NewClient(publicId string, clientConn iowrappers2.ReadWriteAddrCloser,
|
||||||
agentConn net.Conn) *ClientConnection {
|
agentConn net.Conn, agentGuid string) *ClientConnection {
|
||||||
return &ClientConnection{
|
return &ClientConnection{
|
||||||
Client: models.Client{
|
Client: models.Client{
|
||||||
Guid: strconv.Itoa(rand.Int()),
|
Guid: strconv.Itoa(rand.Int()),
|
||||||
PublicId: publicId,
|
PublicId: publicId,
|
||||||
|
AgentGuid: agentGuid,
|
||||||
ClientId: strconv.Itoa(clientIdGenerator.IncrementAndGet()),
|
ClientId: strconv.Itoa(clientIdGenerator.IncrementAndGet()),
|
||||||
StartTime: time.Now(),
|
StartTime: time.Now(),
|
||||||
},
|
},
|
||||||
@ -201,7 +202,7 @@ func (admin *Admin) addClient(publicId string, clientConn iowrappers2.ReadWriteA
|
|||||||
|
|
||||||
log.Println("Sending connection information to agent")
|
log.Println("Sending connection information to agent")
|
||||||
|
|
||||||
client := NewClient(publicId, clientConn, agentConn)
|
client := NewClient(publicId, clientConn, agentConn, agent.Guid)
|
||||||
|
|
||||||
// Before using this connection for SSH we use it to send client metadata to the
|
// Before using this connection for SSH we use it to send client metadata to the
|
||||||
// agent
|
// agent
|
||||||
|
Loading…
Reference in New Issue
Block a user