utils

package
v0.0.0-...-8727f20 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CPUProgressBar

func CPUProgressBar(percentage float64) string

CPUProgressBar returns a simple progress bar used with displaying cpu percentages

func ChangeProcessToTableFormat

func ChangeProcessToTableFormat(p Process) []string

ChangeProcessToTableFormat returns all the process fields in an array of string

func ConvertBits

func ConvertBits(bits uint64) float64

ConvertBits converts an amount of bits to gigabytes

func ConvertTime

func ConvertTime(uptime uint64) string

ConvertTime is used to convert uptime seconds to minutes and hours

func GetTerminalHeight

func GetTerminalHeight() int

GetTerminalHeight returns the height of the terminal

func GetTerminalWidth

func GetTerminalWidth() int

GetTerminalWidth gets the terminals width so that we can adjust the ui elements accordingly

Types

type BasicInfo

type BasicInfo struct {
	CorePercentages   []float64
	MemoryUsed        uint64
	TotalMemory       uint64
	MemoryUsedPercent float64
	Hostname          string
	Uptime            uint64
	KernelVersion     string
	Procs             uint64
	Processes         [][]string
	OS                string
	Platform          string
	Swap              SwapData
	Memory            MemoryData
}

BasicInfo has all the the values in the upper box

func LoadData

func LoadData() (BasicInfo, error)

LoadData loads all the system information and returns it in a struct

type MemoryData

type MemoryData struct {
	Total       float64
	Used        float64
	UsedPercent float64
}

MemoryData model holds all memory related information

func LoadMemoryData

func LoadMemoryData() (MemoryData, error)

LoadMemoryData loads data related to virtual memory

type Process

type Process struct {
	Pid           int32
	Name          string
	CPUPercentage float64
	Running       bool
	User          string
}

Process includes all the types for the table view

func LoadAllProcesses

func LoadAllProcesses() []Process

LoadAllProcesses returns a filtered list of processes which are

func LoadSingleProcessData

func LoadSingleProcessData(process *process.Process) (Process, error)

LoadSingleProcessData loads all the data into the predefined process struct

type RenderTab

type RenderTab func()

type SwapData

type SwapData struct {
	Total       float64
	UsedPercent float64
	Used        float64
}

SwapData model holds all swap related information

func LoadSwapData

func LoadSwapData() (SwapData, error)

LoadSwapData returns all swap related data

type View

type View struct {
	List            *widgets.List
	SystemInfoList  *widgets.List
	ProcessesWindow *widgets.Table
	TabPanel        *widgets.TabPane
	Data            BasicInfo
	Grid            *ui.Grid
	RenderTab       RenderTab
	SettingsPage    *ui.Grid
	SettingsList    *widgets.List
}

View data structure

func NewView

func NewView() *View

NewView returns a pointer to a view struct

func (*View) Init

func (view *View) Init()

Init initializes the ui

func (*View) Render

func (view *View) Render(data BasicInfo)

Render is used to update screen with new data.

func (*View) Resize

func (view *View) Resize()

Resize is used when an terminal resize event occurs and it updates list dimensions accordingly

Jump to

Keyboard shortcuts

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