monitor

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorModeNone = iota
	ColorModePercentage
)

Variables

View Source
var IOCount = 50

Functions

func CreateMemoryBarGraph

func CreateMemoryBarGraph(length int, meminfo *linux.MemInfo) (memory, swap string)

func CreatePercentGraph

func CreatePercentGraph(length int, value, total float64, color string) string

func Run

func Run(r *sshrun.Run) (err error)

Types

type CPUUsage

type CPUUsage struct {
	linux.CPUStat
	Detail    []linux.CPUStat
	Timestamp time.Time
}

CPUUsage is monitoring cpu struct. cpu is CPUStatAll only

type CPUUsageTop

type CPUUsageTop struct {
	Low    float64
	Normal float64
	Kernel float64
	Guest  float64
	Total  float64
}

type DiskIO

type DiskIO struct {
	Device     string
	ReadIOs    uint64
	ReadBytes  int64
	WriteIOs   uint64
	WriteBytes int64
}

type DiskUsage

type DiskUsage struct {
	MountPoint   string
	FSType       string
	Device       string
	All          uint64
	Used         uint64
	Free         uint64
	ReadIOBytes  []int64
	WriteIOBytes []int64
}

type Graph

type Graph struct {
	// Data is the data to be graphed.
	Data []float64

	// Min and Max are the minimum and maximum values of the graph.
	Min float64
	Max float64

	// ColorMode
	ColorMode int
}

func (*Graph) BrailleLine

func (g *Graph) BrailleLine() (result []string)

func (*Graph) Sparkline

func (g *Graph) Sparkline() (result []string)

type MemoryUsage

type MemoryUsage struct {
	*linux.MemInfo
	// contains filtered or unexported fields
}

MemoryUsage is monitoring memory struct

type Monitor

type Monitor struct {
	// selected server list
	ServerList []string

	// Node list
	Nodes []*Node

	// View
	View *mview.Application

	// Panel
	PanelCounter int
	Panels       *mview.TabbedPanels

	// BaseTab(List)
	BaseGrid *mview.Grid

	sync.Mutex
	// contains filtered or unexported fields
}

func (*Monitor) CreateNode

func (m *Monitor) CreateNode(server string, wg *sync.WaitGroup)

func (*Monitor) DrawUpdate

func (m *Monitor) DrawUpdate()

func (*Monitor) GetNode

func (m *Monitor) GetNode(server string) *Node

func (*Monitor) StartView

func (m *Monitor) StartView()

StartView is start view application.

type NetworkIO

type NetworkIO struct {
	Device    string
	RXPackets uint64
	RXBytes   uint64
	TXPackets uint64
	TXBytes   uint64
	sync.RWMutex
}

type NetworkUsage

type NetworkUsage struct {
	Device      string
	IPv4Address string
	IPv6Address string
	RXBytes     []uint64
	TXBytes     []uint64
	RXPackets   []uint64
	TXPackets   []uint64
}

type Node

type Node struct {
	ServerName string

	// Path
	PathProcStat      string
	PathProcCpuinfo   string
	PathProcMeminfo   string
	PathProcUptime    string
	PathProcLoadavg   string
	PathProcMounts    string
	PathProcDiskStats string

	// DiskIO
	DiskIOs          map[string][]*DiskIO
	DiskIOsLimit     int
	DiskReadIOBytes  []int64
	DiskWriteIOBytes []int64

	// NetworkIO
	NetworkIOs       map[string][]*NetworkIO
	NetworkIOsLimit  int
	NetworkRXBytes   []uint64
	NetworkRXPackets []uint64
	NetworkTXBytes   []uint64
	NetworkTXPackets []uint64

	// Process
	LatestProcessLists []*linux.Process

	// Top
	NodeTop *NodeTop

	sync.RWMutex
	// contains filtered or unexported fields
}

Node is monitoring node struct

func NewNode

func NewNode(name string) *Node

NewNode is create new Node struct. with set default values

func (*Node) CheckClientAlive

func (n *Node) CheckClientAlive() bool

func (*Node) Connect

func (n *Node) Connect(r *sshrun.Run) (err error)

func (*Node) CreateNodeTop

func (n *Node) CreateNodeTop() (err error)

func (*Node) CreateTopCPUUsage

func (n *Node) CreateTopCPUUsage() (result *TopCPUUsage)

