github.com/crowdsecurity/crowdsec@v1.6.1/cmd/crowdsec-cli/machines_table.go (about)

     1  package main
     2  
     3  import (
     4  	"io"
     5  	"time"
     6  
     7  	"github.com/aquasecurity/table"
     8  
     9  	"github.com/crowdsecurity/crowdsec/pkg/database/ent"
    10  	"github.com/crowdsecurity/crowdsec/pkg/emoji"
    11  )
    12  
    13  func getAgentsTable(out io.Writer, machines []*ent.Machine) {
    14  	t := newLightTable(out)
    15  	t.SetHeaders("Name", "IP Address", "Last Update", "Status", "Version", "Auth Type", "Last Heartbeat")
    16  	t.SetHeaderAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft)
    17  	t.SetAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft)
    18  
    19  	for _, m := range machines {
    20  		validated := emoji.Prohibited
    21  		if m.IsValidated {
    22  			validated = emoji.CheckMark
    23  		}
    24  
    25  		hb, active := getLastHeartbeat(m)
    26  		if !active {
    27  			hb = emoji.Warning + " " + hb
    28  		}
    29  
    30  		t.AddRow(m.MachineId, m.IpAddress, m.UpdatedAt.Format(time.RFC3339), validated, m.Version, m.AuthType, hb)
    31  	}
    32  
    33  	t.Render()
    34  }