common

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

gopsutil is a port of psutil(http://pythonhosted.org/psutil/). This covers these architectures.

  • linux (amd64, arm)
  • freebsd (amd64)
  • windows (amd64)

Index

Constants

View Source
const (
	ERROR_SUCCESS        = 0
	ERROR_FILE_NOT_FOUND = 2
	DRIVE_REMOVABLE      = 2
	DRIVE_FIXED          = 3
	HKEY_LOCAL_MACHINE   = 0x80000002
	RRF_RT_REG_SZ        = 0x00000002
	RRF_RT_REG_DWORD     = 0x00000010
	PDH_FMT_LONG         = 0x00000100
	PDH_FMT_DOUBLE       = 0x00000200
	PDH_FMT_LARGE        = 0x00000400
	PDH_INVALID_DATA     = 0xc0000bc6
	PDH_INVALID_HANDLE   = 0xC0000bbc
	PDH_NO_DATA          = 0x800007d5
)

windows system const

Variables

View Source
var (
	Modkernel32 = syscall.NewLazyDLL("kernel32.dll")
	ModNt       = syscall.NewLazyDLL("ntdll.dll")
	ModPdh      = syscall.NewLazyDLL("pdh.dll")

	ProcGetSystemTimes           = Modkernel32.NewProc("GetSystemTimes")
	ProcNtQuerySystemInformation = ModNt.NewProc("NtQuerySystemInformation")
	PdhOpenQuery                 = ModPdh.NewProc("PdhOpenQuery")
	PdhAddCounter                = ModPdh.NewProc("PdhAddCounterW")
	PdhCollectQueryData          = ModPdh.NewProc("PdhCollectQueryData")
	PdhGetFormattedCounterValue  = ModPdh.NewProc("PdhGetFormattedCounterValue")
	PdhCloseQuery                = ModPdh.NewProc("PdhCloseQuery")
)
View Source
var NotImplementedError = errors.New("not implemented yet")

Functions

func BytePtrToString

func BytePtrToString(p *uint8) string

borrowed from net/interface_windows.go

func ByteToString

func ByteToString(orig []byte) string

func CreateQuery

func CreateQuery() (syscall.Handle, error)

CreateQuery XXX copied from https://github.com/mackerelio/mackerel-agent/

func IntToString

func IntToString(orig []int8) string

func PathExists

func PathExists(filename string) bool

func ReadLines

func ReadLines(filename string) ([]string, error)

ReadLines reads contents from a file and splits them by new lines. A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).

func ReadLinesOffsetN

func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error)

ReadLines reads contents from file and splits them by new line. The offset tells at which line number to start. The count determines the number of lines to read (starting from offset):

n >= 0: at most n lines
n < 0: whole file

func StringsContains

func StringsContains(target []string, src string) bool

StringsContains checks the src in any string of the target string slice

func StringsHas

func StringsHas(target []string, src string) bool

StringsHas checks the target string slice containes src or not

Types

type CounterInfo

type CounterInfo struct {
	PostName    string
	CounterName string
	Counter     syscall.Handle
}

CounterInfo copied from https://github.com/mackerelio/mackerel-agent/

func CreateCounter

func CreateCounter(query syscall.Handle, pname, cname string) (*CounterInfo, error)

CreateCounter XXX

type FILETIME

type FILETIME struct {
	DwLowDateTime  uint32
	DwHighDateTime uint32
}

type FakeInvoke

type FakeInvoke struct {
	CommandExpectedDir string // CommandExpectedDir specifies dir which includes expected outputs.
	Suffix             string // Suffix species expected file name suffix such as "fail"
	Error              error  // If Error specfied, return the error.
}

func (FakeInvoke) Command

func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error)

Command in FakeInvoke returns from expected file if exists.

type Invoke

type Invoke struct{}

func (Invoke) Command

func (i Invoke) Command(name string, arg ...string) ([]byte, error)

type Invoker

type Invoker interface {
	Command(string, ...string) ([]byte, error)
}

type PDH_FMT_COUNTERVALUE_DOUBLE

type PDH_FMT_COUNTERVALUE_DOUBLE struct {
	CStatus     uint32
	DoubleValue float64
}

for double values

type PDH_FMT_COUNTERVALUE_LARGE

type PDH_FMT_COUNTERVALUE_LARGE struct {
	CStatus    uint32
	LargeValue int64
}

for 64 bit integer values

type PDH_FMT_COUNTERVALUE_LONG

type PDH_FMT_COUNTERVALUE_LONG struct {
	CStatus   uint32
	LongValue int32
	// contains filtered or unexported fields
}

for long values

Jump to

Keyboard shortcuts

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