topidchart

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 26 Imported by: 1

README ¶

🚀 topid chart

topid is a cpu/mem stats visualization profiler.

Set CPU/MEM filter

Appending ?filter=avg CPU,max CPU,avg MEM,max MEM to the URL outputted by topid can set the filter which determines which processes you want to show in the chart. The default value is ?filter=2,10,10,20 which means:

  • The processes whose avg CPU usage less than 2% AND max CPU usage less than 10% will not show in CPU usage chart.
  • The processes whose avg MEM usage less than 10 MB AND max MEM usage less than 20 MB will not show in MEM usage chart.

For example, changing http://10.10.10.10:9998/meaningfultag/20211111-xdtfmvhd to http://10.10.10.10:9998/meaningfultag/20211111-xdtfmvhd?filter=1,10,5,10 will show more processes in the charts.

Be careful if you set the filter smaller than the default value, since it will slow down the showing of the charts.

How to start topid on target device

Check if gshell daemon is running

Each system that wants to join gshell service network, one gshell daemon should be running on that system.

cd /path/to/gshell
alias gsh='bin/gshell'
gsh info

gsh info outputs service not found: godevsig_gshellDaemon if gshell daemon has not been started. We need to download gshell and start gshell daemon first.

# Download gshell binary
mkdir -p gshell/bin
cd gshell
wget http://10.10.10.10:8088/gshell/release/latest/gshell.$(uname -a) -O bin/gshell
chmod +x bin/gshell

# Run gshell daemon
alias gsh='bin/gshell'
gsh -loglevel info daemon -registry 10.10.10.10:11985 -bcast 9923 &

Then gsh info should output below info:

~/gshell $ alias gsh='bin/gshell'
~/gshell $ gsh info
Version: v21.11.rc2
Build tags: stdbase,stdcommon,stdruntime,adaptiveservice,shell,log,pidinfo,topidchartmsg
Commit: 5e77199ae4d3c1579491177cacddb0d80b77bfd8
Options of gsh run
$ gsh run -h
Usage of run [options] <file.go> [args...]
        Look for file.go in local file system or else in `gshell repo`,
        run it in a new GRE in specified GRG on local/remote system:
  -group string
        create new or use existing GRG (default "<random>")
  -i    enter interactive mode
  -maxprocs int
        set GOMAXPROCS variable (default -1)
  -rm
        automatically remove the GRE when it exits
  -rt string
        set the GRG to SCHED_RR min/max priority 1/99 on new GRG creation
        Caution: gshell daemon must be started as root to set realtime attributes
  -ver string
        specify the running GRG version, default to target daemon version

Run topid app

Once gshell daemon has been started, use gsh run to run any go apps/services in the central repo:

~/gshell $ gsh repo
github.com/godevsig/ghub master

~/gshell $ gsh run -rt 91 -i perf/topid/topid.go -chart -snapshot -sys -i 5 -tag meaningfultag

Follow the URL that topid.go outputs to get topid chart.

Parameters of topid.go
  • topid by default collect all process performance data, use -p pid -child to specify pid if only the pid and its child are interested.
  • -chart: send data to chart server
  • -snapshot: optional, periodically send process data to chart server
  • -sys: also collect system CPU and mem data
  • -i 5: collect data every 5 seconds
  • -tag name: mark this run as "name", this tag will be part of the generated URL
  • -info "cmd1,cmd2,cmd3...": extra info of the system, will be shown in the web

See also:

  1. Deploy gshell daemon
  2. topid usage

gshell introduction

gshell is gshellos based service management tool.
gshellos is a simple pure golang service framework for linux devices that provides:

  • Flexible running model
    • Mixed execution mode to run go apps/services
      • interpreted mode for flexibility, compiled mode for performance
      • mix-used in runtime, easy to switch
    • Isolated Gshell Runtime Environment(GRE)
      • one service/app runs in one GRE
      • GRE has separate OS input, output, args
      • GREs share memory by communicating
    • App/service group mechanism
      • GREs can be grouped to run in one Gshell Runtime Group(GRG)
      • applicable real-time scheduling policy on GRG
      • zero communication cost in same GRG: zero data copy, no kernel round trip
      • group/ungroup by gshell command line at runtime
    • Remote deployment
  • Simplified and unified communication
    • Name based service publishing/discovery
      • a service is published under the name of {"publisher", "service"}
      • 4 scopes of service visibility: Process, OS, LAN, WAN
      • a service can be published in all the above scopes
      • a service is discovered in the above scope order
    • Message oriented client-server communication
      • servers define message structs, clients import message structs
      • simple Send() Recv() API and RPC alike SendRecv() API
      • data encoding/serializing when necessary
      • messages can be reordered by predefined priority
    • High concurrency model
      • client side multiplexed connection
      • server side auto scale worker pool
      • of course go routines and go channels
  • Zero deploy dependency on all CPU arch
    • X86, ARM, MIPS, PPC...
    • embedded boxes, cloud containers, server VMs...
    • only one binary is needed
  • Zero cost for service/app migration between different scopes/machines/locations
    • no code change, no recompile, no redeploy
    • gshell command line to move services/apps around at runtime
  • Auto update without impacting the running services
  • Interactive and native debugging with built-in REPL shell
  • P2P network model
    • zero config, self discovered and managed network
    • auto reverse proxy for service behind NAT

See godevsig/gshellos for details.

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func ParseFile ¶

func ParseFile(filename string) error

ParseFile parse encode record file

Types ¶

type ProcessInfo ¶

type ProcessInfo struct {
	Pid  int
	Name string
	Ucpu float32
	Scpu float32
	Mem  uint64 // in KB
}

ProcessInfo is process statistics.

type Record ¶

type Record struct {
	Timestamp int64
	Processes []ProcessInfo
	Snapshot  string
}

Record is sent by client periodically including target processes info, an optional snapshot such as process tree, and timestamp.

type Server ¶

type Server struct {
	// contains filtered or unexported fields
}

Server represents data server

func NewServer ¶

func NewServer(lg *log.Logger, port, dir string) *Server

NewServer creates a new server instance.

func (*Server) Close ¶

func (server *Server) Close()

Close shutdown the server.

func (*Server) Run ¶

func (server *Server) Run() error

Run runs the server.

type SessionRequest ¶

type SessionRequest struct {
	Tag       string
	SysInfo   SysInfo
	ExtraInfo string
}

SessionRequest is the message sent by client. Return SessionResponse. Client should send one or more Record after SessionResponse is received.

func (*SessionRequest) Handle ¶

func (msg *SessionRequest) Handle(stream as.ContextStream) (reply interface{})

Handle handles SessionRequest.

type SessionResponse ¶

type SessionResponse struct {
	ChartURL string
}

SessionResponse is the message replied by server.

type SysInfo ¶

type SysInfo struct {
	CPUInfo    string
	KernelInfo string
}

SysInfo is part of SessionRequest used to initiate a collecting session.

Directories ¶

Path Synopsis

Jump to

Keyboard shortcuts

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