Help us shape the future of Go! Take the 2026 Go Developer Survey

cligotop

package
v1.3.104 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package cligotop cmd/skywire-cli/commands/gotop/grpcdevice.go c4-vis-cli

Package cligotop cmd/skywire-cli/commands/gotop/root.go c4-vis-cli

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "gotop",
	Short: "Terminal based graphical activity monitor",
	Long: `A terminal based graphical activity monitor inspired by gtop and vtop.

By default, tries to connect to the local visor's gRPC server for system stats.
If unavailable, falls back to running gotop directly using local gopsutil.`,
	Run: func(cmd *cobra.Command, _ []string) {
		updateInterval, err := time.ParseDuration(rateFlag)
		if err != nil {
			internal.PrintFatalError(cmd.Flags(), fmt.Errorf("invalid rate: %v", err))
		}

		if remotePK != "" {
			if err := runRemoteMode(cmd, updateInterval); err != nil {
				internal.PrintFatalError(cmd.Flags(), err)
			}
			return
		}

		if localMode {
			if err := runDirectGotop(); err != nil {
				internal.PrintFatalError(cmd.Flags(), err)
			}
			return
		}

		grpcClient, err := rpcgrpc.NewPingClient(clirpc.Addr)
		if err != nil {

			stderrLogger.Printf("Visor gRPC not available, running gotop directly: %v", err)
			if err := runDirectGotop(); err != nil {
				internal.PrintFatalError(cmd.Flags(), err)
			}
			return
		}
		defer grpcClient.Close()

		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
		_, err = grpcClient.GetSystemStats(ctx, false, 0)
		cancel()
		if err != nil {

			stderrLogger.Printf("Visor gRPC available but GetSystemStats failed, running gotop directly: %v", err)
			if err := runDirectGotop(); err != nil {
				internal.PrintFatalError(cmd.Flags(), err)
			}
			return
		}

		if err := runVisorGotop(grpcClient, updateInterval); err != nil {
			internal.PrintFatalError(cmd.Flags(), err)
		}
	},
}

RootCmd is the gotop command

Functions

func SetupGRPCDevice

func SetupGRPCDevice(client *rpcgrpc.PingClient, _ string, updateInterval time.Duration, includeProcs bool, procLimit int32) error

SetupGRPCDevice makes the local visor gotop's only source of CPU, memory and temperature readings.

func SetupRemoteGRPCDevice

func SetupRemoteGRPCDevice(client *rpcgrpc.PingClient, remotePK string, updateInterval time.Duration, includeProcs bool, procLimit int32) error

SetupRemoteGRPCDevice initializes a gRPC device that fetches stats from a remote visor via DMSG. The local visor proxies the connection to the remote visor.

func ShutdownGRPCDevice

func ShutdownGRPCDevice()

ShutdownGRPCDevice shuts down the gRPC device and connection.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL