Documentation ¶
Overview ¶
Package ostent is the library part of ostent cmd.
Index ¶
- Constants
- Variables
- func AddAssetPathContextFunc(path string) func(http.Handler) http.Handler
- func AddBackground(j backgroundHandler)
- func ApplyRoutes(r *httprouter.Router, routes map[*Route]Handle, ...)
- func AssetInfoFunc(infofunc func(string) (os.FileInfo, error)) func(string) (TimeInfo, error)
- func AssetReadFunc(readfunc func(string) ([]byte, error)) func(string) ([]byte, error)
- func CollectLoop()
- func Distrib() (string, error)
- func Fetch(keys *params.FetchKeys) error
- func FetchExtract(jdata *gabs.Container, keys []string) (*gabs.Container, interface{})
- func FetchOne(k params.FetchKey, keys []string) error
- func FormatCPU(label string, mc *system.MetricCPU) system.CPUData
- func FormatDF(md *system.MetricDF) system.DFData
- func FormatIF(mi *system.MetricIF) system.IFData
- func FormatIF1000(diff *system.GaugeDiff, info1, info2 *string)
- func FormatIF1024(diff *system.GaugeDiff, info1, info2 *string)
- func GetHN() (string, error)
- func HardwareIF(name string) bool
- func LSBID(platform string) string
- func NewErrorLog() (*log.Logger, func() error)
- func NextSecond() time.Time
- func NextSecondDelta() (time.Time, time.Duration)
- func ProcName(_ int, procName string) string
- func RunBackground()
- func WriteField(buf *bytes.Buffer, val interface{}, posts ...string)
- type Access
- type AccessFormat
- type CPUSlice
- type Collector
- type ContextID
- type DFSlice
- type DFSort
- type ExportingList
- type ExportingListing
- type Handle
- type IFSlice
- type IndexData
- type IndexRegistry
- func (ir *IndexRegistry) CPU(para *params.Params, data IndexData) bool
- func (ir *IndexRegistry) DF(para *params.Params, data IndexData) bool
- func (ir *IndexRegistry) GetCPU(para *params.Params) []system.CPUData
- func (ir *IndexRegistry) GetDF(para *params.Params) []system.DFData
- func (ir *IndexRegistry) GetIF(para *params.Params) []system.IFData
- func (ir *IndexRegistry) GetOrRegisterPrivateCPU(coreno int) *system.MetricCPU
- func (ir *IndexRegistry) GetOrRegisterPrivateDF(fs sigar.FileSystem) *system.MetricDF
- func (ir *IndexRegistry) GetOrRegisterPrivateIF(name string) *system.MetricIF
- func (ir *IndexRegistry) IF(para *params.Params, data IndexData) bool
- func (ir *IndexRegistry) LA(para *params.Params, data IndexData) bool
- func (ir *IndexRegistry) ListPrivateCPU() (cs CPUSlice)
- func (ir *IndexRegistry) ListPrivateDF() (dfs DFSlice)
- func (ir *IndexRegistry) ListPrivateIF() (is IFSlice)
- func (ir *IndexRegistry) MEM(para *params.Params, data IndexData) bool
- func (ir *IndexRegistry) UpdateCPU(all sigar.Cpu, list []sigar.Cpu)
- func (ir *IndexRegistry) UpdateDF(fs sigar.FileSystem, usage sigar.FileSystemUsage)
- func (ir *IndexRegistry) UpdateIF(ifaddr system.IfAddress)
- func (ir *IndexRegistry) UpdateLA(la sigar.LoadAverage)
- func (ir *IndexRegistry) UpdateRAM(got sigar.Mem, extra1, extra2 uint64)
- func (ir *IndexRegistry) UpdateSwap(got sigar.Swap)
- type MSS
- type Machine
- func (m Machine) CPU(reg Registry, wg *sync.WaitGroup)
- func (m Machine) DF(reg Registry, wg *sync.WaitGroup)
- func (m Machine) GetHN() (string, error)
- func (m Machine) HN(sreg S2SRegistry, wg *sync.WaitGroup)
- func (m Machine) IF(reg Registry, wg *sync.WaitGroup)
- func (m Machine) LA(reg Registry, wg *sync.WaitGroup)
- func (m Machine) PS(CH chan<- PSSlice)
- func (m Machine) RAM(reg Registry, wg *sync.WaitGroup)
- func (m Machine) Swap(reg Registry, wg *sync.WaitGroup)
- func (m Machine) UP(sreg S2SRegistry, wg *sync.WaitGroup)
- type NetIO
- func (io NetIO) BytesIn() uint
- func (io NetIO) BytesOut() uint
- func (io NetIO) DropsIn() uint
- func (io NetIO) DropsOut() uint
- func (io NetIO) ErrorsIn() uint
- func (io NetIO) ErrorsOut() uint
- func (io NetIO) GetIP() string
- func (io NetIO) GetName() string
- func (io NetIO) PacketsIn() uint
- func (io NetIO) PacketsOut() uint
- type PS
- type PSSlice
- type PSSort
- type Registry
- type Responding
- type Route
- type RouteInfo
- type S2SRegistry
- type SSE
- type ServeAssets
- type ServeIndex
- type ServePanic
- type ServeSSE
- type ServeWS
- type TimeInfo
- type UpgradeInfo
Constants ¶
const PanicStatusCode = http.StatusInternalServerError
const VERSION = "0.6.1"
VERSION of the latest known release. Unused in non-bin mode. Compared with in github.com/ostrost/ostent/main.go MUST BE semver compatible: no two digits ("X.Y") allowed.
Variables ¶
var ( RXlo = regexp.MustCompile("^lo\\d*$") RXvbr = regexp.MustCompile("^virbr\\d+$") RXvbrnic = regexp.MustCompile("^virbr\\d+-nic$") RXbridge = regexp.MustCompile("^bridge\\d+$") RXvboxnet = regexp.MustCompile("^vboxnet\\d+$") RXfw = regexp.MustCompile("^fw\\d+$") RXgif = regexp.MustCompile("^gif\\d+$") RXstf = regexp.MustCompile("^stf\\d+$") RXwdl = regexp.MustCompile("^awdl\\d+$") RXairdrop = regexp.MustCompile("^p2p\\d+$") )
These are regexps to match network interfaces.
var ( Reg1s *IndexRegistry RegMSS = &MSS{KV: map[string]string{}} OstentUpgrade = new(UpgradeInfo) )
var ( PanicStatusText = statusLine(PanicStatusCode) PanicTemplate = template.Must(template.New("recovery.html").Parse(` <html> <head><title>{{.Title}}</title></head> <body bgcolor="white"> <center><h1>{{.Description}}</h1></center> <hr><pre>{{.Stack}}</pre> </body> </html> `)) )
var ( // Connections is of unexported conns type to hold active ws connections. Connections = conns{/* contains filtered or unexported fields */} )
var DISTRIB string
DISTRIB is distribution string and it's version. Set once at init.
var ZeroTime, _ = time.Parse("15:04:05", "00:00:00")
ZeroTime is zero time for formatting duration from it.
Functions ¶
func AddAssetPathContextFunc ¶
func AddBackground ¶
func AddBackground(j backgroundHandler)
func ApplyRoutes ¶
func ApplyRoutes(r *httprouter.Router, routes map[*Route]Handle, conv func(http.Handler) httprouter.Handle)
func AssetInfoFunc ¶
AssetInfoFunc wraps bindata's AssetInfo func. Returns typecasted infofunc.
func AssetReadFunc ¶
AssetReadFunc wraps bindata's Asset func. Returns readfunc itself.
func FetchExtract ¶ added in v0.6.1
func FormatIF1000 ¶
func FormatIF1024 ¶
func HardwareIF ¶
HardwareIF returns false for known virtual/software network interface name.
func NewErrorLog ¶
NewErrorLog creates a logger and returns a func to defer.
func NextSecondDelta ¶
NextSecondDelta returns precisely next second in Time and Duration.
func RunBackground ¶
func RunBackground()
func WriteField ¶
WriteField is a helper to write val and optional posts[0] or a whitespace. The name relate to use with logrus.Entry.Data fields, no other Field relation.
Types ¶
type Access ¶
type Access struct { TaggedBin bool Log *logrus.Logger Hosts struct { Mutex sync.Mutex Hosts map[string]struct{} } }
func NewServery ¶
type Collector ¶
type Collector interface { GetHN() (string, error) HN(S2SRegistry, *sync.WaitGroup) UP(S2SRegistry, *sync.WaitGroup) LA(Registry, *sync.WaitGroup) RAM(Registry, *sync.WaitGroup) Swap(Registry, *sync.WaitGroup) IF(Registry, *sync.WaitGroup) PS(chan<- PSSlice) DF(Registry, *sync.WaitGroup) CPU(Registry, *sync.WaitGroup) }
Collector is collection interface.
type ExportingList ¶ added in v0.6.1
type ExportingList []struct{ Name, Endpoint string }
ExportingList is a list to be sorted by .Name: - Entries come from CLI flags which may be specified in any order - That order not preserved since parsing anyway
var ( // Exporting has "exporting to" list (after init) Exporting ExportingList )
func (ExportingList) Len ¶ added in v0.6.1
func (el ExportingList) Len() int
func (ExportingList) Less ¶ added in v0.6.1
func (el ExportingList) Less(i, j int) bool
func (ExportingList) Swap ¶ added in v0.6.1
func (el ExportingList) Swap(i, j int)
type ExportingListing ¶ added in v0.6.1
type ExportingListing struct { RWMutex sync.RWMutex ExportingList }
ExportingListing keeps "exporting to" list.
func (*ExportingListing) AddExporter ¶ added in v0.6.1
func (el *ExportingListing) AddExporter(name string, stringer fmt.Stringer)
type IndexData ¶
type IndexData map[string]interface{}
IndexData is a data map for templates and marshalling. Keys (even abbrevs eg CPU) intentionally start with lowercase.
type IndexRegistry ¶
type IndexRegistry struct { Registry metrics.Registry PrivateCPUAll *system.MetricCPU /// metrics.Registry PrivateCPURegistry metrics.Registry // set of MetricCPUs is handled as a metric in this registry PrivateIFRegistry metrics.Registry // set of system.MetricIFs is handled as a metric in this registry PrivateDFRegistry metrics.Registry // set of system.MetricDFs is handled as a metric in this registry PrivateMutex sync.Mutex RAM *system.MetricRAM Swap system.MetricSwap Load *system.MetricLoad Mutex sync.Mutex }
func (*IndexRegistry) GetCPU ¶
func (ir *IndexRegistry) GetCPU(para *params.Params) []system.CPUData
func (*IndexRegistry) GetOrRegisterPrivateCPU ¶
func (ir *IndexRegistry) GetOrRegisterPrivateCPU(coreno int) *system.MetricCPU
GetOrRegisterPrivateCPU produces a registered in PrivateCPURegistry MetricCPU.
func (*IndexRegistry) GetOrRegisterPrivateDF ¶
func (ir *IndexRegistry) GetOrRegisterPrivateDF(fs sigar.FileSystem) *system.MetricDF
func (*IndexRegistry) GetOrRegisterPrivateIF ¶
func (ir *IndexRegistry) GetOrRegisterPrivateIF(name string) *system.MetricIF
GetOrRegisterPrivateIF produces a registered in PrivateIFRegistry system.MetricIF.
func (*IndexRegistry) ListPrivateCPU ¶
func (ir *IndexRegistry) ListPrivateCPU() (cs CPUSlice)
ListPrivateCPU returns list of system.MetricCPU's by traversing the PrivateCPURegistry.
func (*IndexRegistry) ListPrivateDF ¶
func (ir *IndexRegistry) ListPrivateDF() (dfs DFSlice)
ListPrivateDF returns list of system.MetricDF's by traversing the PrivateDFRegistry.
func (*IndexRegistry) ListPrivateIF ¶
func (ir *IndexRegistry) ListPrivateIF() (is IFSlice)
ListPrivateIF returns list of MetricIF's by traversing the PrivateIFRegistry.
func (*IndexRegistry) UpdateCPU ¶
func (ir *IndexRegistry) UpdateCPU(all sigar.Cpu, list []sigar.Cpu)
func (*IndexRegistry) UpdateDF ¶
func (ir *IndexRegistry) UpdateDF(fs sigar.FileSystem, usage sigar.FileSystemUsage)
func (*IndexRegistry) UpdateIF ¶
func (ir *IndexRegistry) UpdateIF(ifaddr system.IfAddress)
func (*IndexRegistry) UpdateLA ¶
func (ir *IndexRegistry) UpdateLA(la sigar.LoadAverage)
func (*IndexRegistry) UpdateRAM ¶
func (ir *IndexRegistry) UpdateRAM(got sigar.Mem, extra1, extra2 uint64)
func (*IndexRegistry) UpdateSwap ¶
func (ir *IndexRegistry) UpdateSwap(got sigar.Swap)
UpdateSwap reads got and updates the ir.Swap. TODO Bad description.
type Machine ¶
type Machine struct{}
Machine implements Collector by collecting the maching metrics.
type NetIO ¶ added in v0.6.1
type NetIO struct { psnet.IOCountersStat IP string }
func (NetIO) PacketsOut ¶ added in v0.6.1
type Registry ¶
type Registry interface { UpdateIF(system.IfAddress) UpdateCPU(sigar.Cpu, []sigar.Cpu) UpdateLA(sigar.LoadAverage) UpdateSwap(sigar.Swap) UpdateRAM(sigar.Mem, uint64, uint64) UpdateDF(sigar.FileSystem, sigar.FileSystemUsage) }
Registry has updates with sigar values.
type Responding ¶
func (*Responding) Flush ¶
func (r *Responding) Flush()
func (*Responding) Hijack ¶
func (r *Responding) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (Responding) StatusGood ¶
func (r Responding) StatusGood() bool
func (*Responding) WriteHeader ¶
func (r *Responding) WriteHeader(status int)
type S2SRegistry ¶
S2SRegistry is for string kv storage.
type SSE ¶
type SSE struct { Writer http.ResponseWriter // points to the writer Params *params.Params SentHeaders bool Errord bool }
type ServeAssets ¶
type ServeAssets struct { Log *log.Logger AssetFunc func(string) ([]byte, error) AssetInfoFunc func(string) (os.FileInfo, error) AssetAltModTimeFunc func() time.Time // may be nil }
func (ServeAssets) Serve ¶
func (sa ServeAssets) Serve(w http.ResponseWriter, r *http.Request)
Serve does http.ServeContent with asset content and info.
type ServeIndex ¶
type ServeIndex struct { ServeWS TaggedBin bool IndexTemplate *templateutil.LazyTemplate }
func NewServeIndex ¶
func NewServeIndex(sw ServeWS, taggedbin bool, template *templateutil.LazyTemplate) ServeIndex
func (ServeIndex) Index ¶
func (si ServeIndex) Index(w http.ResponseWriter, r *http.Request)
Index renders index page.
type ServePanic ¶
type ServePanic struct{ TaggedBin bool }
func NewServePanic ¶
func NewServePanic(taggedbin bool) *ServePanic
func (*ServePanic) PanicHandler ¶
func (sp *ServePanic) PanicHandler(w http.ResponseWriter, r *http.Request)
type ServeSSE ¶
type ServeSSE struct { Access *Access flags.DelayBounds }
func NewServeSSE ¶
func NewServeSSE(access *Access, dbounds flags.DelayBounds) ServeSSE
type UpgradeInfo ¶ added in v0.6.1
func (*UpgradeInfo) Get ¶ added in v0.6.1
func (ui *UpgradeInfo) Get() string
func (*UpgradeInfo) Set ¶ added in v0.6.1
func (ui *UpgradeInfo) Set(lv string)