package cmd import ( "fmt" "github.com/olekukonko/tablewriter" "github.com/urfave/cli/v2" "os/user" "strings" "csctl/internal" ) func Resources(*cli.Context) error { u, _ := user.Current() memoryUsage, err := internal.ContactSR(&internal.TCPData{Type: "ram", Username: u.Username}) if err != nil { return internal.Error(err, "Unable to fetch information from CSD.") } storageUsage, err := internal.ContactSR(&internal.TCPData{Type: "storage", Username: u.Username}) if err != nil { return internal.Error(err, "Unable to fetch information from CSD.") } processCount, err := internal.ContactSR(&internal.TCPData{Type: "processcount", Username: u.Username}) if err != nil { return internal.Error(err, "Unable to fetch information from CSD.") } sshLogins, err := internal.ContactSR(&internal.TCPData{Type: "sshlogins", Username: u.Username}) tableString := &strings.Builder{} table := tablewriter.NewWriter(tableString) table.SetHeader([]string{"RAM Usage", "Storage Usage", "Processes Running", "SSH Logins"}) table.Append([]string{memoryUsage, storageUsage, processCount, sshLogins}) table.Render() fmt.Println(tableString.String()) return nil }