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