os

package
v0.0.0-...-f7edce5 Latest Latest
Warning

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

Go to latest
Published: May 21, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MemBelow = iota
	MemExactly
	MemAbove
)
View Source
const (
	LevelNotEnough = iota
	LevelBelowFive
	LevelExactlyFive
	LevelAboveFive
	LevelMalformed
)
View Source
const MemAvailable = "MemAvailable_bytes"

Variables

View Source
var MemInfoModule = fx.Provide(NewMemInfo)
View Source
var MinerModule = fx.Provide(NewMiner)
View Source
var NetInfoModule = fx.Provide(NewNetInfo)
View Source
var NetworkingModule = fx.Provide(NewNetworking)
View Source
var NtpdateModule = fx.Provide(func() Ntpdate {
	return &NtpdateData{
		run: func(cmd string, arg ...string) error {
			return exec.Command(cmd, arg...).Run()
		},
	}
})
View Source
var RebootModule = fx.Provide(func() Reboot {
	return &RebootData{
		run: func(cmd string, arg string) error {
			return exec.Command(cmd, arg).Run()
		},
	}
})
View Source
var StatRetrieverModule = fx.Provide(NewStatRetriever)

Functions

func NewNetInterfaces

func NewNetInterfaces() []net.Interface

For testing only

Types

type LinuxMemInfo

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

func (*LinuxMemInfo) Get

func (m *LinuxMemInfo) Get() (MemInfoData, error)

type LinuxStatRetriever

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

func (*LinuxStatRetriever) GetLoadData

func (lsr *LinuxStatRetriever) GetLoadData() (*LoadData, error)

type LoadData

type LoadData struct {
	OneMinAvg     float64
	FiveMinAvg    float64
	FifteenMinAvg float64
}

func ParseLoadData

func ParseLoadData(data string) (*LoadData, error)

Parse /proc loadavg and return 1m, 5m and 15m.

type MemInfo

type MemInfo interface {
	Get() (data MemInfoData, err error)
}

func NewMemInfo

func NewMemInfo() MemInfo

type MemInfoData

type MemInfoData = map[string]float64

type Miner

type Miner interface {
	Start() error
	Stop() error
}

func NewMiner

func NewMiner() Miner

type MinerData

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

func (MinerData) Start

func (s MinerData) Start() error

func (MinerData) Stop

func (s MinerData) Stop() error

type MockMemInfo

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

func NewMockMemInfo

func NewMockMemInfo(dataSet int) MockMemInfo

func (*MockMemInfo) Get

func (sr *MockMemInfo) Get() (MemInfoData, error)

type MockMiner

type MockMiner struct {
	CalledStartMiner bool
	CalledStopMiner  bool
}

func NewMockMiner

func NewMockMiner() MockMiner

func (*MockMiner) Start

func (ms *MockMiner) Start() error

func (*MockMiner) Stop

func (ms *MockMiner) Stop() error

type MockNetInfo

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

func NewMockNetInfo

func NewMockNetInfo() MockNetInfo

func (*MockNetInfo) GetMacAddress

func (mni *MockNetInfo) GetMacAddress() *string

func (*MockNetInfo) GetNetInterfaces

func (mni *MockNetInfo) GetNetInterfaces() ([]net.Interface, error)

type MockNtpdate

type MockNtpdate struct {
	Counter       int
	CalledNtpdate bool
}

func NewMockNtpdate

func NewMockNtpdate() MockNtpdate

func (*MockNtpdate) Ntpdate

func (ms *MockNtpdate) Ntpdate(server string) error

type MockReboot

type MockReboot struct {
	Counter      int
	CalledReboot bool
}

func NewMockReboot

func NewMockReboot() MockReboot

func (*MockReboot) Reboot

func (ms *MockReboot) Reboot() error

type MockStatRetriever

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

func NewMockStatRetriever

func NewMockStatRetriever(dataSet int) MockStatRetriever

func (*MockStatRetriever) GetLoadData

func (sr *MockStatRetriever) GetLoadData() (*LoadData, error)

type NetInfo

type NetInfo interface {
	GetNetInterfaces() ([]net.Interface, error)
	GetMacAddress() *string
}

func NewNetInfo

func NewNetInfo() NetInfo

type NetInfoData

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

func (*NetInfoData) GetMacAddress

func (ni *NetInfoData) GetMacAddress() *string

func (*NetInfoData) GetNetInterfaces

func (ni *NetInfoData) GetNetInterfaces() ([]net.Interface, error)

type Networking

type Networking interface {
	SetDHCP() error
	SetStatic(address string, netmask string, gateway string) error
	FormatStatic(address string, netmask string, gateway string) string
}

func NewNetworking

func NewNetworking() Networking

type NetworkingData

type NetworkingData struct {
	File string
}

func (*NetworkingData) FormatStatic

func (n *NetworkingData) FormatStatic(address string, netmask string, gateway string) string

func (*NetworkingData) SetDHCP

func (n *NetworkingData) SetDHCP() error

func (*NetworkingData) SetStatic

func (n *NetworkingData) SetStatic(address string, netmask string, gateway string) error

type Ntpdate

type Ntpdate interface {
	Ntpdate(server string) error
}

type NtpdateData

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

func (*NtpdateData) Ntpdate

func (r *NtpdateData) Ntpdate(server string) error

type Reboot

type Reboot interface {
	Reboot() error
}

type RebootData

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

func (*RebootData) Reboot

func (r *RebootData) Reboot() error

type StatRetriever

type StatRetriever interface {
	GetLoadData() (data *LoadData, err error)
}

func NewStatRetriever

func NewStatRetriever() StatRetriever

type UptimeResult

type UptimeResult struct {
	time.Duration
	Error error
}

type UptimeResultFunc

type UptimeResultFunc func() UptimeResult

func NewUptimeResultFunc

func NewUptimeResultFunc() UptimeResultFunc

Jump to

Keyboard shortcuts

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