dmesg

package
v0.0.0-...-612c548 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stream

func Stream(out chan<- *Message, stop <-chan bool, sampleTime time.Duration) error

Stream creates a goroutine that, every sampleTime ticks, will send new dmesg messages to out. It also listens on stop, in case you need to abort the goroutine. If there is an error setting up the initial state, it is returned, but otherwise errors are logged and otherwise ignored.

Types

type Message

type Message struct {
	Level     int64
	Timestamp time.Time
	Message   string
}

Message encapsulates kernel ring buffer messages. The timestamp is absolute, not relative to boot time.

type State

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

State is an opaque datatype representing whatever state is needed for the dmesg parser.

func New

func New() (*State, error)

New creates a new State.

func (*State) Current

func (s *State) Current() ([]byte, error)

Current retrieves the current contents of the kernel message ring buffer.

func (*State) Messages

func (s *State) Messages() ([]*Message, error)

Messages retrieves all kernel ring buffer messages and returns them, or a reason why it could not.

func (*State) ParseMessages

func (s *State) ParseMessages(buffer []byte) ([]*Message, error)

ParseMessages reads dmesg type messages out of buffer. To do so it must read the system boot time out of /proc/stat, because dmesg timestamps are relative to when the system booted.

Jump to

Keyboard shortcuts

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