2022-10-07 09:05:35 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/aquasecurity/table"
|
|
|
|
"github.com/enescakir/emoji"
|
|
|
|
|
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/database/ent"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getAgentsTable(out io.Writer, machines []*ent.Machine) {
|
|
|
|
t := newLightTable(out)
|
|
|
|
t.SetHeaders("Name", "IP Address", "Last Update", "Status", "Version", "Auth Type", "Last Heartbeat")
|
|
|
|
t.SetHeaderAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft)
|
|
|
|
t.SetAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft)
|
|
|
|
|
|
|
|
for _, m := range machines {
|
|
|
|
var validated string
|
|
|
|
if m.IsValidated {
|
|
|
|
validated = emoji.CheckMark.String()
|
|
|
|
} else {
|
|
|
|
validated = emoji.Prohibited.String()
|
|
|
|
}
|
|
|
|
|
2023-06-08 13:08:51 +00:00
|
|
|
hb, active := getLastHeartbeat(m)
|
|
|
|
if !active {
|
|
|
|
hb = emoji.Warning.String() + " " + hb
|
|
|
|
}
|
|
|
|
t.AddRow(m.MachineId, m.IpAddress, m.UpdatedAt.Format(time.RFC3339), validated, m.Version, m.AuthType, hb)
|
2022-10-07 09:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t.Render()
|
|
|
|
}
|