rwho

package
v0.0.0-...-1254524 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadWhod

func ReadWhod(path string) (*WhodHeader, []*WhoEntry, error)

Types

type WhoEntry

type WhoEntry struct {
	Tty       [8]byte // tty name
	User      [8]byte // user id
	LoginTime int32   // time on
	IdleTime  int32   // tty idle time
}

WhoEntry represents tty information and idle time.

func ParseWhoEntry

func ParseWhoEntry(r io.Reader) (*WhoEntry, error)

func (*WhoEntry) GetIdleTime

func (e *WhoEntry) GetIdleTime() time.Duration

func (*WhoEntry) GetLoginTime

func (e *WhoEntry) GetLoginTime() time.Time

func (*WhoEntry) GetTty

func (e *WhoEntry) GetTty() string

func (*WhoEntry) GetUser

func (e *WhoEntry) GetUser() string

type Whod

type Whod struct {
	Header     *WhodHeader
	WhoEntries []*WhoEntry
}

func ParseWhod

func ParseWhod(r io.Reader) (*Whod, error)

func ReadWhodFile

func ReadWhodFile(path string) (*Whod, error)

func ScanHosts

func ScanHosts() ([]*Whod, error)

type WhodHeader

type WhodHeader struct {
	Version     byte     // protocol version #
	Type        byte     // packet type
	Padding     [2]byte  // padding
	Sendtime    int32    // time stamp by sender
	Recvtime    int32    // time stamp applied by receiver
	Hostname    [32]byte // host's name
	LoadAverage [3]int32 // load average as in uptime
	Boottime    int32    // time system booted
}

whod represents rwho protocol packet.

func ParseWhodHeader

func ParseWhodHeader(r io.Reader) (*WhodHeader, error)

func (*WhodHeader) GetBootTime

func (h *WhodHeader) GetBootTime() time.Time

func (*WhodHeader) GetHostname

func (h *WhodHeader) GetHostname() string

func (*WhodHeader) GetLoadAverage15min

func (h *WhodHeader) GetLoadAverage15min() float64

func (*WhodHeader) GetLoadAverage1min

func (h *WhodHeader) GetLoadAverage1min() float64

func (*WhodHeader) GetLoadAverage5min

func (h *WhodHeader) GetLoadAverage5min() float64

func (*WhodHeader) GetRecvTime

func (h *WhodHeader) GetRecvTime() time.Time

func (*WhodHeader) GetSendTime

func (h *WhodHeader) GetSendTime() time.Time

func (*WhodHeader) GetUptime

func (h *WhodHeader) GetUptime() time.Duration

func (*WhodHeader) IsDown

func (h *WhodHeader) IsDown() bool

Jump to

Keyboard shortcuts

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