Documentation
¶
Index ¶
- Constants
- Variables
- func Addr() string
- func GenerateHTMLReport(ctx context.Context, htmlFilename string, jsData string)
- func GetNetStats(interfaces []net.Interface, dir string) []float64
- func GetSockOpt(fd uintptr, value int) (int, error)
- func HasNetStats() error
- func Interval() int
- func LinkAddr() string
- func OpenViewer(ctx context.Context, openBrowser bool)
- func SetConfiguration(opts ...Option)
- type CPUViewer
- type Metrics
- type NetInterfacesViewer
- type Option
- type StatsMgr
- type Theme
- type ViewManager
- type Viewer
Constants ¶
const ( DefaultTemplate = `` /* 926-byte string literal not displayed */ DefaultMaxPoints = 30 DefaultTimeFormat = "15:04:05" DefaultInterval = 2000 DefaultAddr = "localhost:18066" DefaultTheme = ThemeMacarons )
const (
//
VCPU = "CPU"
)
const (
//
VNetInterfaces = "Network Interfaces"
)
Variables ¶
var ChartNames = map[string]string{
"rx": "download",
"tx": "upload",
}
var ErrNotImplemented = errors.New("not implemented yet")
var ErrNotSupported = errors.New("not supported")
var GoStatsFrequency = 250 * time.Millisecond
the defaut frequency for Go stats.
var GoStatsRoute = "/rt/gostats"
the path for Go stats
var StaticFiles fs.FS
var ViewerTmplHTML string // the template has only one unnamed action ({{.}}) which will be replaced with json data
Functions ¶
func GenerateHTMLReport ¶
GenerateHTMLReport produces HTML file from jsData if filename is ":" opens result from a temporary local web browser
func GetNetStats ¶
return rx/tx counters for interfaces - Linux version
func HasNetStats ¶
func HasNetStats() error
func OpenViewer ¶
func SetConfiguration ¶
func SetConfiguration(opts ...Option)
Types ¶
type CPUViewer ¶
type CPUViewer struct {
// contains filtered or unexported fields
}
CPUViewer collects the cpu number metrics via `gopsutil/cpu`
func (*CPUViewer) SetStatsMgr ¶
type NetInterfacesViewer ¶
type NetInterfacesViewer struct {
// contains filtered or unexported fields
}
NetInterfacesViewer collects network interfaces counters
func (*NetInterfacesViewer) Name ¶
func (vr *NetInterfacesViewer) Name() string
func (*NetInterfacesViewer) Serve ¶
func (vr *NetInterfacesViewer) Serve(w http.ResponseWriter, _ *http.Request)
func (*NetInterfacesViewer) SetStatsMgr ¶
func (vr *NetInterfacesViewer) SetStatsMgr(smgr *StatsMgr)
func (*NetInterfacesViewer) View ¶
func (vr *NetInterfacesViewer) View() *charts.Line
type Option ¶
type Option func(c *config)
func WithInterval ¶
WithInterval sets the interval of collecting and pulling metrics
func WithMaxPoints ¶
WithMaxPoints sets the maximum points of each chart series
func WithTemplate ¶
WithTemplate sets the rendered template which fetching stats from the server and handling the metrics data
func WithTimeFormat ¶
WithTimeFormat sets the time format for the line-chart Y-axis label
type StatsMgr ¶
type StatsMgr struct {
Ctx context.Context
Cancel context.CancelFunc
// contains filtered or unexported fields
}
type Theme ¶
type Theme string
const ( ThemeWesteros Theme = types.ThemeWesteros ThemeMacarons Theme = types.ThemeMacarons )
type ViewManager ¶
type ViewManager struct {
Smgr *StatsMgr
Ctx context.Context
Cancel context.CancelFunc
Views []Viewer
PerfViews []viewer.Viewer
// contains filtered or unexported fields
}
ViewManager
func NewViewManager ¶
func NewViewManager(tick time.Duration, path string, interfaceNames []string, debug bool) (*ViewManager, error)
New creates a new ViewManager instance
func (*ViewManager) PerfRegister ¶
func (vm *ViewManager) PerfRegister(views ...viewer.Viewer)
PerfRegister registers perf views to the external ViewManager
func (*ViewManager) Register ¶
func (vm *ViewManager) Register(views ...Viewer)
Register registers views to the ViewManager
func (*ViewManager) RegisterRoutes ¶
func (vm *ViewManager) RegisterRoutes(mux *http.ServeMux)
type Viewer ¶
type Viewer interface {
Name() string
View() *charts.Line
Serve(w http.ResponseWriter, _ *http.Request)
SetStatsMgr(smgr *StatsMgr)
}
Viewer is the abstraction of a Graph which in charge of collecting metrics from somewhere
func NewCPUViewer ¶
NewCPUViewer returns the CPUViewer instance Series: CPUCores