func (*Node) CreateTopDiskInfomation

func (n *Node) CreateTopDiskInfomation() (result *TopDiskInfomation)

func (*Node) CreateTopMemoryUsage

func (n *Node) CreateTopMemoryUsage() (result *TopMemoryUsage)

func (*Node) CreateTopNetworkInfomation

func (n *Node) CreateTopNetworkInfomation() (result *TopNetworkInfomation)

func (*Node) CreateTopUptime

func (n *Node) CreateTopUptime() (result *TopUptime)

func (*Node) GetCPUCore

func (n *Node) GetCPUCore() (cn int, err error)

GetCPUCore is get cpu core num

func (*Node) GetCPUCoreUsage

func (n *Node) GetCPUCoreUsage() (usages []CPUUsageTop, err error)

func (*Node) GetCPUUsage

func (n *Node) GetCPUUsage() (usage float64, err error)

func (*Node) GetCPUUsageWithBrailleLine

func (n *Node) GetCPUUsageWithBrailleLine() (usage float64, brailleLine string, err error)

func (*Node) GetCPUUsageWithSparkline

func (n *Node) GetCPUUsageWithSparkline() (usage float64, sparkline string, err error)

func (*Node) GetDiskUsage

func (n *Node) GetDiskUsage() (diskUsages []*DiskUsage, err error)

func (*Node) GetIPV6

func (n *Node) GetIPV6() (ipv6 []sshproc.IPv6, err error)

func (*Node) GetIPv4

func (n *Node) GetIPv4() (ipv4 []sshproc.IPv4, err error)

func (*Node) GetKernelVersion

func (n *Node) GetKernelVersion() (version string, err error)

func (*Node) GetLoadAvg

func (n *Node) GetLoadAvg() (loadavg *linux.LoadAvg, err error)

func (*Node) GetMemInfo

func (n *Node) GetMemInfo() (memInfo *linux.MemInfo, err error)

func (*Node) GetMemoryUsage

func (n *Node) GetMemoryUsage() (memUsed, memTotal, swapUsed, swapTotal uint64, err error)

GetMemoryUsage is get memory usage. return size is byte.

func (*Node) GetNetworkUsage

func (n *Node) GetNetworkUsage() (networkUsages []*NetworkUsage, err error)

func (*Node) GetTaskCounts

func (n *Node) GetTaskCounts() (tasks uint64, err error)

func (*Node) GetUptime

func (n *Node) GetUptime() (uptime *linux.Uptime, err error)

func (*Node) MonitoringCPUUsage

func (n *Node) MonitoringCPUUsage()

func (*Node) MonitoringDiskIO

func (n *Node) MonitoringDiskIO()

func (*Node) MonitoringNetworkIO

func (n *Node) MonitoringNetworkIO() (err error)

func (*Node) StartMonitoring

func (n *Node) StartMonitoring()

type NodeTop

type NodeTop struct {
	Grid         *mview.Grid
	CPUUsage     *TopCPUUsage
	MemoryUsage  *TopMemoryUsage
	Uptimes      *TopUptime
	DiskUsage    *TopDiskInfomation
	NetworkUsage *TopNetworkInfomation

	sync.Mutex
}

type TopCPUUsage

type TopCPUUsage struct {
	*mview.Table

	Node *Node
}

func (*TopCPUUsage) Update

func (t *TopCPUUsage) Update(wg *sync.WaitGroup)

type TopDiskInfomation

type TopDiskInfomation struct {
	*mview.Table
	Node *Node
}

func (*TopDiskInfomation) Update

func (t *TopDiskInfomation) Update(wg *sync.WaitGroup)

type TopMemoryUsage

type TopMemoryUsage struct {
	*mview.Table
	Node *Node
}

func (*TopMemoryUsage) Update

func (t *TopMemoryUsage) Update(wg *sync.WaitGroup)

type TopNetworkInfomation

type TopNetworkInfomation struct {
	*mview.Table
	Node *Node
}

func (*TopNetworkInfomation) Update

func (t *TopNetworkInfomation) Update(wg *sync.WaitGroup)

type TopUptime

type TopUptime struct {
	*mview.Table
	Node *Node
}

func (*TopUptime) Update

func (t *TopUptime) Update(wg *sync.WaitGroup)

type UpdateRows

type UpdateRows struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