baper

package module
v0.0.0-...-f11b29d Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2019 License: MIT Imports: 9 Imported by: 0

README

Baper

Go library which helps you read CPU Stat and convert it to JSON. You can also use Baper as Unix Daemon

Getting started

Running CLI Mode

$ make build

Show help and options

$ baper -h

Running with specific interval

$ baper -i 2

Output

process running on PID =  73863
{"disk":{"kbPerTime":40.96,"tps":30,"mbPerSecond":1.2},"cpu":{"user":4,"system":2,"idle":94},"loadAverage":{"oneMinute":2.01,"fiveMinute":1.58,"fifteenMinute":1.56}}{"disk":{"kbPerTime":6.81,"tps":45,"mbPerSecond":0.3},"cpu":{"user":3,"system":1,"idle":96},"loadAverage":{"oneMinute":2.01,"fiveMinute":1.58,"fifteenMinute":1.56}}{"disk":{"kbPerTime":128,"tps":1,"mbPerSecond":0.12},"cpu":{"user":3,"system":1,"idle":96},"loadAverage":{"oneMinute":1.93,"fiveMinute":1.57,"fifteenMinute":1.56}}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	User   float64 `json:"user"`
	System float64 `json:"system"`
	Idle   float64 `json:"idle"`
}

CPU struct

type CPUStat

type CPUStat struct {
	Disk        Disk        `json:"disk"`
	CPU         CPU         `json:"cpu"`
	LoadAverage LoadAverage `json:"loadAverage"`
	TimeStamp   time.Time   `json:"timeStamp"`
}

CPUStat struct

type Collector

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

Collector struct

func New

func New(sender Sender, interval int) *Collector

New function, Collector's constructor

func (*Collector) Collect

func (collector *Collector) Collect() error

Collect function will collect information from iostat

func (*Collector) Kill

func (collector *Collector) Kill() error

Kill function will kill cmd process

type Disk

type Disk struct {
	KBPerTime   float64 `json:"kbPerTime"`
	TPS         float64 `json:"tps"`
	MBPerSecond float64 `json:"mbPerSecond"`
}

Disk struct

type IOWriterSender

type IOWriterSender struct {
	Writer io.Writer
}

IOWriterSender struct you can create your own implementation

func (IOWriterSender) Send

func (sender IOWriterSender) Send(line []byte) error

type LoadAverage

type LoadAverage struct {
	OneMinute     float64 `json:"oneMinute"`
	FiveMinute    float64 `json:"fiveMinute"`
	FifteenMinute float64 `json:"fifteenMinute"`
}

LoadAverage struct

type Sender

type Sender interface {
	Send([]byte) error
}

Sender interface

Directories

Path Synopsis
cmd
baper command

Jump to

Keyboard shortcuts

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