common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2015 License: MIT, BSD-3-Clause Imports: 6 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 GetWmic

func GetWmic(target string, query ...string) ([][]string, error)

exec wmic and return lines splited by newline

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 file and splits them by new line. 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 StringContains

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

Check 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 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