mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Merge pull request #2277 from hashicorp/f-durable-uuid
Reproducible Node ID
This commit is contained in:
59
vendor/github.com/StackExchange/wmi/wmi.go
generated
vendored
59
vendor/github.com/StackExchange/wmi/wmi.go
generated
vendored
@@ -45,9 +45,15 @@ var l = log.New(os.Stdout, "", log.LstdFlags)
|
||||
|
||||
var (
|
||||
ErrInvalidEntityType = errors.New("wmi: invalid entity type")
|
||||
lock sync.Mutex
|
||||
// ErrNilCreateObject is the error returned if CreateObject returns nil even
|
||||
// if the error was nil.
|
||||
ErrNilCreateObject = errors.New("wmi: create object returned nil")
|
||||
lock sync.Mutex
|
||||
)
|
||||
|
||||
// S_FALSE is returned by CoInitializeEx if it was already called on this thread.
|
||||
const S_FALSE = 0x00000001
|
||||
|
||||
// QueryNamespace invokes Query with the given namespace on the local machine.
|
||||
func QueryNamespace(query string, dst interface{}, namespace string) error {
|
||||
return Query(query, dst, nil, namespace)
|
||||
@@ -126,21 +132,18 @@ func (c *Client) Query(query string, dst interface{}, connectServerArgs ...inter
|
||||
|
||||
err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
|
||||
if err != nil {
|
||||
oleerr := err.(*ole.OleError)
|
||||
// S_FALSE = 0x00000001 // CoInitializeEx was already called on this thread
|
||||
if oleerr.Code() != ole.S_OK && oleerr.Code() != 0x00000001 {
|
||||
oleCode := err.(*ole.OleError).Code()
|
||||
if oleCode != ole.S_OK && oleCode != S_FALSE {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Only invoke CoUninitialize if the thread was not initizlied before.
|
||||
// This will allow other go packages based on go-ole play along
|
||||
// with this library.
|
||||
defer ole.CoUninitialize()
|
||||
}
|
||||
defer ole.CoUninitialize()
|
||||
|
||||
unknown, err := oleutil.CreateObject("WbemScripting.SWbemLocator")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if unknown == nil {
|
||||
return ErrNilCreateObject
|
||||
}
|
||||
defer unknown.Release()
|
||||
|
||||
@@ -171,19 +174,34 @@ func (c *Client) Query(query string, dst interface{}, connectServerArgs ...inter
|
||||
return err
|
||||
}
|
||||
|
||||
enumProperty, err := result.GetProperty("_NewEnum")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer enumProperty.Clear()
|
||||
|
||||
enum, err := enumProperty.ToIUnknown().IEnumVARIANT(ole.IID_IEnumVariant)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if enum == nil {
|
||||
return fmt.Errorf("can't get IEnumVARIANT, enum is nil")
|
||||
}
|
||||
defer enum.Release()
|
||||
|
||||
// Initialize a slice with Count capacity
|
||||
dv.Set(reflect.MakeSlice(dv.Type(), 0, int(count)))
|
||||
|
||||
var errFieldMismatch error
|
||||
for i := int64(0); i < count; i++ {
|
||||
for itemRaw, length, err := enum.Next(1); length > 0; itemRaw, length, err = enum.Next(1) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := func() error {
|
||||
// item is a SWbemObject, but really a Win32_Process
|
||||
itemRaw, err := oleutil.CallMethod(result, "ItemIndex", i)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
item := itemRaw.ToIDispatch()
|
||||
defer itemRaw.Clear()
|
||||
defer item.Release()
|
||||
|
||||
ev := reflect.New(elemType)
|
||||
if err = c.loadEntity(ev.Interface(), item); err != nil {
|
||||
@@ -332,6 +350,17 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat
|
||||
Reason: "not a bool",
|
||||
}
|
||||
}
|
||||
case float32:
|
||||
switch f.Kind() {
|
||||
case reflect.Float32:
|
||||
f.SetFloat(float64(val))
|
||||
default:
|
||||
return &ErrFieldMismatch{
|
||||
StructType: of.Type(),
|
||||
FieldName: n,
|
||||
Reason: "not a Float32",
|
||||
}
|
||||
}
|
||||
default:
|
||||
typeof := reflect.TypeOf(val)
|
||||
if typeof == nil && (isPtr || c.NonePtrZero) {
|
||||
|
||||
9
vendor/github.com/go-ole/go-ole/.travis.yml
generated
vendored
9
vendor/github.com/go-ole/go-ole/.travis.yml
generated
vendored
@@ -1,9 +0,0 @@
|
||||
language: go
|
||||
sudo: false
|
||||
|
||||
go:
|
||||
- 1.1
|
||||
- 1.2
|
||||
- 1.3
|
||||
- 1.4
|
||||
- tip
|
||||
49
vendor/github.com/go-ole/go-ole/ChangeLog.md
generated
vendored
49
vendor/github.com/go-ole/go-ole/ChangeLog.md
generated
vendored
@@ -1,49 +0,0 @@
|
||||
# Version 1.x.x
|
||||
|
||||
* **Add more test cases and reference new test COM server project.** (Placeholder for future additions)
|
||||
|
||||
# Version 1.2.0-alphaX
|
||||
|
||||
**Minimum supported version is now Go 1.4. Go 1.1 support is deprecated, but should still build.**
|
||||
|
||||
* Added CI configuration for Travis-CI and AppVeyor.
|
||||
* Added test InterfaceID and ClassID for the COM Test Server project.
|
||||
* Added more inline documentation (#83).
|
||||
* Added IEnumVARIANT implementation (#88).
|
||||
* Added IEnumVARIANT test cases (#99, #100, #101).
|
||||
* Added support for retrieving `time.Time` from VARIANT (#92).
|
||||
* Added test case for IUnknown (#64).
|
||||
* Added test case for IDispatch (#64).
|
||||
* Added test cases for scalar variants (#64, #76).
|
||||
|
||||
# Version 1.1.1
|
||||
|
||||
* Fixes for Linux build.
|
||||
* Fixes for Windows build.
|
||||
|
||||
# Version 1.1.0
|
||||
|
||||
The change to provide building on all platforms is a new feature. The increase in minor version reflects that and allows those who wish to stay on 1.0.x to continue to do so. Support for 1.0.x will be limited to bug fixes.
|
||||
|
||||
* Move GUID out of variables.go into its own file to make new documentation available.
|
||||
* Move OleError out of ole.go into its own file to make new documentation available.
|
||||
* Add documentation to utility functions.
|
||||
* Add documentation to variant receiver functions.
|
||||
* Add documentation to ole structures.
|
||||
* Make variant available to other systems outside of Windows.
|
||||
* Make OLE structures available to other systems outside of Windows.
|
||||
|
||||
## New Features
|
||||
|
||||
* Library should now be built on all platforms supported by Go. Library will NOOP on any platform that is not Windows.
|
||||
* More functions are now documented and available on godoc.org.
|
||||
|
||||
# Version 1.0.1
|
||||
|
||||
1. Fix package references from repository location change.
|
||||
|
||||
# Version 1.0.0
|
||||
|
||||
This version is stable enough for use. The COM API is still incomplete, but provides enough functionality for accessing COM servers using IDispatch interface.
|
||||
|
||||
There is no changelog for this version. Check commits for history.
|
||||
46
vendor/github.com/go-ole/go-ole/README.md
generated
vendored
46
vendor/github.com/go-ole/go-ole/README.md
generated
vendored
@@ -1,46 +0,0 @@
|
||||
#Go OLE
|
||||
|
||||
[](https://ci.appveyor.com/project/jacobsantos/go-ole-jgs28)
|
||||
[](https://travis-ci.org/go-ole/go-ole)
|
||||
[](https://godoc.org/github.com/go-ole/go-ole)
|
||||
|
||||
Go bindings for Windows COM using shared libraries instead of cgo.
|
||||
|
||||
By Yasuhiro Matsumoto.
|
||||
|
||||
## Install
|
||||
|
||||
To experiment with go-ole, you can just compile and run the example program:
|
||||
|
||||
```
|
||||
go get github.com/go-ole/go-ole
|
||||
cd /path/to/go-ole/
|
||||
go test
|
||||
|
||||
cd /path/to/go-ole/example/excel
|
||||
go run excel.go
|
||||
```
|
||||
|
||||
## Continuous Integration
|
||||
|
||||
Continuous integration configuration has been added for both Travis-CI and AppVeyor. You will have to add these to your own account for your fork in order for it to run.
|
||||
|
||||
**Travis-CI**
|
||||
|
||||
Travis-CI was added to check builds on Linux to ensure that `go get` works when cross building. Currently, Travis-CI is not used to test cross-building, but this may be changed in the future. It is also not currently possible to test the library on Linux, since COM API is specific to Windows and it is not currently possible to run a COM server on Linux or even connect to a remote COM server.
|
||||
|
||||
**AppVeyor**
|
||||
|
||||
AppVeyor is used to build on Windows using the (in-development) test COM server. It is currently only used to test the build and ensure that the code works on Windows. It will be used to register a COM server and then run the test cases based on the test COM server.
|
||||
|
||||
The tests currently do run and do pass and this should be maintained with commits.
|
||||
|
||||
##Versioning
|
||||
|
||||
Go OLE uses [semantic versioning](http://semver.org) for version numbers, which is similar to the version contract of the Go language. Which means that the major version will always maintain backwards compatibility with minor versions. Minor versions will only add new additions and changes. Fixes will always be in patch.
|
||||
|
||||
This contract should allow you to upgrade to new minor and patch versions without breakage or modifications to your existing code. Leave a ticket, if there is breakage, so that it could be fixed.
|
||||
|
||||
##LICENSE
|
||||
|
||||
Under the MIT License: http://mattn.mit-license.org/2013
|
||||
63
vendor/github.com/go-ole/go-ole/appveyor.yml
generated
vendored
63
vendor/github.com/go-ole/go-ole/appveyor.yml
generated
vendored
@@ -1,63 +0,0 @@
|
||||
# Notes:
|
||||
# - Minimal appveyor.yml file is an empty file. All sections are optional.
|
||||
# - Indent each level of configuration with 2 spaces. Do not use tabs!
|
||||
# - All section names are case-sensitive.
|
||||
# - Section names should be unique on each level.
|
||||
|
||||
version: "1.3.0.{build}-alpha-{branch}"
|
||||
|
||||
os: Windows Server 2012 R2
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- v1.2
|
||||
- v1.1
|
||||
- v1.0
|
||||
|
||||
skip_tags: true
|
||||
|
||||
clone_folder: c:\gopath\src\github.com\go-ole\go-ole
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
matrix:
|
||||
- GOARCH: amd64
|
||||
GOVERSION: 1.4
|
||||
GOROOT: c:\go
|
||||
DOWNLOADPLATFORM: "x64"
|
||||
|
||||
install:
|
||||
- choco install mingw
|
||||
- SET PATH=c:\tools\mingw64\bin;%PATH%
|
||||
# - Download COM Server
|
||||
- ps: Start-FileDownload "https://github.com/go-ole/test-com-server/releases/download/v1.0.2/test-com-server-${env:DOWNLOADPLATFORM}.zip"
|
||||
- 7z e test-com-server-%DOWNLOADPLATFORM%.zip -oc:\gopath\src\github.com\go-ole\go-ole > NUL
|
||||
- c:\gopath\src\github.com\go-ole\go-ole\build\register-assembly.bat
|
||||
# - set
|
||||
- go version
|
||||
- go env
|
||||
- c:\gopath\src\github.com\go-ole\go-ole\build\compile-go.bat
|
||||
- go tool dist install -v cmd/8a
|
||||
- go tool dist install -v cmd/8c
|
||||
- go tool dist install -v cmd/8g
|
||||
- go tool dist install -v cmd/8l
|
||||
- go tool dist install -v cmd/6a
|
||||
- go tool dist install -v cmd/6c
|
||||
- go tool dist install -v cmd/6g
|
||||
- go tool dist install -v cmd/6l
|
||||
- go get -u golang.org/x/tools/cmd/cover
|
||||
- go get -u golang.org/x/tools/cmd/godoc
|
||||
- go get -u golang.org/x/tools/cmd/stringer
|
||||
|
||||
build_script:
|
||||
- cd c:\gopath\src\github.com\go-ole\go-ole
|
||||
- go get -v -t ./...
|
||||
- go build
|
||||
- go test -v -cover ./...
|
||||
|
||||
# disable automatic tests
|
||||
test: off
|
||||
|
||||
# disable deployment
|
||||
deploy: off
|
||||
5
vendor/github.com/go-ole/go-ole/build/compile-go.bat
generated
vendored
5
vendor/github.com/go-ole/go-ole/build/compile-go.bat
generated
vendored
@@ -1,5 +0,0 @@
|
||||
@echo OFF
|
||||
|
||||
echo "BUILD GOLANG"
|
||||
cd "%GOROOT%\src"
|
||||
./make.bat --dist-tool
|
||||
8
vendor/github.com/go-ole/go-ole/build/register-assembly.bat
generated
vendored
8
vendor/github.com/go-ole/go-ole/build/register-assembly.bat
generated
vendored
@@ -1,8 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
IF "x86" == "%DOWNLOADPLATFORM%" (
|
||||
CALL c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe /codebase /nologo c:\gopath\src\github.com\go-ole\go-ole\TestCOMServer.dll
|
||||
)
|
||||
IF "x64" == "%DOWNLOADPLATFORM%" (
|
||||
CALL c:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe /codebase /nologo c:\gopath\src\github.com\go-ole\go-ole\TestCOMServer.dll
|
||||
)
|
||||
BIN
vendor/github.com/go-ole/go-ole/data/screenshot.png
generated
vendored
BIN
vendor/github.com/go-ole/go-ole/data/screenshot.png
generated
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
31
vendor/github.com/go-ole/go-ole/example/excel/excel.go
generated
vendored
31
vendor/github.com/go-ole/go-ole/example/excel/excel.go
generated
vendored
@@ -1,31 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ole.CoInitialize(0)
|
||||
unknown, _ := oleutil.CreateObject("Excel.Application")
|
||||
excel, _ := unknown.QueryInterface(ole.IID_IDispatch)
|
||||
oleutil.PutProperty(excel, "Visible", true)
|
||||
workbooks := oleutil.MustGetProperty(excel, "Workbooks").ToIDispatch()
|
||||
workbook := oleutil.MustCallMethod(workbooks, "Add", nil).ToIDispatch()
|
||||
worksheet := oleutil.MustGetProperty(workbook, "Worksheets", 1).ToIDispatch()
|
||||
cell := oleutil.MustGetProperty(worksheet, "Cells", 1, 1).ToIDispatch()
|
||||
oleutil.PutProperty(cell, "Value", 12345)
|
||||
|
||||
time.Sleep(2000000000)
|
||||
|
||||
oleutil.PutProperty(workbook, "Saved", true)
|
||||
oleutil.CallMethod(workbook, "Close", false)
|
||||
oleutil.CallMethod(excel, "Quit")
|
||||
excel.Release()
|
||||
|
||||
ole.CoUninitialize()
|
||||
}
|
||||
96
vendor/github.com/go-ole/go-ole/example/excel2/excel.go
generated
vendored
96
vendor/github.com/go-ole/go-ole/example/excel2/excel.go
generated
vendored
@@ -1,96 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
)
|
||||
|
||||
func writeExample(excel, workbooks *ole.IDispatch, filepath string) {
|
||||
// ref: https://msdn.microsoft.com/zh-tw/library/office/ff198017.aspx
|
||||
// http://stackoverflow.com/questions/12159513/what-is-the-correct-xlfileformat-enumeration-for-excel-97-2003
|
||||
const xlExcel8 = 56
|
||||
workbook := oleutil.MustCallMethod(workbooks, "Add", nil).ToIDispatch()
|
||||
defer workbook.Release()
|
||||
worksheet := oleutil.MustGetProperty(workbook, "Worksheets", 1).ToIDispatch()
|
||||
defer worksheet.Release()
|
||||
cell := oleutil.MustGetProperty(worksheet, "Cells", 1, 1).ToIDispatch()
|
||||
oleutil.PutProperty(cell, "Value", 12345)
|
||||
cell.Release()
|
||||
activeWorkBook := oleutil.MustGetProperty(excel, "ActiveWorkBook").ToIDispatch()
|
||||
defer activeWorkBook.Release()
|
||||
|
||||
os.Remove(filepath)
|
||||
// ref: https://msdn.microsoft.com/zh-tw/library/microsoft.office.tools.excel.workbook.saveas.aspx
|
||||
oleutil.MustCallMethod(activeWorkBook, "SaveAs", filepath, xlExcel8, nil, nil).ToIDispatch()
|
||||
|
||||
//time.Sleep(2 * time.Second)
|
||||
|
||||
// let excel could close without asking
|
||||
// oleutil.PutProperty(workbook, "Saved", true)
|
||||
// oleutil.CallMethod(workbook, "Close", false)
|
||||
}
|
||||
|
||||
func readExample(fileName string, excel, workbooks *ole.IDispatch) {
|
||||
workbook, err := oleutil.CallMethod(workbooks, "Open", fileName)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer workbook.ToIDispatch().Release()
|
||||
|
||||
sheets := oleutil.MustGetProperty(excel, "Sheets").ToIDispatch()
|
||||
sheetCount := (int)(oleutil.MustGetProperty(sheets, "Count").Val)
|
||||
fmt.Println("sheet count=", sheetCount)
|
||||
sheets.Release()
|
||||
|
||||
worksheet := oleutil.MustGetProperty(workbook.ToIDispatch(), "Worksheets", 1).ToIDispatch()
|
||||
defer worksheet.Release()
|
||||
for row := 1; row <= 2; row++ {
|
||||
for col := 1; col <= 5; col++ {
|
||||
cell := oleutil.MustGetProperty(worksheet, "Cells", row, col).ToIDispatch()
|
||||
val, err := oleutil.GetProperty(cell, "Value")
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
fmt.Printf("(%d,%d)=%+v toString=%s\n", col, row, val.Value(), val.ToString())
|
||||
cell.Release()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func showMethodsAndProperties(i *ole.IDispatch) {
|
||||
n, err := i.GetTypeInfoCount()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
tinfo, err := i.GetTypeInfo()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
fmt.Println("n=", n, "tinfo=", tinfo)
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.Flags() | log.Lshortfile)
|
||||
ole.CoInitialize(0)
|
||||
unknown, _ := oleutil.CreateObject("Excel.Application")
|
||||
excel, _ := unknown.QueryInterface(ole.IID_IDispatch)
|
||||
oleutil.PutProperty(excel, "Visible", true)
|
||||
|
||||
workbooks := oleutil.MustGetProperty(excel, "Workbooks").ToIDispatch()
|
||||
cwd, _ := os.Getwd()
|
||||
writeExample(excel, workbooks, cwd+"\\write.xls")
|
||||
readExample(cwd+"\\excel97-2003.xls", excel, workbooks)
|
||||
showMethodsAndProperties(workbooks)
|
||||
workbooks.Release()
|
||||
// oleutil.CallMethod(excel, "Quit")
|
||||
excel.Release()
|
||||
ole.CoUninitialize()
|
||||
}
|
||||
33
vendor/github.com/go-ole/go-ole/example/ie/ie.go
generated
vendored
33
vendor/github.com/go-ole/go-ole/example/ie/ie.go
generated
vendored
@@ -1,33 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ole.CoInitialize(0)
|
||||
unknown, _ := oleutil.CreateObject("InternetExplorer.Application")
|
||||
ie, _ := unknown.QueryInterface(ole.IID_IDispatch)
|
||||
oleutil.CallMethod(ie, "Navigate", "http://www.google.com")
|
||||
oleutil.PutProperty(ie, "Visible", true)
|
||||
for {
|
||||
if oleutil.MustGetProperty(ie, "Busy").Val == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
time.Sleep(1e9)
|
||||
|
||||
document := oleutil.MustGetProperty(ie, "document").ToIDispatch()
|
||||
window := oleutil.MustGetProperty(document, "parentWindow").ToIDispatch()
|
||||
// set 'golang' to text box.
|
||||
oleutil.MustCallMethod(window, "eval", "document.getElementsByName('q')[0].value = 'golang'")
|
||||
// click btnG.
|
||||
btnG := oleutil.MustCallMethod(window, "eval", "document.getElementsByName('btnG')[0]").ToIDispatch()
|
||||
oleutil.MustCallMethod(btnG, "click")
|
||||
}
|
||||
47
vendor/github.com/go-ole/go-ole/example/itunes/itunes.go
generated
vendored
47
vendor/github.com/go-ole/go-ole/example/itunes/itunes.go
generated
vendored
@@ -1,47 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
"github.com/gonuts/commander"
|
||||
)
|
||||
|
||||
func iTunes() *ole.IDispatch {
|
||||
ole.CoInitialize(0)
|
||||
unknown, err := oleutil.CreateObject("iTunes.Application")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
itunes, err := unknown.QueryInterface(ole.IID_IDispatch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return itunes
|
||||
}
|
||||
|
||||
func main() {
|
||||
command := &commander.Command{
|
||||
UsageLine: os.Args[0],
|
||||
Short: "itunes cmd",
|
||||
}
|
||||
command.Subcommands = []*commander.Command{}
|
||||
for _, name := range []string{"Play", "Stop", "Pause", "Quit"} {
|
||||
command.Subcommands = append(command.Subcommands, &commander.Command{
|
||||
Run: func(cmd *commander.Command, args []string) error {
|
||||
_, err := oleutil.CallMethod(iTunes(), name)
|
||||
return err
|
||||
},
|
||||
UsageLine: strings.ToLower(name),
|
||||
})
|
||||
}
|
||||
err := command.Dispatch(os.Args[1:])
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
29
vendor/github.com/go-ole/go-ole/example/mediaplayer/mediaplayer.go
generated
vendored
29
vendor/github.com/go-ole/go-ole/example/mediaplayer/mediaplayer.go
generated
vendored
@@ -1,29 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ole.CoInitialize(0)
|
||||
unknown, err := oleutil.CreateObject("WMPlayer.OCX")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
wmp := unknown.MustQueryInterface(ole.IID_IDispatch)
|
||||
collection := oleutil.MustGetProperty(wmp, "MediaCollection").ToIDispatch()
|
||||
list := oleutil.MustCallMethod(collection, "getAll").ToIDispatch()
|
||||
count := int(oleutil.MustGetProperty(list, "count").Val)
|
||||
for i := 0; i < count; i++ {
|
||||
item := oleutil.MustGetProperty(list, "item", i).ToIDispatch()
|
||||
name := oleutil.MustGetProperty(item, "name").ToString()
|
||||
sourceURL := oleutil.MustGetProperty(item, "sourceURL").ToString()
|
||||
fmt.Println(name, sourceURL)
|
||||
}
|
||||
}
|
||||
24
vendor/github.com/go-ole/go-ole/example/msagent/msagent.go
generated
vendored
24
vendor/github.com/go-ole/go-ole/example/msagent/msagent.go
generated
vendored
@@ -1,24 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ole.CoInitialize(0)
|
||||
unknown, _ := oleutil.CreateObject("Agent.Control.1")
|
||||
agent, _ := unknown.QueryInterface(ole.IID_IDispatch)
|
||||
oleutil.PutProperty(agent, "Connected", true)
|
||||
characters := oleutil.MustGetProperty(agent, "Characters").ToIDispatch()
|
||||
oleutil.CallMethod(characters, "Load", "Merlin", "c:\\windows\\msagent\\chars\\Merlin.acs")
|
||||
character := oleutil.MustCallMethod(characters, "Character", "Merlin").ToIDispatch()
|
||||
oleutil.CallMethod(character, "Show")
|
||||
oleutil.CallMethod(character, "Speak", "こんにちわ世界")
|
||||
|
||||
time.Sleep(4000000000)
|
||||
}
|
||||
49
vendor/github.com/go-ole/go-ole/example/msxml/rssreader.go
generated
vendored
49
vendor/github.com/go-ole/go-ole/example/msxml/rssreader.go
generated
vendored
@@ -1,49 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ole.CoInitialize(0)
|
||||
unknown, _ := oleutil.CreateObject("Microsoft.XMLHTTP")
|
||||
xmlhttp, _ := unknown.QueryInterface(ole.IID_IDispatch)
|
||||
_, err := oleutil.CallMethod(xmlhttp, "open", "GET", "http://rss.slashdot.org/Slashdot/slashdot", false)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
_, err = oleutil.CallMethod(xmlhttp, "send", nil)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
state := -1
|
||||
for state != 4 {
|
||||
state = int(oleutil.MustGetProperty(xmlhttp, "readyState").Val)
|
||||
time.Sleep(10000000)
|
||||
}
|
||||
responseXml := oleutil.MustGetProperty(xmlhttp, "responseXml").ToIDispatch()
|
||||
items := oleutil.MustCallMethod(responseXml, "selectNodes", "/rss/channel/item").ToIDispatch()
|
||||
length := int(oleutil.MustGetProperty(items, "length").Val)
|
||||
|
||||
for n := 0; n < length; n++ {
|
||||
item := oleutil.MustGetProperty(items, "item", n).ToIDispatch()
|
||||
|
||||
title := oleutil.MustCallMethod(item, "selectSingleNode", "title").ToIDispatch()
|
||||
fmt.Println(oleutil.MustGetProperty(title, "text").ToString())
|
||||
|
||||
link := oleutil.MustCallMethod(item, "selectSingleNode", "link").ToIDispatch()
|
||||
fmt.Println(" " + oleutil.MustGetProperty(link, "text").ToString())
|
||||
|
||||
title.Release()
|
||||
link.Release()
|
||||
item.Release()
|
||||
}
|
||||
items.Release()
|
||||
xmlhttp.Release()
|
||||
}
|
||||
29
vendor/github.com/go-ole/go-ole/example/outlook/outlook.go
generated
vendored
29
vendor/github.com/go-ole/go-ole/example/outlook/outlook.go
generated
vendored
@@ -1,29 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ole.CoInitialize(0)
|
||||
unknown, _ := oleutil.CreateObject("Outlook.Application")
|
||||
outlook, _ := unknown.QueryInterface(ole.IID_IDispatch)
|
||||
ns := oleutil.MustCallMethod(outlook, "GetNamespace", "MAPI").ToIDispatch()
|
||||
folder := oleutil.MustCallMethod(ns, "GetDefaultFolder", 10).ToIDispatch()
|
||||
contacts := oleutil.MustCallMethod(folder, "Items").ToIDispatch()
|
||||
count := oleutil.MustGetProperty(contacts, "Count").Value().(int32)
|
||||
for i := 1; i <= int(count); i++ {
|
||||
item, err := oleutil.GetProperty(contacts, "Item", i)
|
||||
if err == nil && item.VT == ole.VT_DISPATCH {
|
||||
if value, err := oleutil.GetProperty(item.ToIDispatch(), "FullName"); err == nil {
|
||||
fmt.Println(value.Value())
|
||||
}
|
||||
}
|
||||
}
|
||||
oleutil.MustCallMethod(outlook, "Quit")
|
||||
}
|
||||
140
vendor/github.com/go-ole/go-ole/example/winsock/winsock.go
generated
vendored
140
vendor/github.com/go-ole/go-ole/example/winsock/winsock.go
generated
vendored
@@ -1,140 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
ole "github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
)
|
||||
|
||||
type EventReceiver struct {
|
||||
lpVtbl *EventReceiverVtbl
|
||||
ref int32
|
||||
host *ole.IDispatch
|
||||
}
|
||||
|
||||
type EventReceiverVtbl struct {
|
||||
pQueryInterface uintptr
|
||||
pAddRef uintptr
|
||||
pRelease uintptr
|
||||
pGetTypeInfoCount uintptr
|
||||
pGetTypeInfo uintptr
|
||||
pGetIDsOfNames uintptr
|
||||
pInvoke uintptr
|
||||
}
|
||||
|
||||
func QueryInterface(this *ole.IUnknown, iid *ole.GUID, punk **ole.IUnknown) uint32 {
|
||||
s, _ := ole.StringFromCLSID(iid)
|
||||
*punk = nil
|
||||
if ole.IsEqualGUID(iid, ole.IID_IUnknown) ||
|
||||
ole.IsEqualGUID(iid, ole.IID_IDispatch) {
|
||||
AddRef(this)
|
||||
*punk = this
|
||||
return ole.S_OK
|
||||
}
|
||||
if s == "{248DD893-BB45-11CF-9ABC-0080C7E7B78D}" {
|
||||
AddRef(this)
|
||||
*punk = this
|
||||
return ole.S_OK
|
||||
}
|
||||
return ole.E_NOINTERFACE
|
||||
}
|
||||
|
||||
func AddRef(this *ole.IUnknown) int32 {
|
||||
pthis := (*EventReceiver)(unsafe.Pointer(this))
|
||||
pthis.ref++
|
||||
return pthis.ref
|
||||
}
|
||||
|
||||
func Release(this *ole.IUnknown) int32 {
|
||||
pthis := (*EventReceiver)(unsafe.Pointer(this))
|
||||
pthis.ref--
|
||||
return pthis.ref
|
||||
}
|
||||
|
||||
func GetIDsOfNames(this *ole.IUnknown, iid *ole.GUID, wnames []*uint16, namelen int, lcid int, pdisp []int32) uintptr {
|
||||
for n := 0; n < namelen; n++ {
|
||||
pdisp[n] = int32(n)
|
||||
}
|
||||
return uintptr(ole.S_OK)
|
||||
}
|
||||
|
||||
func GetTypeInfoCount(pcount *int) uintptr {
|
||||
if pcount != nil {
|
||||
*pcount = 0
|
||||
}
|
||||
return uintptr(ole.S_OK)
|
||||
}
|
||||
|
||||
func GetTypeInfo(ptypeif *uintptr) uintptr {
|
||||
return uintptr(ole.E_NOTIMPL)
|
||||
}
|
||||
|
||||
func Invoke(this *ole.IDispatch, dispid int, riid *ole.GUID, lcid int, flags int16, dispparams *ole.DISPPARAMS, result *ole.VARIANT, pexcepinfo *ole.EXCEPINFO, nerr *uint) uintptr {
|
||||
switch dispid {
|
||||
case 0:
|
||||
log.Println("DataArrival")
|
||||
winsock := (*EventReceiver)(unsafe.Pointer(this)).host
|
||||
var data ole.VARIANT
|
||||
ole.VariantInit(&data)
|
||||
oleutil.CallMethod(winsock, "GetData", &data)
|
||||
s := string(data.ToArray().ToByteArray())
|
||||
println()
|
||||
println(s)
|
||||
println()
|
||||
case 1:
|
||||
log.Println("Connected")
|
||||
winsock := (*EventReceiver)(unsafe.Pointer(this)).host
|
||||
oleutil.CallMethod(winsock, "SendData", "GET / HTTP/1.0\r\n\r\n")
|
||||
case 3:
|
||||
log.Println("SendProgress")
|
||||
case 4:
|
||||
log.Println("SendComplete")
|
||||
case 5:
|
||||
log.Println("Close")
|
||||
this.Release()
|
||||
case 6:
|
||||
log.Fatal("Error")
|
||||
default:
|
||||
log.Println(dispid)
|
||||
}
|
||||
return ole.E_NOTIMPL
|
||||
}
|
||||
|
||||
func main() {
|
||||
ole.CoInitialize(0)
|
||||
|
||||
unknown, err := oleutil.CreateObject("{248DD896-BB45-11CF-9ABC-0080C7E7B78D}")
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
winsock, _ := unknown.QueryInterface(ole.IID_IDispatch)
|
||||
iid, _ := ole.CLSIDFromString("{248DD893-BB45-11CF-9ABC-0080C7E7B78D}")
|
||||
|
||||
dest := &EventReceiver{}
|
||||
dest.lpVtbl = &EventReceiverVtbl{}
|
||||
dest.lpVtbl.pQueryInterface = syscall.NewCallback(QueryInterface)
|
||||
dest.lpVtbl.pAddRef = syscall.NewCallback(AddRef)
|
||||
dest.lpVtbl.pRelease = syscall.NewCallback(Release)
|
||||
dest.lpVtbl.pGetTypeInfoCount = syscall.NewCallback(GetTypeInfoCount)
|
||||
dest.lpVtbl.pGetTypeInfo = syscall.NewCallback(GetTypeInfo)
|
||||
dest.lpVtbl.pGetIDsOfNames = syscall.NewCallback(GetIDsOfNames)
|
||||
dest.lpVtbl.pInvoke = syscall.NewCallback(Invoke)
|
||||
dest.host = winsock
|
||||
|
||||
oleutil.ConnectObject(winsock, iid, (*ole.IUnknown)(unsafe.Pointer(dest)))
|
||||
_, err = oleutil.CallMethod(winsock, "Connect", "127.0.0.1", 80)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var m ole.Msg
|
||||
for dest.ref != 0 {
|
||||
ole.GetMessage(&m, 0, 0, 0)
|
||||
ole.DispatchMessage(&m)
|
||||
}
|
||||
}
|
||||
210
vendor/github.com/go-ole/go-ole/guid.go
generated
vendored
210
vendor/github.com/go-ole/go-ole/guid.go
generated
vendored
@@ -2,28 +2,28 @@ package ole
|
||||
|
||||
var (
|
||||
// IID_NULL is null Interface ID, used when no other Interface ID is known.
|
||||
IID_NULL = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
|
||||
IID_NULL = NewGUID("{00000000-0000-0000-0000-000000000000}")
|
||||
|
||||
// IID_IUnknown is for IUnknown interfaces.
|
||||
IID_IUnknown = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}
|
||||
IID_IUnknown = NewGUID("{00000000-0000-0000-C000-000000000046}")
|
||||
|
||||
// IID_IDispatch is for IDispatch interfaces.
|
||||
IID_IDispatch = &GUID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}
|
||||
IID_IDispatch = NewGUID("{00020400-0000-0000-C000-000000000046}")
|
||||
|
||||
// IID_IEnumVariant is for IEnumVariant interfaces
|
||||
IID_IEnumVariant = &GUID{0x00020404, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}
|
||||
IID_IEnumVariant = NewGUID("{00020404-0000-0000-C000-000000000046}")
|
||||
|
||||
// IID_IConnectionPointContainer is for IConnectionPointContainer interfaces.
|
||||
IID_IConnectionPointContainer = &GUID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}}
|
||||
IID_IConnectionPointContainer = NewGUID("{B196B284-BAB4-101A-B69C-00AA00341D07}")
|
||||
|
||||
// IID_IConnectionPoint is for IConnectionPoint interfaces.
|
||||
IID_IConnectionPoint = &GUID{0xB196B286, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}}
|
||||
IID_IConnectionPoint = NewGUID("{B196B286-BAB4-101A-B69C-00AA00341D07}")
|
||||
|
||||
// IID_IInspectable is for IInspectable interfaces.
|
||||
IID_IInspectable = &GUID{0xaf86e2e0, 0xb12d, 0x4c6a, [8]byte{0x9c, 0x5a, 0xd7, 0xaa, 0x65, 0x10, 0x1e, 0x90}}
|
||||
IID_IInspectable = NewGUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}")
|
||||
|
||||
// IID_IProvideClassInfo is for IProvideClassInfo interfaces.
|
||||
IID_IProvideClassInfo = &GUID{0xb196b283, 0xbab4, 0x101a, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}}
|
||||
IID_IProvideClassInfo = NewGUID("{B196B283-BAB4-101A-B69C-00AA00341D07}")
|
||||
)
|
||||
|
||||
// These are for testing and not part of any library.
|
||||
@@ -31,64 +31,67 @@ var (
|
||||
// IID_ICOMTestString is for ICOMTestString interfaces.
|
||||
//
|
||||
// {E0133EB4-C36F-469A-9D3D-C66B84BE19ED}
|
||||
IID_ICOMTestString = &GUID{0xe0133eb4, 0xc36f, 0x469a, [8]byte{0x9d, 0x3d, 0xc6, 0x6b, 0x84, 0xbe, 0x19, 0xed}}
|
||||
IID_ICOMTestString = NewGUID("{E0133EB4-C36F-469A-9D3D-C66B84BE19ED}")
|
||||
|
||||
// IID_ICOMTestInt8 is for ICOMTestInt8 interfaces.
|
||||
//
|
||||
// {BEB06610-EB84-4155-AF58-E2BFF53608B4}
|
||||
IID_ICOMTestInt8 = &GUID{0xbeb06610, 0xeb84, 0x4155, [8]byte{0xaf, 0x58, 0xe2, 0xbf, 0xf5, 0x36, 0x80, 0xb4}}
|
||||
// {BEB06610-EB84-4155-AF58-E2BFF53680B4}
|
||||
IID_ICOMTestInt8 = NewGUID("{BEB06610-EB84-4155-AF58-E2BFF53680B4}")
|
||||
|
||||
// IID_ICOMTestInt16 is for ICOMTestInt16 interfaces.
|
||||
//
|
||||
// {DAA3F9FA-761E-4976-A860-8364CE55F6FC}
|
||||
IID_ICOMTestInt16 = &GUID{0xdaa3f9fa, 0x761e, 0x4976, [8]byte{0xa8, 0x60, 0x83, 0x64, 0xce, 0x55, 0xf6, 0xfc}}
|
||||
IID_ICOMTestInt16 = NewGUID("{DAA3F9FA-761E-4976-A860-8364CE55F6FC}")
|
||||
|
||||
// IID_ICOMTestInt32 is for ICOMTestInt32 interfaces.
|
||||
//
|
||||
// {E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0}
|
||||
IID_ICOMTestInt32 = &GUID{0xe3dedee7, 0x38a2, 0x4540, [8]byte{0x91, 0xd1, 0x2e, 0xef, 0x1d, 0x88, 0x91, 0xb0}}
|
||||
IID_ICOMTestInt32 = NewGUID("{E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0}")
|
||||
|
||||
// IID_ICOMTestInt64 is for ICOMTestInt64 interfaces.
|
||||
//
|
||||
// {8D437CBC-B3ED-485C-BC32-C336432A1623}
|
||||
IID_ICOMTestInt64 = &GUID{0x8d437cbc, 0xb3ed, 0x485c, [8]byte{0xbc, 0x32, 0xc3, 0x36, 0x43, 0x2a, 0x16, 0x23}}
|
||||
IID_ICOMTestInt64 = NewGUID("{8D437CBC-B3ED-485C-BC32-C336432A1623}")
|
||||
|
||||
// IID_ICOMTestFloat is for ICOMTestFloat interfaces.
|
||||
//
|
||||
// {BF1ED004-EA02-456A-AA55-2AC8AC6B054C}
|
||||
IID_ICOMTestFloat = &GUID{0xbf1ed004, 0xea02, 0x456a, [8]byte{0xaa, 0x55, 0x2a, 0xc8, 0xac, 0x6b, 0x5, 0x4c}}
|
||||
IID_ICOMTestFloat = NewGUID("{BF1ED004-EA02-456A-AA55-2AC8AC6B054C}")
|
||||
|
||||
// IID_ICOMTestDouble is for ICOMTestDouble interfaces.
|
||||
//
|
||||
// {BF908A81-8687-4E93-999F-D86FAB284BA0}
|
||||
IID_ICOMTestDouble = &GUID{0xbf908a81, 0x8687, 0x4e93, [8]byte{0x99, 0x9f, 0xd8, 0x6f, 0xab, 0x28, 0x4b, 0xa0}}
|
||||
IID_ICOMTestDouble = NewGUID("{BF908A81-8687-4E93-999F-D86FAB284BA0}")
|
||||
|
||||
// IID_ICOMTestBoolean is for ICOMTestBoolean interfaces.
|
||||
//
|
||||
// {D530E7A6-4EE8-40D1-8931-3D63B8605001}
|
||||
IID_ICOMTestBoolean = &GUID{0xd530e7a6, 0x4ee8, 0x40d1, [8]byte{0x89, 0x31, 0x3d, 0x63, 0xb8, 0x60, 0x50, 0x10}}
|
||||
// {D530E7A6-4EE8-40D1-8931-3D63B8605010}
|
||||
IID_ICOMTestBoolean = NewGUID("{D530E7A6-4EE8-40D1-8931-3D63B8605010}")
|
||||
|
||||
// IID_ICOMEchoTestObject is for ICOMEchoTestObject interfaces.
|
||||
//
|
||||
// {6485B1EF-D780-4834-A4FE-1EBB51746CA3}
|
||||
IID_ICOMEchoTestObject = &GUID{0x6485b1ef, 0xd780, 0x4834, [8]byte{0xa4, 0xfe, 0x1e, 0xbb, 0x51, 0x74, 0x6c, 0xa3}}
|
||||
IID_ICOMEchoTestObject = NewGUID("{6485B1EF-D780-4834-A4FE-1EBB51746CA3}")
|
||||
|
||||
// IID_ICOMTestTypes is for ICOMTestTypes interfaces.
|
||||
//
|
||||
// {CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0}
|
||||
IID_ICOMTestTypes = &GUID{0xcca8d7ae, 0x91c0, 0x4277, [8]byte{0xa8, 0xb3, 0xff, 0x4e, 0xdf, 0x28, 0xd3, 0xc0}}
|
||||
IID_ICOMTestTypes = NewGUID("{CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0}")
|
||||
|
||||
// CLSID_COMEchoTestObject is for COMEchoTestObject class.
|
||||
//
|
||||
// {3C24506A-AE9E-4D50-9157-EF317281F1B0}
|
||||
CLSID_COMEchoTestObject = &GUID{0x3c24506a, 0xae9e, 0x4d50, [8]byte{0x91, 0x57, 0xef, 0x31, 0x72, 0x81, 0xf1, 0xb0}}
|
||||
CLSID_COMEchoTestObject = NewGUID("{3C24506A-AE9E-4D50-9157-EF317281F1B0}")
|
||||
|
||||
// CLSID_COMTestScalarClass is for COMTestScalarClass class.
|
||||
//
|
||||
// {865B85C5-0334-4AC6-9EF6-AACEC8FC5E86}
|
||||
CLSID_COMTestScalarClass = &GUID{0x865b85c5, 0x0334, 0x4ac6, [8]byte{0x9e, 0xf6, 0xaa, 0xce, 0xc8, 0xfc, 0x5e, 0x86}}
|
||||
CLSID_COMTestScalarClass = NewGUID("{865B85C5-0334-4AC6-9EF6-AACEC8FC5E86}")
|
||||
)
|
||||
|
||||
const hextable = "0123456789ABCDEF"
|
||||
const emptyGUID = "{00000000-0000-0000-0000-000000000000}"
|
||||
|
||||
// GUID is Windows API specific GUID type.
|
||||
//
|
||||
// This exists to match Windows GUID type for direct passing for COM.
|
||||
@@ -100,6 +103,169 @@ type GUID struct {
|
||||
Data4 [8]byte
|
||||
}
|
||||
|
||||
// NewGUID converts the given string into a globally unique identifier that is
|
||||
// compliant with the Windows API.
|
||||
//
|
||||
// The supplied string may be in any of these formats:
|
||||
//
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
// XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
||||
// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
|
||||
//
|
||||
// The conversion of the supplied string is not case-sensitive.
|
||||
func NewGUID(guid string) *GUID {
|
||||
d := []byte(guid)
|
||||
var d1, d2, d3, d4a, d4b []byte
|
||||
|
||||
switch len(d) {
|
||||
case 38:
|
||||
if d[0] != '{' || d[37] != '}' {
|
||||
return nil
|
||||
}
|
||||
d = d[1:37]
|
||||
fallthrough
|
||||
case 36:
|
||||
if d[8] != '-' || d[13] != '-' || d[18] != '-' || d[23] != '-' {
|
||||
return nil
|
||||
}
|
||||
d1 = d[0:8]
|
||||
d2 = d[9:13]
|
||||
d3 = d[14:18]
|
||||
d4a = d[19:23]
|
||||
d4b = d[24:36]
|
||||
case 32:
|
||||
d1 = d[0:8]
|
||||
d2 = d[8:12]
|
||||
d3 = d[12:16]
|
||||
d4a = d[16:20]
|
||||
d4b = d[20:32]
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
var g GUID
|
||||
var ok1, ok2, ok3, ok4 bool
|
||||
g.Data1, ok1 = decodeHexUint32(d1)
|
||||
g.Data2, ok2 = decodeHexUint16(d2)
|
||||
g.Data3, ok3 = decodeHexUint16(d3)
|
||||
g.Data4, ok4 = decodeHexByte64(d4a, d4b)
|
||||
if ok1 && ok2 && ok3 && ok4 {
|
||||
return &g
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func decodeHexUint32(src []byte) (value uint32, ok bool) {
|
||||
var b1, b2, b3, b4 byte
|
||||
var ok1, ok2, ok3, ok4 bool
|
||||
b1, ok1 = decodeHexByte(src[0], src[1])
|
||||
b2, ok2 = decodeHexByte(src[2], src[3])
|
||||
b3, ok3 = decodeHexByte(src[4], src[5])
|
||||
b4, ok4 = decodeHexByte(src[6], src[7])
|
||||
value = (uint32(b1) << 24) | (uint32(b2) << 16) | (uint32(b3) << 8) | uint32(b4)
|
||||
ok = ok1 && ok2 && ok3 && ok4
|
||||
return
|
||||
}
|
||||
|
||||
func decodeHexUint16(src []byte) (value uint16, ok bool) {
|
||||
var b1, b2 byte
|
||||
var ok1, ok2 bool
|
||||
b1, ok1 = decodeHexByte(src[0], src[1])
|
||||
b2, ok2 = decodeHexByte(src[2], src[3])
|
||||
value = (uint16(b1) << 8) | uint16(b2)
|
||||
ok = ok1 && ok2
|
||||
return
|
||||
}
|
||||
|
||||
func decodeHexByte64(s1 []byte, s2 []byte) (value [8]byte, ok bool) {
|
||||
var ok1, ok2, ok3, ok4, ok5, ok6, ok7, ok8 bool
|
||||
value[0], ok1 = decodeHexByte(s1[0], s1[1])
|
||||
value[1], ok2 = decodeHexByte(s1[2], s1[3])
|
||||
value[2], ok3 = decodeHexByte(s2[0], s2[1])
|
||||
value[3], ok4 = decodeHexByte(s2[2], s2[3])
|
||||
value[4], ok5 = decodeHexByte(s2[4], s2[5])
|
||||
value[5], ok6 = decodeHexByte(s2[6], s2[7])
|
||||
value[6], ok7 = decodeHexByte(s2[8], s2[9])
|
||||
value[7], ok8 = decodeHexByte(s2[10], s2[11])
|
||||
ok = ok1 && ok2 && ok3 && ok4 && ok5 && ok6 && ok7 && ok8
|
||||
return
|
||||
}
|
||||
|
||||
func decodeHexByte(c1, c2 byte) (value byte, ok bool) {
|
||||
var n1, n2 byte
|
||||
var ok1, ok2 bool
|
||||
n1, ok1 = decodeHexChar(c1)
|
||||
n2, ok2 = decodeHexChar(c2)
|
||||
value = (n1 << 4) | n2
|
||||
ok = ok1 && ok2
|
||||
return
|
||||
}
|
||||
|
||||
func decodeHexChar(c byte) (byte, bool) {
|
||||
switch {
|
||||
case '0' <= c && c <= '9':
|
||||
return c - '0', true
|
||||
case 'a' <= c && c <= 'f':
|
||||
return c - 'a' + 10, true
|
||||
case 'A' <= c && c <= 'F':
|
||||
return c - 'A' + 10, true
|
||||
}
|
||||
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// String converts the GUID to string form. It will adhere to this pattern:
|
||||
//
|
||||
// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
|
||||
//
|
||||
// If the GUID is nil, the string representation of an empty GUID is returned:
|
||||
//
|
||||
// {00000000-0000-0000-0000-000000000000}
|
||||
func (guid *GUID) String() string {
|
||||
if guid == nil {
|
||||
return emptyGUID
|
||||
}
|
||||
|
||||
var c [38]byte
|
||||
c[0] = '{'
|
||||
putUint32Hex(c[1:9], guid.Data1)
|
||||
c[9] = '-'
|
||||
putUint16Hex(c[10:14], guid.Data2)
|
||||
c[14] = '-'
|
||||
putUint16Hex(c[15:19], guid.Data3)
|
||||
c[19] = '-'
|
||||
putByteHex(c[20:24], guid.Data4[0:2])
|
||||
c[24] = '-'
|
||||
putByteHex(c[25:37], guid.Data4[2:8])
|
||||
c[37] = '}'
|
||||
return string(c[:])
|
||||
}
|
||||
|
||||
func putUint32Hex(b []byte, v uint32) {
|
||||
b[0] = hextable[byte(v>>24)>>4]
|
||||
b[1] = hextable[byte(v>>24)&0x0f]
|
||||
b[2] = hextable[byte(v>>16)>>4]
|
||||
b[3] = hextable[byte(v>>16)&0x0f]
|
||||
b[4] = hextable[byte(v>>8)>>4]
|
||||
b[5] = hextable[byte(v>>8)&0x0f]
|
||||
b[6] = hextable[byte(v)>>4]
|
||||
b[7] = hextable[byte(v)&0x0f]
|
||||
}
|
||||
|
||||
func putUint16Hex(b []byte, v uint16) {
|
||||
b[0] = hextable[byte(v>>8)>>4]
|
||||
b[1] = hextable[byte(v>>8)&0x0f]
|
||||
b[2] = hextable[byte(v)>>4]
|
||||
b[3] = hextable[byte(v)&0x0f]
|
||||
}
|
||||
|
||||
func putByteHex(dst, src []byte) {
|
||||
for i := 0; i < len(src); i++ {
|
||||
dst[i*2] = hextable[src[i]>>4]
|
||||
dst[i*2+1] = hextable[src[i]&0x0f]
|
||||
}
|
||||
}
|
||||
|
||||
// IsEqualGUID compares two GUID.
|
||||
//
|
||||
// Not constant time comparison.
|
||||
|
||||
13
vendor/github.com/go-ole/go-ole/idispatch_windows.go
generated
vendored
13
vendor/github.com/go-ole/go-ole/idispatch_windows.go
generated
vendored
@@ -180,17 +180,14 @@ func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}
|
||||
if hr != 0 {
|
||||
err = NewErrorWithSubError(hr, BstrToString(excepInfo.bstrDescription), excepInfo)
|
||||
}
|
||||
for _, varg := range vargs {
|
||||
for i, varg := range vargs {
|
||||
n := len(params) - i - 1
|
||||
if varg.VT == VT_BSTR && varg.Val != 0 {
|
||||
SysFreeString(((*int16)(unsafe.Pointer(uintptr(varg.Val)))))
|
||||
}
|
||||
/*
|
||||
if varg.VT == (VT_BSTR|VT_BYREF) && varg.Val != 0 {
|
||||
*(params[n].(*string)) = LpOleStrToString((*uint16)(unsafe.Pointer(uintptr(varg.Val))))
|
||||
println(*(params[n].(*string)))
|
||||
fmt.Fprintln(os.Stderr, *(params[n].(*string)))
|
||||
}
|
||||
*/
|
||||
if varg.VT == (VT_BSTR|VT_BYREF) && varg.Val != 0 {
|
||||
*(params[n].(*string)) = LpOleStrToString(*(**uint16)(unsafe.Pointer(uintptr(varg.Val))))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
2
vendor/github.com/go-ole/go-ole/iinspectable_windows.go
generated
vendored
2
vendor/github.com/go-ole/go-ole/iinspectable_windows.go
generated
vendored
@@ -30,7 +30,7 @@ func (v *IInspectable) GetIids() (iids []*GUID, err error) {
|
||||
slicehdr := reflect.SliceHeader{Data: array, Len: int(byteCount), Cap: int(byteCount)}
|
||||
byteSlice := *(*[]byte)(unsafe.Pointer(&slicehdr))
|
||||
reader := bytes.NewReader(byteSlice)
|
||||
for i, _ := range iids {
|
||||
for i := range iids {
|
||||
guid := GUID{}
|
||||
err = binary.Read(reader, binary.LittleEndian, &guid)
|
||||
if err != nil {
|
||||
|
||||
1
vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go
generated
vendored
1
vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go
generated
vendored
@@ -49,6 +49,7 @@ func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (cooki
|
||||
point.Release()
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
container.Release()
|
||||
|
||||
8
vendor/github.com/go-ole/go-ole/safearray_func.go
generated
vendored
8
vendor/github.com/go-ole/go-ole/safearray_func.go
generated
vendored
@@ -2,6 +2,10 @@
|
||||
|
||||
package ole
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// safeArrayAccessData returns raw array pointer.
|
||||
//
|
||||
// AKA: SafeArrayAccessData in Windows API.
|
||||
@@ -120,8 +124,8 @@ func safeArrayGetElementSize(safearray *SafeArray) (*uint32, error) {
|
||||
}
|
||||
|
||||
// safeArrayGetElement retrieves element at given index.
|
||||
func safeArrayGetElement(safearray *SafeArray, index int64) (uintptr, error) {
|
||||
return uintptr(0), NewError(E_NOTIMPL)
|
||||
func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error {
|
||||
return NewError(E_NOTIMPL)
|
||||
}
|
||||
|
||||
// safeArrayGetElement retrieves element at given index and converts to string.
|
||||
|
||||
26
vendor/github.com/shirou/gopsutil/Makefile
generated
vendored
26
vendor/github.com/shirou/gopsutil/Makefile
generated
vendored
@@ -1,26 +0,0 @@
|
||||
.PHONY: help check
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
SUBPKGS=cpu disk docker host internal load mem net process
|
||||
|
||||
help: ## Show help
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
check: ## Check
|
||||
errcheck -ignore="Close|Run|Write" ./...
|
||||
golint ./... | egrep -v 'underscores|HttpOnly|should have comment|comment on exported|CamelCase|VM|UID' && exit 1 || exit 0
|
||||
|
||||
BUILD_FAIL_PATTERN=grep -v "exec format error" | grep "build failed" && exit 1 || exit 0
|
||||
build_test: ## test only buildable
|
||||
# Supported operating systems
|
||||
GOOS=linux go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=freebsd go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
CGO_ENABLED=0 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
CGO_ENABLED=1 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=windows go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
# Operating systems supported for building only (not implemented error if used)
|
||||
GOOS=dragonfly go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=netbsd go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=openbsd go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=solaris go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
@echo 'Successfully built on all known operating systems'
|
||||
300
vendor/github.com/shirou/gopsutil/README.rst
generated
vendored
300
vendor/github.com/shirou/gopsutil/README.rst
generated
vendored
@@ -1,300 +0,0 @@
|
||||
gopsutil: psutil for golang
|
||||
==============================
|
||||
|
||||
.. image:: https://circleci.com/gh/shirou/gopsutil.svg?&style=shield
|
||||
:target: https://circleci.com/gh/shirou/gopsutil
|
||||
|
||||
.. image:: https://coveralls.io/repos/shirou/gopsutil/badge.svg?branch=master
|
||||
:target: https://coveralls.io/r/shirou/gopsutil?branch=master
|
||||
|
||||
.. image:: https://godoc.org/github.com/shirou/gopsutil?status.svg
|
||||
:target: http://godoc.org/github.com/shirou/gopsutil
|
||||
|
||||
This is a port of psutil (http://pythonhosted.org/psutil/). The challenge is porting all
|
||||
psutil functions on some architectures.
|
||||
|
||||
|
||||
.. highlights:: Breaking Changes!
|
||||
|
||||
Breaking changes is introduced at v2. See `issue 174 <https://github.com/shirou/gopsutil/issues/174>`_ .
|
||||
|
||||
|
||||
Migrating to v2
|
||||
-------------------------
|
||||
|
||||
On gopsutil itself, `v2migration.sh <https://github.com/shirou/gopsutil/blob/v2/v2migration.sh>`_ is used for migration. It can not be commonly used, but it may help you with migration.
|
||||
|
||||
|
||||
Available Architectures
|
||||
------------------------------------
|
||||
|
||||
- FreeBSD i386/amd64
|
||||
- Linux i386/amd64/arm(raspberry pi)
|
||||
- Windows/amd64
|
||||
- Darwin/amd64
|
||||
|
||||
All works are implemented without cgo by porting c struct to golang struct.
|
||||
|
||||
|
||||
Usage
|
||||
---------
|
||||
|
||||
Note: gopsutil v2 breaks compatibility. If you want to stay with compatibility, please use v1 branch and vendoring.
|
||||
|
||||
.. code:: go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/shirou/gopsutil/mem"
|
||||
)
|
||||
|
||||
func main() {
|
||||
v, _ := mem.VirtualMemory()
|
||||
|
||||
// almost every return value is a struct
|
||||
fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)
|
||||
|
||||
// convert to JSON. String() is also implemented
|
||||
fmt.Println(v)
|
||||
}
|
||||
|
||||
The output is below.
|
||||
|
||||
::
|
||||
|
||||
Total: 3179569152, Free:284233728, UsedPercent:84.508194%
|
||||
{"total":3179569152,"available":492572672,"used":2895335424,"usedPercent":84.50819439828305, (snip...)}
|
||||
|
||||
You can set an alternative location to :code:`/proc` by setting the :code:`HOST_PROC` environment variable.
|
||||
|
||||
You can set an alternative location to :code:`/sys` by setting the :code:`HOST_SYS` environment variable.
|
||||
|
||||
You can set an alternative location to :code:`/etc` by setting the :code:`HOST_ETC` environment variable.
|
||||
|
||||
Documentation
|
||||
------------------------
|
||||
|
||||
see http://godoc.org/github.com/shirou/gopsutil
|
||||
|
||||
Requirements
|
||||
-----------------
|
||||
|
||||
- go1.5 or above is required.
|
||||
|
||||
|
||||
More Info
|
||||
--------------------
|
||||
|
||||
Several methods have been added which are not present in psutil, but will provide useful information.
|
||||
|
||||
- host/HostInfo() (linux)
|
||||
|
||||
- Hostname
|
||||
- Uptime
|
||||
- Procs
|
||||
- OS (ex: "linux")
|
||||
- Platform (ex: "ubuntu", "arch")
|
||||
- PlatformFamily (ex: "debian")
|
||||
- PlatformVersion (ex: "Ubuntu 13.10")
|
||||
- VirtualizationSystem (ex: "LXC")
|
||||
- VirtualizationRole (ex: "guest"/"host")
|
||||
|
||||
- cpu/CPUInfo() (linux, freebsd)
|
||||
|
||||
- CPU (ex: 0, 1, ...)
|
||||
- VendorID (ex: "GenuineIntel")
|
||||
- Family
|
||||
- Model
|
||||
- Stepping
|
||||
- PhysicalID
|
||||
- CoreID
|
||||
- Cores (ex: 2)
|
||||
- ModelName (ex: "Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz")
|
||||
- Mhz
|
||||
- CacheSize
|
||||
- Flags (ex: "fpu vme de pse tsc msr pae mce cx8 ...")
|
||||
|
||||
- load/LoadAvg() (linux, freebsd)
|
||||
|
||||
- Load1
|
||||
- Load5
|
||||
- Load15
|
||||
|
||||
- docker/GetDockerIDList() (linux only)
|
||||
|
||||
- container id list ([]string)
|
||||
|
||||
- docker/CgroupCPU() (linux only)
|
||||
|
||||
- user
|
||||
- system
|
||||
|
||||
- docker/CgroupMem() (linux only)
|
||||
|
||||
- various status
|
||||
|
||||
- net_protocols (linux only)
|
||||
|
||||
- system wide stats on network protocols (i.e IP, TCP, UDP, etc.)
|
||||
- sourced from /proc/net/snmp
|
||||
|
||||
- iptables nf_conntrack (linux only)
|
||||
|
||||
- system wide stats on netfilter conntrack module
|
||||
- sourced from /proc/sys/net/netfilter/nf_conntrack_count
|
||||
|
||||
Some codes are ported from Ohai. many thanks.
|
||||
|
||||
|
||||
Current Status
|
||||
------------------
|
||||
|
||||
- x: work
|
||||
- b: almost works, but something is broken
|
||||
|
||||
================= ====== ======= ====== =======
|
||||
name Linux FreeBSD MacOSX Windows
|
||||
cpu_times x x x x
|
||||
cpu_count x x x x
|
||||
cpu_percent x x x x
|
||||
cpu_times_percent x x x x
|
||||
virtual_memory x x x x
|
||||
swap_memory x x x
|
||||
disk_partitions x x x x
|
||||
disk_io_counters x x
|
||||
disk_usage x x x x
|
||||
net_io_counters x x b x
|
||||
boot_time x x x x
|
||||
users x x x x
|
||||
pids x x x x
|
||||
pid_exists x x x x
|
||||
net_connections x x
|
||||
net_protocols x
|
||||
net_if_addrs
|
||||
net_if_stats
|
||||
netfilter_conntrack x
|
||||
================= ====== ======= ====== =======
|
||||
|
||||
Process class
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
================ ===== ======= ====== =======
|
||||
name Linux FreeBSD MacOSX Windows
|
||||
pid x x x x
|
||||
ppid x x x x
|
||||
name x x x x
|
||||
cmdline x x x
|
||||
create_time x
|
||||
status x x x
|
||||
cwd x
|
||||
exe x x x
|
||||
uids x x x
|
||||
gids x x x
|
||||
terminal x x x
|
||||
io_counters x x x
|
||||
nice x x x x
|
||||
num_fds x
|
||||
num_ctx_switches x
|
||||
num_threads x x x x
|
||||
cpu_times x
|
||||
memory_info x x x x
|
||||
memory_info_ex x
|
||||
memory_maps x
|
||||
open_files x
|
||||
send_signal x x x
|
||||
suspend x x x
|
||||
resume x x x
|
||||
terminate x x x
|
||||
kill x x x
|
||||
username x
|
||||
ionice
|
||||
rlimit
|
||||
num_handlres
|
||||
threads
|
||||
cpu_percent x x
|
||||
cpu_affinity
|
||||
memory_percent
|
||||
parent x x
|
||||
children x x x
|
||||
connections x x
|
||||
is_running
|
||||
================ ===== ======= ====== =======
|
||||
|
||||
Original Metrics
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
================== ===== ======= ====== =======
|
||||
item Linux FreeBSD MacOSX Windows
|
||||
**HostInfo**
|
||||
hostname x x x x
|
||||
uptime x x x
|
||||
proces x x
|
||||
os x x x x
|
||||
platform x x x
|
||||
platformfamily x x x
|
||||
virtualization x
|
||||
**CPU**
|
||||
VendorID x x x x
|
||||
Family x x x x
|
||||
Model x x x x
|
||||
Stepping x x x x
|
||||
PhysicalID x
|
||||
CoreID x
|
||||
Cores x x
|
||||
ModelName x x x x
|
||||
**LoadAvg**
|
||||
Load1 x x x
|
||||
Load5 x x x
|
||||
Load15 x x x
|
||||
**GetDockerID**
|
||||
container id x no no no
|
||||
**CgroupsCPU**
|
||||
user x no no no
|
||||
system x no no no
|
||||
**CgroupsMem**
|
||||
various x no no no
|
||||
================== ===== ======= ====== =======
|
||||
|
||||
- future work
|
||||
|
||||
- process_iter
|
||||
- wait_procs
|
||||
- Process class
|
||||
|
||||
- as_dict
|
||||
- wait
|
||||
|
||||
|
||||
License
|
||||
------------
|
||||
|
||||
New BSD License (same as psutil)
|
||||
|
||||
|
||||
Related Works
|
||||
-----------------------
|
||||
|
||||
I have been influenced by the following great works:
|
||||
|
||||
- psutil: http://pythonhosted.org/psutil/
|
||||
- dstat: https://github.com/dagwieers/dstat
|
||||
- gosigar: https://github.com/cloudfoundry/gosigar/
|
||||
- goprocinfo: https://github.com/c9s/goprocinfo
|
||||
- go-ps: https://github.com/mitchellh/go-ps
|
||||
- ohai: https://github.com/opscode/ohai/
|
||||
- bosun: https://github.com/bosun-monitor/bosun/tree/master/cmd/scollector/collectors
|
||||
- mackerel: https://github.com/mackerelio/mackerel-agent/tree/master/metrics
|
||||
|
||||
How to Contribute
|
||||
---------------------------
|
||||
|
||||
1. Fork it
|
||||
2. Create your feature branch (git checkout -b my-new-feature)
|
||||
3. Commit your changes (git commit -am 'Add some feature')
|
||||
4. Push to the branch (git push origin my-new-feature)
|
||||
5. Create new Pull Request
|
||||
|
||||
My English is terrible, so documentation or correcting comments are also
|
||||
welcome.
|
||||
11
vendor/github.com/shirou/gopsutil/circle.yml
generated
vendored
11
vendor/github.com/shirou/gopsutil/circle.yml
generated
vendored
@@ -1,11 +0,0 @@
|
||||
machine:
|
||||
timezone:
|
||||
Asia/Tokyo
|
||||
test:
|
||||
override:
|
||||
- GOOS=linux GOARCH=amd64 go test -v ./...
|
||||
- GOOS=linux GOARCH=386 go get -v ./...
|
||||
- GOOS=linux GOARCH=arm GOARM=7 go get -v ./...
|
||||
- GOOS=freebsd GOARCH=amd64 go get -v ./...
|
||||
- GOOS=windows GOARCH=amd64 go get -v ./...
|
||||
- GOOS=darwin GOARCH=amd64 go get -v ./...
|
||||
26
vendor/github.com/shirou/gopsutil/coverall.sh
generated
vendored
26
vendor/github.com/shirou/gopsutil/coverall.sh
generated
vendored
@@ -1,26 +0,0 @@
|
||||
#/bin/sh
|
||||
|
||||
# see http://www.songmu.jp/riji/entry/2015-01-15-goveralls-multi-package.html
|
||||
|
||||
set -e
|
||||
# cleanup
|
||||
cleanup() {
|
||||
if [ $tmpprof != "" ] && [ -f $tmpprof ]; then
|
||||
rm -f $tmpprof
|
||||
fi
|
||||
exit
|
||||
}
|
||||
trap cleanup INT QUIT TERM EXIT
|
||||
|
||||
# メインの処理
|
||||
prof=${1:-".profile.cov"}
|
||||
echo "mode: count" > $prof
|
||||
gopath1=$(echo $GOPATH | cut -d: -f1)
|
||||
for pkg in $(go list ./...); do
|
||||
tmpprof=$gopath1/src/$pkg/profile.tmp
|
||||
go test -covermode=count -coverprofile=$tmpprof $pkg
|
||||
if [ -f $tmpprof ]; then
|
||||
cat $tmpprof | tail -n +2 >> $prof
|
||||
rm $tmpprof
|
||||
fi
|
||||
done
|
||||
83
vendor/github.com/shirou/gopsutil/cpu/cpu.go
generated
vendored
83
vendor/github.com/shirou/gopsutil/cpu/cpu.go
generated
vendored
@@ -2,10 +2,12 @@ package cpu
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
@@ -91,3 +93,84 @@ func (c InfoStat) String() string {
|
||||
s, _ := json.Marshal(c)
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func getAllBusy(t TimesStat) (float64, float64) {
|
||||
busy := t.User + t.System + t.Nice + t.Iowait + t.Irq +
|
||||
t.Softirq + t.Steal + t.Guest + t.GuestNice + t.Stolen
|
||||
return busy + t.Idle, busy
|
||||
}
|
||||
|
||||
func calculateBusy(t1, t2 TimesStat) float64 {
|
||||
t1All, t1Busy := getAllBusy(t1)
|
||||
t2All, t2Busy := getAllBusy(t2)
|
||||
|
||||
if t2Busy <= t1Busy {
|
||||
return 0
|
||||
}
|
||||
if t2All <= t1All {
|
||||
return 1
|
||||
}
|
||||
return (t2Busy - t1Busy) / (t2All - t1All) * 100
|
||||
}
|
||||
|
||||
func calculateAllBusy(t1, t2 []TimesStat) ([]float64, error) {
|
||||
// Make sure the CPU measurements have the same length.
|
||||
if len(t1) != len(t2) {
|
||||
return nil, fmt.Errorf(
|
||||
"received two CPU counts: %d != %d",
|
||||
len(t1), len(t2),
|
||||
)
|
||||
}
|
||||
|
||||
ret := make([]float64, len(t1))
|
||||
for i, t := range t2 {
|
||||
ret[i] = calculateBusy(t1[i], t)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
//Percent calculates the percentage of cpu used either per CPU or combined.
|
||||
//If an interval of 0 is given it will compare the current cpu times against the last call.
|
||||
func Percent(interval time.Duration, percpu bool) ([]float64, error) {
|
||||
if interval <= 0 {
|
||||
return percentUsedFromLastCall(percpu)
|
||||
}
|
||||
|
||||
// Get CPU usage at the start of the interval.
|
||||
cpuTimes1, err := Times(percpu)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
time.Sleep(interval)
|
||||
|
||||
// And at the end of the interval.
|
||||
cpuTimes2, err := Times(percpu)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return calculateAllBusy(cpuTimes1, cpuTimes2)
|
||||
}
|
||||
|
||||
func percentUsedFromLastCall(percpu bool) ([]float64, error) {
|
||||
cpuTimes, err := Times(percpu)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lastCPUPercent.Lock()
|
||||
defer lastCPUPercent.Unlock()
|
||||
var lastTimes []TimesStat
|
||||
if percpu {
|
||||
lastTimes = lastCPUPercent.lastPerCPUTimes
|
||||
lastCPUPercent.lastPerCPUTimes = cpuTimes
|
||||
} else {
|
||||
lastTimes = lastCPUPercent.lastCPUTimes
|
||||
lastCPUPercent.lastCPUTimes = cpuTimes
|
||||
}
|
||||
|
||||
if lastTimes == nil {
|
||||
return nil, fmt.Errorf("Error getting times for cpu percent. LastTimes was nil")
|
||||
}
|
||||
return calculateAllBusy(lastTimes, cpuTimes)
|
||||
}
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go
generated
vendored
@@ -57,7 +57,7 @@ func perCPUTimes() ([]TimesStat, error) {
|
||||
// copy the cpuload array to a []byte buffer
|
||||
// where we can binary.Read the data
|
||||
size := int(ncpu) * binary.Size(cpu_ticks)
|
||||
buf := C.GoBytes(unsafe.Pointer(cpuload), C.int(size))
|
||||
buf := (*[1 << 30]byte)(unsafe.Pointer(cpuload))[:size:size]
|
||||
|
||||
bbuf := bytes.NewBuffer(buf)
|
||||
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/cpu/cpu_fallback.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/cpu/cpu_fallback.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build !darwin,!linux,!freebsd,!windows
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
||||
|
||||
package cpu
|
||||
|
||||
|
||||
49
vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd.go
generated
vendored
49
vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd.go
generated
vendored
@@ -21,6 +21,12 @@ const (
|
||||
)
|
||||
|
||||
var ClocksPerSec = float64(128)
|
||||
var cpuMatch = regexp.MustCompile(`^CPU:`)
|
||||
var originMatch = regexp.MustCompile(`Origin\s*=\s*"(.+)"\s+Id\s*=\s*(.+)\s+Family\s*=\s*(.+)\s+Model\s*=\s*(.+)\s+Stepping\s*=\s*(.+)`)
|
||||
var featuresMatch = regexp.MustCompile(`Features=.+<(.+)>`)
|
||||
var featuresMatch2 = regexp.MustCompile(`Features2=[a-f\dx]+<(.+)>`)
|
||||
var cpuEnd = regexp.MustCompile(`^Trying to mount root`)
|
||||
var cpuCores = regexp.MustCompile(`FreeBSD/SMP: (\d*) package\(s\) x (\d*) core\(s\)`)
|
||||
|
||||
func init() {
|
||||
getconf, err := exec.LookPath("/usr/bin/getconf")
|
||||
@@ -102,18 +108,18 @@ func Times(percpu bool) ([]TimesStat, error) {
|
||||
// are the same across CPUs.
|
||||
func Info() ([]InfoStat, error) {
|
||||
const dmesgBoot = "/var/run/dmesg.boot"
|
||||
lines, _ := common.ReadLines(dmesgBoot)
|
||||
|
||||
c := InfoStat{}
|
||||
c, num, err := parseDmesgBoot(dmesgBoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var vals []string
|
||||
var err error
|
||||
if vals, err = common.DoSysctrl("hw.clockrate"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if c.Mhz, err = strconv.ParseFloat(vals[0], 64); err != nil {
|
||||
return nil, fmt.Errorf("Unable to parse FreeBSD CPU clock rate: %v", err)
|
||||
}
|
||||
c.CPU = int32(c.Mhz)
|
||||
|
||||
if vals, err = common.DoSysctrl("hw.ncpu"); err != nil {
|
||||
return nil, err
|
||||
@@ -129,26 +135,51 @@ func Info() ([]InfoStat, error) {
|
||||
}
|
||||
c.ModelName = strings.Join(vals, " ")
|
||||
|
||||
ret := make([]InfoStat, num)
|
||||
for i := 0; i < num; i++ {
|
||||
ret[i] = c
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func parseDmesgBoot(fileName string) (InfoStat, int, error) {
|
||||
c := InfoStat{}
|
||||
lines, _ := common.ReadLines(fileName)
|
||||
var cpuNum int
|
||||
for _, line := range lines {
|
||||
if matches := regexp.MustCompile(`Origin\s*=\s*"(.+)"\s+Id\s*=\s*(.+)\s+Family\s*=\s*(.+)\s+Model\s*=\s*(.+)\s+Stepping\s*=\s*(.+)`).FindStringSubmatch(line); matches != nil {
|
||||
if matches := cpuEnd.FindStringSubmatch(line); matches != nil {
|
||||
break
|
||||
} else if matches := originMatch.FindStringSubmatch(line); matches != nil {
|
||||
c.VendorID = matches[1]
|
||||
c.Family = matches[3]
|
||||
c.Model = matches[4]
|
||||
t, err := strconv.ParseInt(matches[5], 10, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to parse FreeBSD CPU stepping information from %q: %v", line, err)
|
||||
return c, 0, fmt.Errorf("Unable to parse FreeBSD CPU stepping information from %q: %v", line, err)
|
||||
}
|
||||
c.Stepping = int32(t)
|
||||
} else if matches := regexp.MustCompile(`Features=.+<(.+)>`).FindStringSubmatch(line); matches != nil {
|
||||
} else if matches := featuresMatch.FindStringSubmatch(line); matches != nil {
|
||||
for _, v := range strings.Split(matches[1], ",") {
|
||||
c.Flags = append(c.Flags, strings.ToLower(v))
|
||||
}
|
||||
} else if matches := regexp.MustCompile(`Features2=[a-f\dx]+<(.+)>`).FindStringSubmatch(line); matches != nil {
|
||||
} else if matches := featuresMatch2.FindStringSubmatch(line); matches != nil {
|
||||
for _, v := range strings.Split(matches[1], ",") {
|
||||
c.Flags = append(c.Flags, strings.ToLower(v))
|
||||
}
|
||||
} else if matches := cpuCores.FindStringSubmatch(line); matches != nil {
|
||||
t, err := strconv.ParseInt(matches[1], 10, 32)
|
||||
if err != nil {
|
||||
return c, 0, fmt.Errorf("Unable to parse FreeBSD CPU Nums from %q: %v", line, err)
|
||||
}
|
||||
cpuNum = int(t)
|
||||
t2, err := strconv.ParseInt(matches[2], 10, 32)
|
||||
if err != nil {
|
||||
return c, 0, fmt.Errorf("Unable to parse FreeBSD CPU cores from %q: %v", line, err)
|
||||
}
|
||||
c.Cores = int32(t2)
|
||||
}
|
||||
}
|
||||
|
||||
return []InfoStat{c}, nil
|
||||
return c, cpuNum, nil
|
||||
}
|
||||
|
||||
27
vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go
generated
vendored
27
vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go
generated
vendored
@@ -36,6 +36,9 @@ func Times(percpu bool) ([]TimesStat, error) {
|
||||
var startIdx uint = 1
|
||||
for {
|
||||
linen, _ := common.ReadLinesOffsetN(filename, startIdx, 1)
|
||||
if len(linen) == 0 {
|
||||
break
|
||||
}
|
||||
line := linen[0]
|
||||
if !strings.HasPrefix(line, "cpu") {
|
||||
break
|
||||
@@ -97,7 +100,7 @@ func finishCPUInfo(c *InfoStat) error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
c.Mhz = value/1000.0 // value is in kHz
|
||||
c.Mhz = value / 1000.0 // value is in kHz
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -144,17 +147,29 @@ func Info() ([]InfoStat, error) {
|
||||
c.Family = value
|
||||
case "model":
|
||||
c.Model = value
|
||||
case "model name":
|
||||
case "model name", "cpu":
|
||||
c.ModelName = value
|
||||
case "stepping":
|
||||
t, err := strconv.ParseInt(value, 10, 64)
|
||||
if strings.Contains(value, "POWER8") ||
|
||||
strings.Contains(value, "POWER7") {
|
||||
c.Model = strings.Split(value, " ")[0]
|
||||
c.Family = "POWER"
|
||||
c.VendorID = "IBM"
|
||||
}
|
||||
case "stepping", "revision":
|
||||
val := value
|
||||
|
||||
if key == "revision" {
|
||||
val = strings.Split(value, ".")[0]
|
||||
}
|
||||
|
||||
t, err := strconv.ParseInt(val, 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
c.Stepping = int32(t)
|
||||
case "cpu MHz":
|
||||
case "cpu MHz", "clock":
|
||||
// treat this as the fallback value, thus we ignore error
|
||||
if t, err := strconv.ParseFloat(value, 64); err == nil {
|
||||
if t, err := strconv.ParseFloat(strings.Replace(value, "MHz", "", 1), 64); err == nil {
|
||||
c.Mhz = t
|
||||
}
|
||||
case "cache size":
|
||||
|
||||
110
vendor/github.com/shirou/gopsutil/cpu/cpu_openbsd.go
generated
vendored
Normal file
110
vendor/github.com/shirou/gopsutil/cpu/cpu_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
// +build openbsd
|
||||
|
||||
package cpu
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
// sys/sched.h
|
||||
const (
|
||||
CPUser = 0
|
||||
CPNice = 1
|
||||
CPSys = 2
|
||||
CPIntr = 3
|
||||
CPIdle = 4
|
||||
CPUStates = 5
|
||||
)
|
||||
|
||||
// sys/sysctl.h
|
||||
const (
|
||||
CTLKern = 1 // "high kernel": proc, limits
|
||||
KernCptime = 40 // KERN_CPTIME
|
||||
KernCptime2 = 71 // KERN_CPTIME2
|
||||
)
|
||||
|
||||
var ClocksPerSec = float64(128)
|
||||
|
||||
func init() {
|
||||
getconf, err := exec.LookPath("/usr/bin/getconf")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
out, err := invoke.Command(getconf, "CLK_TCK")
|
||||
// ignore errors
|
||||
if err == nil {
|
||||
i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
|
||||
if err == nil {
|
||||
ClocksPerSec = float64(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Times(percpu bool) ([]TimesStat, error) {
|
||||
var ret []TimesStat
|
||||
|
||||
var ncpu int
|
||||
if percpu {
|
||||
ncpu, _ = Counts(true)
|
||||
} else {
|
||||
ncpu = 1
|
||||
}
|
||||
|
||||
for i := 0; i < ncpu; i++ {
|
||||
var cpuTimes [CPUStates]int64
|
||||
var mib []int32
|
||||
if percpu {
|
||||
mib = []int32{CTLKern, KernCptime}
|
||||
} else {
|
||||
mib = []int32{CTLKern, KernCptime2, int32(i)}
|
||||
}
|
||||
buf, _, err := common.CallSyscall(mib)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
br := bytes.NewReader(buf)
|
||||
err = binary.Read(br, binary.LittleEndian, &cpuTimes)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
c := TimesStat{
|
||||
User: float64(cpuTimes[CPUser]) / ClocksPerSec,
|
||||
Nice: float64(cpuTimes[CPNice]) / ClocksPerSec,
|
||||
System: float64(cpuTimes[CPSys]) / ClocksPerSec,
|
||||
Idle: float64(cpuTimes[CPIdle]) / ClocksPerSec,
|
||||
Irq: float64(cpuTimes[CPIntr]) / ClocksPerSec,
|
||||
}
|
||||
if !percpu {
|
||||
c.CPU = "cpu-total"
|
||||
} else {
|
||||
c.CPU = fmt.Sprintf("cpu%d", i)
|
||||
}
|
||||
ret = append(ret, c)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Returns only one (minimal) CPUInfoStat on OpenBSD
|
||||
func Info() ([]InfoStat, error) {
|
||||
var ret []InfoStat
|
||||
|
||||
c := InfoStat{}
|
||||
|
||||
v, err := syscall.Sysctl("hw.model")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.ModelName = v
|
||||
|
||||
return append(ret, c), nil
|
||||
}
|
||||
90
vendor/github.com/shirou/gopsutil/cpu/cpu_unix.go
generated
vendored
90
vendor/github.com/shirou/gopsutil/cpu/cpu_unix.go
generated
vendored
@@ -1,90 +0,0 @@
|
||||
// +build linux freebsd darwin
|
||||
|
||||
package cpu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func getAllBusy(t TimesStat) (float64, float64) {
|
||||
busy := t.User + t.System + t.Nice + t.Iowait + t.Irq +
|
||||
t.Softirq + t.Steal + t.Guest + t.GuestNice + t.Stolen
|
||||
return busy + t.Idle, busy
|
||||
}
|
||||
|
||||
func calculateBusy(t1, t2 TimesStat) float64 {
|
||||
t1All, t1Busy := getAllBusy(t1)
|
||||
t2All, t2Busy := getAllBusy(t2)
|
||||
|
||||
if t2Busy <= t1Busy {
|
||||
return 0
|
||||
}
|
||||
if t2All <= t1All {
|
||||
return 1
|
||||
}
|
||||
return (t2Busy - t1Busy) / (t2All - t1All) * 100
|
||||
}
|
||||
|
||||
func calculateAllBusy(t1, t2 []TimesStat) ([]float64, error) {
|
||||
// Make sure the CPU measurements have the same length.
|
||||
if len(t1) != len(t2) {
|
||||
return nil, fmt.Errorf(
|
||||
"received two CPU counts: %d != %d",
|
||||
len(t1), len(t2),
|
||||
)
|
||||
}
|
||||
|
||||
ret := make([]float64, len(t1))
|
||||
for i, t := range t2 {
|
||||
ret[i] = calculateBusy(t1[i], t)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
//Percent calculates the percentage of cpu used either per CPU or combined.
|
||||
//If an interval of 0 is given it will compare the current cpu times against the last call.
|
||||
func Percent(interval time.Duration, percpu bool) ([]float64, error) {
|
||||
if interval <= 0 {
|
||||
return percentUsedFromLastCall(percpu)
|
||||
}
|
||||
|
||||
// Get CPU usage at the start of the interval.
|
||||
cpuTimes1, err := Times(percpu)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
time.Sleep(interval)
|
||||
|
||||
// And at the end of the interval.
|
||||
cpuTimes2, err := Times(percpu)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return calculateAllBusy(cpuTimes1, cpuTimes2)
|
||||
}
|
||||
|
||||
func percentUsedFromLastCall(percpu bool) ([]float64, error) {
|
||||
cpuTimes, err := Times(percpu)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lastCPUPercent.Lock()
|
||||
defer lastCPUPercent.Unlock()
|
||||
var lastTimes []TimesStat
|
||||
if percpu {
|
||||
lastTimes = lastCPUPercent.lastPerCPUTimes
|
||||
lastCPUPercent.lastPerCPUTimes = cpuTimes
|
||||
} else {
|
||||
lastTimes = lastCPUPercent.lastCPUTimes
|
||||
lastCPUPercent.lastCPUTimes = cpuTimes
|
||||
}
|
||||
|
||||
if lastTimes == nil {
|
||||
return nil, fmt.Errorf("Error getting times for cpu percent. LastTimes was nil")
|
||||
}
|
||||
return calculateAllBusy(lastTimes, cpuTimes)
|
||||
|
||||
}
|
||||
19
vendor/github.com/shirou/gopsutil/cpu/cpu_windows.go
generated
vendored
19
vendor/github.com/shirou/gopsutil/cpu/cpu_windows.go
generated
vendored
@@ -5,7 +5,6 @@ package cpu
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/StackExchange/wmi"
|
||||
@@ -85,21 +84,3 @@ func Info() ([]InfoStat, error) {
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func Percent(interval time.Duration, percpu bool) ([]float64, error) {
|
||||
var ret []float64
|
||||
var dst []Win32_Processor
|
||||
q := wmi.CreateQuery(&dst, "")
|
||||
err := wmi.Query(q, &dst)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
for _, l := range dst {
|
||||
// use range but windows can only get one percent.
|
||||
if l.LoadPercentage == nil {
|
||||
continue
|
||||
}
|
||||
ret = append(ret, float64(*l.LoadPercentage))
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
1
vendor/github.com/shirou/gopsutil/disk/disk.go
generated
vendored
1
vendor/github.com/shirou/gopsutil/disk/disk.go
generated
vendored
@@ -43,6 +43,7 @@ type IOCountersStat struct {
|
||||
WriteTime uint64 `json:"writeTime"`
|
||||
IopsInProgress uint64 `json:"iopsInProgress"`
|
||||
IoTime uint64 `json:"ioTime"`
|
||||
WeightedIO uint64 `json:"weightedIO"`
|
||||
Name string `json:"name"`
|
||||
SerialNumber string `json:"serialNumber"`
|
||||
}
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/disk/disk_fallback.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/disk/disk_fallback.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build !darwin,!linux,!freebsd,!windows
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
||||
|
||||
package disk
|
||||
|
||||
|
||||
5
vendor/github.com/shirou/gopsutil/disk/disk_linux.go
generated
vendored
5
vendor/github.com/shirou/gopsutil/disk/disk_linux.go
generated
vendored
@@ -328,6 +328,10 @@ func IOCounters() (map[string]IOCountersStat, error) {
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
weightedIO, err := strconv.ParseUint((fields[13]), 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
d := IOCountersStat{
|
||||
ReadBytes: rbytes * SectorSize,
|
||||
WriteBytes: wbytes * SectorSize,
|
||||
@@ -339,6 +343,7 @@ func IOCounters() (map[string]IOCountersStat, error) {
|
||||
WriteTime: wtime,
|
||||
IopsInProgress: iopsInProgress,
|
||||
IoTime: iotime,
|
||||
WeightedIO: weightedIO,
|
||||
}
|
||||
if d == empty {
|
||||
continue
|
||||
|
||||
158
vendor/github.com/shirou/gopsutil/disk/disk_openbsd.go
generated
vendored
Normal file
158
vendor/github.com/shirou/gopsutil/disk/disk_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
// +build openbsd
|
||||
|
||||
package disk
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"path"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
func Partitions(all bool) ([]PartitionStat, error) {
|
||||
var ret []PartitionStat
|
||||
|
||||
// get length
|
||||
count, err := syscall.Getfsstat(nil, MNT_WAIT)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
fs := make([]Statfs, count)
|
||||
_, err = Getfsstat(fs, MNT_WAIT)
|
||||
|
||||
for _, stat := range fs {
|
||||
opts := "rw"
|
||||
if stat.F_flags&MNT_RDONLY != 0 {
|
||||
opts = "ro"
|
||||
}
|
||||
if stat.F_flags&MNT_SYNCHRONOUS != 0 {
|
||||
opts += ",sync"
|
||||
}
|
||||
if stat.F_flags&MNT_NOEXEC != 0 {
|
||||
opts += ",noexec"
|
||||
}
|
||||
if stat.F_flags&MNT_NOSUID != 0 {
|
||||
opts += ",nosuid"
|
||||
}
|
||||
if stat.F_flags&MNT_NODEV != 0 {
|
||||
opts += ",nodev"
|
||||
}
|
||||
if stat.F_flags&MNT_ASYNC != 0 {
|
||||
opts += ",async"
|
||||
}
|
||||
|
||||
d := PartitionStat{
|
||||
Device: common.IntToString(stat.F_mntfromname[:]),
|
||||
Mountpoint: common.IntToString(stat.F_mntonname[:]),
|
||||
Fstype: common.IntToString(stat.F_fstypename[:]),
|
||||
Opts: opts,
|
||||
}
|
||||
if all == false {
|
||||
if !path.IsAbs(d.Device) || !common.PathExists(d.Device) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
ret = append(ret, d)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func IOCounters() (map[string]IOCountersStat, error) {
|
||||
ret := make(map[string]IOCountersStat)
|
||||
|
||||
r, err := syscall.Sysctl("hw.diskstats")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
buf := []byte(r)
|
||||
length := len(buf)
|
||||
|
||||
count := int(uint64(length) / uint64(sizeOfDiskstats))
|
||||
|
||||
// parse buf to Diskstats
|
||||
for i := 0; i < count; i++ {
|
||||
b := buf[i*sizeOfDiskstats : i*sizeOfDiskstats+sizeOfDiskstats]
|
||||
d, err := parseDiskstats(b)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
name := common.IntToString(d.Name[:])
|
||||
|
||||
ds := IOCountersStat{
|
||||
ReadCount: d.Rxfer,
|
||||
WriteCount: d.Wxfer,
|
||||
ReadBytes: d.Rbytes,
|
||||
WriteBytes: d.Wbytes,
|
||||
Name: name,
|
||||
}
|
||||
ret[name] = ds
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// BT2LD(time) ((long double)(time).sec + (time).frac * BINTIME_SCALE)
|
||||
|
||||
// Getfsstat is borrowed from pkg/syscall/syscall_freebsd.go
|
||||
// change Statfs_t to Statfs in order to get more information
|
||||
func Getfsstat(buf []Statfs, flags int) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
var bufsize uintptr
|
||||
if len(buf) > 0 {
|
||||
_p0 = unsafe.Pointer(&buf[0])
|
||||
bufsize = unsafe.Sizeof(Statfs{}) * uintptr(len(buf))
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall(syscall.SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func parseDiskstats(buf []byte) (Diskstats, error) {
|
||||
var ds Diskstats
|
||||
br := bytes.NewReader(buf)
|
||||
// err := binary.Read(br, binary.LittleEndian, &ds)
|
||||
err := common.Read(br, binary.LittleEndian, &ds)
|
||||
if err != nil {
|
||||
return ds, err
|
||||
}
|
||||
|
||||
return ds, nil
|
||||
}
|
||||
|
||||
func Usage(path string) (*UsageStat, error) {
|
||||
stat := syscall.Statfs_t{}
|
||||
err := syscall.Statfs(path, &stat)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bsize := stat.F_bsize
|
||||
|
||||
ret := &UsageStat{
|
||||
Path: path,
|
||||
Fstype: getFsType(stat),
|
||||
Total: (uint64(stat.F_blocks) * uint64(bsize)),
|
||||
Free: (uint64(stat.F_bavail) * uint64(bsize)),
|
||||
InodesTotal: (uint64(stat.F_files)),
|
||||
InodesFree: (uint64(stat.F_ffree)),
|
||||
}
|
||||
|
||||
ret.InodesUsed = (ret.InodesTotal - ret.InodesFree)
|
||||
ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0
|
||||
ret.Used = (uint64(stat.F_blocks) - uint64(stat.F_bfree)) * uint64(bsize)
|
||||
ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func getFsType(stat syscall.Statfs_t) string {
|
||||
return common.IntToString(stat.F_fstypename[:])
|
||||
}
|
||||
91
vendor/github.com/shirou/gopsutil/disk/disk_openbsd_amd64.go
generated
vendored
Normal file
91
vendor/github.com/shirou/gopsutil/disk/disk_openbsd_amd64.go
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_openbsd.go
|
||||
|
||||
package disk
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x8
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x8
|
||||
sizeofLongLong = 0x8
|
||||
sizeofLongDouble = 0x8
|
||||
|
||||
DEVSTAT_NO_DATA = 0x00
|
||||
DEVSTAT_READ = 0x01
|
||||
DEVSTAT_WRITE = 0x02
|
||||
DEVSTAT_FREE = 0x03
|
||||
|
||||
MNT_RDONLY = 0x00000001
|
||||
MNT_SYNCHRONOUS = 0x00000002
|
||||
MNT_NOEXEC = 0x00000004
|
||||
MNT_NOSUID = 0x00000008
|
||||
MNT_NODEV = 0x00000010
|
||||
MNT_ASYNC = 0x00000040
|
||||
|
||||
MNT_WAIT = 1
|
||||
MNT_NOWAIT = 2
|
||||
MNT_LAZY = 3
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfDiskstats = 0x70
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int64
|
||||
_C_long_long int64
|
||||
_C_long_double int64
|
||||
)
|
||||
|
||||
type Statfs struct {
|
||||
F_flags uint32
|
||||
F_bsize uint32
|
||||
F_iosize uint32
|
||||
Pad_cgo_0 [4]byte
|
||||
F_blocks uint64
|
||||
F_bfree uint64
|
||||
F_bavail int64
|
||||
F_files uint64
|
||||
F_ffree uint64
|
||||
F_favail int64
|
||||
F_syncwrites uint64
|
||||
F_syncreads uint64
|
||||
F_asyncwrites uint64
|
||||
F_asyncreads uint64
|
||||
F_fsid Fsid
|
||||
F_namemax uint32
|
||||
F_owner uint32
|
||||
F_ctime uint64
|
||||
F_fstypename [16]int8
|
||||
F_mntonname [90]int8
|
||||
F_mntfromname [90]int8
|
||||
F_mntfromspec [90]int8
|
||||
Pad_cgo_1 [2]byte
|
||||
Mount_info [160]byte
|
||||
}
|
||||
type Diskstats struct {
|
||||
Name [16]int8
|
||||
Busy int32
|
||||
Pad_cgo_0 [4]byte
|
||||
Rxfer uint64
|
||||
Wxfer uint64
|
||||
Seek uint64
|
||||
Rbytes uint64
|
||||
Wbytes uint64
|
||||
Attachtime Timeval
|
||||
Timestamp Timeval
|
||||
Time Timeval
|
||||
}
|
||||
type Fsid struct {
|
||||
Val [2]int32
|
||||
}
|
||||
type Timeval struct {
|
||||
Sec int64
|
||||
Usec int64
|
||||
}
|
||||
|
||||
type Diskstat struct{}
|
||||
type Bintime struct{}
|
||||
15
vendor/github.com/shirou/gopsutil/disk/disk_unix.go
generated
vendored
15
vendor/github.com/shirou/gopsutil/disk/disk_unix.go
generated
vendored
@@ -25,10 +25,21 @@ func Usage(path string) (*UsageStat, error) {
|
||||
if ret.InodesTotal < ret.InodesFree {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
ret.InodesUsed = (ret.InodesTotal - ret.InodesFree)
|
||||
ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0
|
||||
ret.Used = (uint64(stat.Blocks) - uint64(stat.Bfree)) * uint64(bsize)
|
||||
ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0
|
||||
|
||||
if ret.InodesTotal == 0 {
|
||||
ret.InodesUsedPercent = 0
|
||||
} else {
|
||||
ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0
|
||||
}
|
||||
|
||||
if ret.Total == 0 {
|
||||
ret.UsedPercent = 0
|
||||
} else {
|
||||
ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
70
vendor/github.com/shirou/gopsutil/disk/types_openbsd.go
generated
vendored
Normal file
70
vendor/github.com/shirou/gopsutil/disk/types_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// +build ignore
|
||||
// Hand writing: _Ctype_struct___0
|
||||
|
||||
/*
|
||||
Input to cgo -godefs.
|
||||
*/
|
||||
|
||||
package disk
|
||||
|
||||
/*
|
||||
#include <sys/types.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
enum {
|
||||
sizeofPtr = sizeof(void*),
|
||||
};
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const (
|
||||
sizeofPtr = C.sizeofPtr
|
||||
sizeofShort = C.sizeof_short
|
||||
sizeofInt = C.sizeof_int
|
||||
sizeofLong = C.sizeof_long
|
||||
sizeofLongLong = C.sizeof_longlong
|
||||
sizeofLongDouble = C.sizeof_longlong
|
||||
|
||||
DEVSTAT_NO_DATA = 0x00
|
||||
DEVSTAT_READ = 0x01
|
||||
DEVSTAT_WRITE = 0x02
|
||||
DEVSTAT_FREE = 0x03
|
||||
|
||||
// from sys/mount.h
|
||||
MNT_RDONLY = 0x00000001 /* read only filesystem */
|
||||
MNT_SYNCHRONOUS = 0x00000002 /* filesystem written synchronously */
|
||||
MNT_NOEXEC = 0x00000004 /* can't exec from filesystem */
|
||||
MNT_NOSUID = 0x00000008 /* don't honor setuid bits on fs */
|
||||
MNT_NODEV = 0x00000010 /* don't interpret special files */
|
||||
MNT_ASYNC = 0x00000040 /* filesystem written asynchronously */
|
||||
|
||||
MNT_WAIT = 1 /* synchronously wait for I/O to complete */
|
||||
MNT_NOWAIT = 2 /* start all I/O, but do not wait for it */
|
||||
MNT_LAZY = 3 /* push data not written by filesystem syncer */
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfDiskstats = C.sizeof_struct_diskstats
|
||||
)
|
||||
|
||||
// Basic types
|
||||
|
||||
type (
|
||||
_C_short C.short
|
||||
_C_int C.int
|
||||
_C_long C.long
|
||||
_C_long_long C.longlong
|
||||
_C_long_double C.longlong
|
||||
)
|
||||
|
||||
type Statfs C.struct_statfs
|
||||
type Diskstats C.struct_diskstats
|
||||
type Fsid C.fsid_t
|
||||
type Timeval C.struct_timeval
|
||||
|
||||
type Diskstat C.struct_diskstat
|
||||
type Bintime C.struct_bintime
|
||||
1
vendor/github.com/shirou/gopsutil/doc.go
generated
vendored
1
vendor/github.com/shirou/gopsutil/doc.go
generated
vendored
@@ -1 +0,0 @@
|
||||
package gopsutil
|
||||
5
vendor/github.com/shirou/gopsutil/host/host.go
generated
vendored
5
vendor/github.com/shirou/gopsutil/host/host.go
generated
vendored
@@ -6,7 +6,10 @@ import (
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
var invoke common.Invoker
|
||||
var (
|
||||
invoke common.Invoker
|
||||
cachedBootTime = uint64(0)
|
||||
)
|
||||
|
||||
func init() {
|
||||
invoke = common.Invoke{}
|
||||
|
||||
27
vendor/github.com/shirou/gopsutil/host/host_darwin.go
generated
vendored
27
vendor/github.com/shirou/gopsutil/host/host_darwin.go
generated
vendored
@@ -32,11 +32,11 @@ func Info() (*InfoStat, error) {
|
||||
ret.Hostname = hostname
|
||||
}
|
||||
|
||||
platform, family, version, err := PlatformInformation()
|
||||
platform, family, pver, version, err := PlatformInformation()
|
||||
if err == nil {
|
||||
ret.Platform = platform
|
||||
ret.PlatformFamily = family
|
||||
ret.PlatformVersion = version
|
||||
ret.PlatformVersion = pver
|
||||
ret.KernelVersion = version
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ func Info() (*InfoStat, error) {
|
||||
}
|
||||
|
||||
func BootTime() (uint64, error) {
|
||||
if cachedBootTime != 0 {
|
||||
return cachedBootTime, nil
|
||||
}
|
||||
values, err := common.DoSysctrl("kern.boottime")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -76,8 +79,9 @@ func BootTime() (uint64, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
cachedBootTime = uint64(boottime)
|
||||
|
||||
return uint64(boottime), nil
|
||||
return cachedBootTime, nil
|
||||
}
|
||||
|
||||
func uptime(boot uint64) uint64 {
|
||||
@@ -135,26 +139,37 @@ func Users() ([]UserStat, error) {
|
||||
|
||||
}
|
||||
|
||||
func PlatformInformation() (string, string, string, error) {
|
||||
func PlatformInformation() (string, string, string, string, error) {
|
||||
platform := ""
|
||||
family := ""
|
||||
version := ""
|
||||
pver := ""
|
||||
|
||||
sw_vers, err := exec.LookPath("sw_vers")
|
||||
if err != nil {
|
||||
return "", "", "", "", err
|
||||
}
|
||||
uname, err := exec.LookPath("uname")
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
return "", "", "", "", err
|
||||
}
|
||||
|
||||
out, err := invoke.Command(uname, "-s")
|
||||
if err == nil {
|
||||
platform = strings.ToLower(strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
out, err = invoke.Command(sw_vers, "-productVersion")
|
||||
if err == nil {
|
||||
pver = strings.ToLower(strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
out, err = invoke.Command(uname, "-r")
|
||||
if err == nil {
|
||||
version = strings.ToLower(strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
return platform, family, version, nil
|
||||
return platform, family, pver, version, nil
|
||||
}
|
||||
|
||||
func Virtualization() (string, string, error) {
|
||||
|
||||
19
vendor/github.com/shirou/gopsutil/host/host_darwin_386.go
generated
vendored
Normal file
19
vendor/github.com/shirou/gopsutil/host/host_darwin_386.go
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_darwin.go
|
||||
|
||||
package host
|
||||
|
||||
type Utmpx struct {
|
||||
User [256]int8
|
||||
ID [4]int8
|
||||
Line [32]int8
|
||||
Pid int32
|
||||
Type int16
|
||||
Pad_cgo_0 [6]byte
|
||||
Tv Timeval
|
||||
Host [256]int8
|
||||
Pad [16]uint32
|
||||
}
|
||||
type Timeval struct {
|
||||
Sec int32
|
||||
}
|
||||
2
vendor/github.com/shirou/gopsutil/host/host_fallback.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/host/host_fallback.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build !darwin,!linux,!freebsd,!windows
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
||||
|
||||
package host
|
||||
|
||||
|
||||
4
vendor/github.com/shirou/gopsutil/host/host_freebsd.go
generated
vendored
4
vendor/github.com/shirou/gopsutil/host/host_freebsd.go
generated
vendored
@@ -69,6 +69,9 @@ func Info() (*InfoStat, error) {
|
||||
}
|
||||
|
||||
func BootTime() (uint64, error) {
|
||||
if cachedBootTime != 0 {
|
||||
return cachedBootTime, nil
|
||||
}
|
||||
values, err := common.DoSysctrl("kern.boottime")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -80,6 +83,7 @@ func BootTime() (uint64, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
cachedBootTime = boottime
|
||||
|
||||
return boottime, nil
|
||||
}
|
||||
|
||||
44
vendor/github.com/shirou/gopsutil/host/host_freebsd_arm.go
generated
vendored
Normal file
44
vendor/github.com/shirou/gopsutil/host/host_freebsd_arm.go
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_freebsd.go
|
||||
|
||||
package host
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x4
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x8
|
||||
sizeofLongLong = 0x8
|
||||
sizeOfUtmpx = 197 // TODO: why should 197, not 0x118
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int32
|
||||
_C_long_long int64
|
||||
)
|
||||
|
||||
type Utmp struct {
|
||||
Line [8]int8
|
||||
Name [16]int8
|
||||
Host [16]int8
|
||||
Time int32
|
||||
}
|
||||
|
||||
type Utmpx struct {
|
||||
Type int16
|
||||
Tv Timeval
|
||||
Id [8]int8
|
||||
Pid int32
|
||||
User [32]int8
|
||||
Line [16]int8
|
||||
Host [125]int8
|
||||
// Host [128]int8
|
||||
// X__ut_spare [64]int8
|
||||
}
|
||||
|
||||
type Timeval struct {
|
||||
Sec [4]byte
|
||||
Usec [3]byte
|
||||
}
|
||||
6
vendor/github.com/shirou/gopsutil/host/host_linux.go
generated
vendored
6
vendor/github.com/shirou/gopsutil/host/host_linux.go
generated
vendored
@@ -86,6 +86,9 @@ func Info() (*InfoStat, error) {
|
||||
|
||||
// BootTime returns the system boot time expressed in seconds since the epoch.
|
||||
func BootTime() (uint64, error) {
|
||||
if cachedBootTime != 0 {
|
||||
return cachedBootTime, nil
|
||||
}
|
||||
filename := common.HostProc("stat")
|
||||
lines, err := common.ReadLines(filename)
|
||||
if err != nil {
|
||||
@@ -101,7 +104,8 @@ func BootTime() (uint64, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint64(b), nil
|
||||
cachedBootTime = uint64(b)
|
||||
return cachedBootTime, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
45
vendor/github.com/shirou/gopsutil/host/host_linux_s390x.go
generated
vendored
Normal file
45
vendor/github.com/shirou/gopsutil/host/host_linux_s390x.go
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// +build linux
|
||||
// +build s390x
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_linux.go
|
||||
|
||||
package host
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x8
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x8
|
||||
sizeofLongLong = 0x8
|
||||
sizeOfUtmp = 0x180
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int64
|
||||
_C_long_long int64
|
||||
)
|
||||
|
||||
type utmp struct {
|
||||
Type int16
|
||||
Pad_cgo_0 [2]byte
|
||||
Pid int32
|
||||
Line [32]int8
|
||||
Id [4]int8
|
||||
User [32]int8
|
||||
Host [256]int8
|
||||
Exit exit_status
|
||||
Session int32
|
||||
Tv timeval
|
||||
Addr_v6 [4]int32
|
||||
X__glibc_reserved [20]int8
|
||||
}
|
||||
type exit_status struct {
|
||||
Termination int16
|
||||
Exit int16
|
||||
}
|
||||
type timeval struct {
|
||||
Sec int64
|
||||
Usec int64
|
||||
}
|
||||
154
vendor/github.com/shirou/gopsutil/host/host_openbsd.go
generated
vendored
Normal file
154
vendor/github.com/shirou/gopsutil/host/host_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
// +build openbsd
|
||||
|
||||
package host
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
"github.com/shirou/gopsutil/process"
|
||||
)
|
||||
|
||||
const (
|
||||
UTNameSize = 32 /* see MAXLOGNAME in <sys/param.h> */
|
||||
UTLineSize = 8
|
||||
UTHostSize = 16
|
||||
)
|
||||
|
||||
func Info() (*InfoStat, error) {
|
||||
ret := &InfoStat{
|
||||
OS: runtime.GOOS,
|
||||
PlatformFamily: "openbsd",
|
||||
}
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err == nil {
|
||||
ret.Hostname = hostname
|
||||
}
|
||||
|
||||
platform, family, version, err := PlatformInformation()
|
||||
if err == nil {
|
||||
ret.Platform = platform
|
||||
ret.PlatformFamily = family
|
||||
ret.PlatformVersion = version
|
||||
}
|
||||
system, role, err := Virtualization()
|
||||
if err == nil {
|
||||
ret.VirtualizationSystem = system
|
||||
ret.VirtualizationRole = role
|
||||
}
|
||||
|
||||
procs, err := process.Pids()
|
||||
if err == nil {
|
||||
ret.Procs = uint64(len(procs))
|
||||
}
|
||||
|
||||
boot, err := BootTime()
|
||||
if err == nil {
|
||||
ret.BootTime = boot
|
||||
ret.Uptime = uptime(boot)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func BootTime() (uint64, error) {
|
||||
val, err := common.DoSysctrl("kern.boottime")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
boottime, err := strconv.ParseUint(val[0], 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return boottime, nil
|
||||
}
|
||||
|
||||
func uptime(boot uint64) uint64 {
|
||||
return uint64(time.Now().Unix()) - boot
|
||||
}
|
||||
|
||||
func Uptime() (uint64, error) {
|
||||
boot, err := BootTime()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uptime(boot), nil
|
||||
}
|
||||
|
||||
func PlatformInformation() (string, string, string, error) {
|
||||
platform := ""
|
||||
family := ""
|
||||
version := ""
|
||||
uname, err := exec.LookPath("uname")
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
||||
out, err := invoke.Command(uname, "-s")
|
||||
if err == nil {
|
||||
platform = strings.ToLower(strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
out, err = invoke.Command(uname, "-r")
|
||||
if err == nil {
|
||||
version = strings.ToLower(strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
return platform, family, version, nil
|
||||
}
|
||||
|
||||
func Virtualization() (string, string, error) {
|
||||
system := ""
|
||||
role := ""
|
||||
|
||||
return system, role, nil
|
||||
}
|
||||
|
||||
func Users() ([]UserStat, error) {
|
||||
var ret []UserStat
|
||||
utmpfile := "/var/run/utmp"
|
||||
file, err := os.Open(utmpfile)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
buf, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
u := Utmp{}
|
||||
entrySize := int(unsafe.Sizeof(u))
|
||||
count := len(buf) / entrySize
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
b := buf[i*entrySize : i*entrySize+entrySize]
|
||||
var u Utmp
|
||||
br := bytes.NewReader(b)
|
||||
err := binary.Read(br, binary.LittleEndian, &u)
|
||||
if err != nil || u.Time == 0 {
|
||||
continue
|
||||
}
|
||||
user := UserStat{
|
||||
User: common.IntToString(u.Name[:]),
|
||||
Terminal: common.IntToString(u.Line[:]),
|
||||
Host: common.IntToString(u.Host[:]),
|
||||
Started: int(u.Time),
|
||||
}
|
||||
|
||||
ret = append(ret, user)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
31
vendor/github.com/shirou/gopsutil/host/host_openbsd_amd64.go
generated
vendored
Normal file
31
vendor/github.com/shirou/gopsutil/host/host_openbsd_amd64.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_openbsd.go
|
||||
|
||||
package host
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x8
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x8
|
||||
sizeofLongLong = 0x8
|
||||
sizeOfUtmp = 0x130
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int64
|
||||
_C_long_long int64
|
||||
)
|
||||
|
||||
type Utmp struct {
|
||||
Line [8]int8
|
||||
Name [32]int8
|
||||
Host [256]int8
|
||||
Time int64
|
||||
}
|
||||
type Timeval struct {
|
||||
Sec int64
|
||||
Usec int64
|
||||
}
|
||||
6
vendor/github.com/shirou/gopsutil/host/host_windows.go
generated
vendored
6
vendor/github.com/shirou/gopsutil/host/host_windows.go
generated
vendored
@@ -91,11 +91,15 @@ func bootTime(up uint64) uint64 {
|
||||
}
|
||||
|
||||
func BootTime() (uint64, error) {
|
||||
if cachedBootTime != 0 {
|
||||
return cachedBootTime, nil
|
||||
}
|
||||
up, err := Uptime()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return bootTime(up), nil
|
||||
cachedBootTime = bootTime(up)
|
||||
return cachedBootTime, nil
|
||||
}
|
||||
|
||||
func PlatformInformation() (platform string, family string, version string, err error) {
|
||||
|
||||
43
vendor/github.com/shirou/gopsutil/host/types_openbsd.go
generated
vendored
Normal file
43
vendor/github.com/shirou/gopsutil/host/types_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// +build ignore
|
||||
|
||||
/*
|
||||
Input to cgo -godefs.
|
||||
*/
|
||||
|
||||
package host
|
||||
|
||||
/*
|
||||
#define KERNEL
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <utmp.h>
|
||||
|
||||
enum {
|
||||
sizeofPtr = sizeof(void*),
|
||||
};
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const (
|
||||
sizeofPtr = C.sizeofPtr
|
||||
sizeofShort = C.sizeof_short
|
||||
sizeofInt = C.sizeof_int
|
||||
sizeofLong = C.sizeof_long
|
||||
sizeofLongLong = C.sizeof_longlong
|
||||
sizeOfUtmp = C.sizeof_struct_utmp
|
||||
)
|
||||
|
||||
// Basic types
|
||||
|
||||
type (
|
||||
_C_short C.short
|
||||
_C_int C.int
|
||||
_C_long C.long
|
||||
_C_long_long C.longlong
|
||||
)
|
||||
|
||||
type Utmp C.struct_utmp
|
||||
type Timeval C.struct_timeval
|
||||
43
vendor/github.com/shirou/gopsutil/internal/common/common.go
generated
vendored
43
vendor/github.com/shirou/gopsutil/internal/common/common.go
generated
vendored
@@ -341,3 +341,46 @@ func WaitTimeout(c *exec.Cmd, timeout time.Duration) error {
|
||||
return ErrTimeout
|
||||
}
|
||||
}
|
||||
|
||||
// https://gist.github.com/kylelemons/1525278
|
||||
func Pipeline(cmds ...*exec.Cmd) ([]byte, []byte, error) {
|
||||
// Require at least one command
|
||||
if len(cmds) < 1 {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// Collect the output from the command(s)
|
||||
var output bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
last := len(cmds) - 1
|
||||
for i, cmd := range cmds[:last] {
|
||||
var err error
|
||||
// Connect each command's stdin to the previous command's stdout
|
||||
if cmds[i+1].Stdin, err = cmd.StdoutPipe(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// Connect each command's stderr to a buffer
|
||||
cmd.Stderr = &stderr
|
||||
}
|
||||
|
||||
// Connect the output and error for the last command
|
||||
cmds[last].Stdout, cmds[last].Stderr = &output, &stderr
|
||||
|
||||
// Start each command
|
||||
for _, cmd := range cmds {
|
||||
if err := cmd.Start(); err != nil {
|
||||
return output.Bytes(), stderr.Bytes(), err
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for each command to complete
|
||||
for _, cmd := range cmds {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
return output.Bytes(), stderr.Bytes(), err
|
||||
}
|
||||
}
|
||||
|
||||
// Return the pipeline output and the collected standard error
|
||||
return output.Bytes(), stderr.Bytes(), nil
|
||||
}
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build freebsd
|
||||
// +build freebsd openbsd
|
||||
|
||||
package common
|
||||
|
||||
|
||||
70
vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go
generated
vendored
Normal file
70
vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// +build openbsd
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
err := os.Setenv("LC_ALL", "C")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
sysctl, err := exec.LookPath("/sbin/sysctl")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
out, err := exec.Command(sysctl, "-n", mib).Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
v := strings.Replace(string(out), "{ ", "", 1)
|
||||
v = strings.Replace(string(v), " }", "", 1)
|
||||
values := strings.Fields(string(v))
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func CallSyscall(mib []int32) ([]byte, uint64, error) {
|
||||
mibptr := unsafe.Pointer(&mib[0])
|
||||
miblen := uint64(len(mib))
|
||||
|
||||
// get required buffer size
|
||||
length := uint64(0)
|
||||
_, _, err := syscall.Syscall6(
|
||||
syscall.SYS___SYSCTL,
|
||||
uintptr(mibptr),
|
||||
uintptr(miblen),
|
||||
0,
|
||||
uintptr(unsafe.Pointer(&length)),
|
||||
0,
|
||||
0)
|
||||
if err != 0 {
|
||||
var b []byte
|
||||
return b, length, err
|
||||
}
|
||||
if length == 0 {
|
||||
var b []byte
|
||||
return b, length, err
|
||||
}
|
||||
// get proc info itself
|
||||
buf := make([]byte, length)
|
||||
_, _, err = syscall.Syscall6(
|
||||
syscall.SYS___SYSCTL,
|
||||
uintptr(mibptr),
|
||||
uintptr(miblen),
|
||||
uintptr(unsafe.Pointer(&buf[0])),
|
||||
uintptr(unsafe.Pointer(&length)),
|
||||
0,
|
||||
0)
|
||||
if err != 0 {
|
||||
return buf, length, err
|
||||
}
|
||||
|
||||
return buf, length, nil
|
||||
}
|
||||
2
vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build linux freebsd darwin
|
||||
// +build linux freebsd darwin openbsd
|
||||
|
||||
package common
|
||||
|
||||
|
||||
4
vendor/github.com/shirou/gopsutil/mem/mem.go
generated
vendored
4
vendor/github.com/shirou/gopsutil/mem/mem.go
generated
vendored
@@ -54,6 +54,10 @@ type VirtualMemoryStat struct {
|
||||
Writeback uint64 `json:"writeback"`
|
||||
Dirty uint64 `json:"dirty"`
|
||||
WritebackTmp uint64 `json:"writebacktmp"`
|
||||
Shared uint64 `json:"shared"`
|
||||
Slab uint64 `json:"slab"`
|
||||
PageTables uint64 `json:"pagetables"`
|
||||
SwapCached uint64 `json:"swapcached"`
|
||||
}
|
||||
|
||||
type SwapMemoryStat struct {
|
||||
|
||||
8
vendor/github.com/shirou/gopsutil/mem/mem_darwin.go
generated
vendored
8
vendor/github.com/shirou/gopsutil/mem/mem_darwin.go
generated
vendored
@@ -57,11 +57,11 @@ func SwapMemory() (*SwapMemoryStat, error) {
|
||||
u = ((total_v - free_v) / total_v) * 100.0
|
||||
}
|
||||
|
||||
// vm.swapusage shows "M", multiply 1000
|
||||
// vm.swapusage shows "M", multiply 1024 * 1024 to convert bytes.
|
||||
ret = &SwapMemoryStat{
|
||||
Total: uint64(total_v * 1000),
|
||||
Used: uint64(used_v * 1000),
|
||||
Free: uint64(free_v * 1000),
|
||||
Total: uint64(total_v * 1024 * 1024),
|
||||
Used: uint64(used_v * 1024 * 1024),
|
||||
Free: uint64(free_v * 1024 * 1024),
|
||||
UsedPercent: u,
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/mem/mem_fallback.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/mem/mem_fallback.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build !darwin,!linux,!freebsd,!windows
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
||||
|
||||
package mem
|
||||
|
||||
|
||||
12
vendor/github.com/shirou/gopsutil/mem/mem_linux.go
generated
vendored
12
vendor/github.com/shirou/gopsutil/mem/mem_linux.go
generated
vendored
@@ -52,6 +52,14 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
ret.WritebackTmp = t * 1024
|
||||
case "Dirty":
|
||||
ret.Dirty = t * 1024
|
||||
case "Shmem":
|
||||
ret.Shared = t * 1024
|
||||
case "Slab":
|
||||
ret.Slab = t * 1024
|
||||
case "PageTables":
|
||||
ret.PageTables = t * 1024
|
||||
case "SwapCached":
|
||||
ret.SwapCached = t * 1024
|
||||
}
|
||||
}
|
||||
if !memavail {
|
||||
@@ -70,8 +78,8 @@ func SwapMemory() (*SwapMemoryStat, error) {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SwapMemoryStat{
|
||||
Total: uint64(sysinfo.Totalswap),
|
||||
Free: uint64(sysinfo.Freeswap),
|
||||
Total: uint64(sysinfo.Totalswap) * uint64(sysinfo.Unit),
|
||||
Free: uint64(sysinfo.Freeswap) * uint64(sysinfo.Unit),
|
||||
}
|
||||
ret.Used = ret.Total - ret.Free
|
||||
//check Infinity
|
||||
|
||||
110
vendor/github.com/shirou/gopsutil/mem/mem_openbsd.go
generated
vendored
Normal file
110
vendor/github.com/shirou/gopsutil/mem/mem_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
// +build openbsd
|
||||
|
||||
package mem
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func GetPageSize() (uint64, error) {
|
||||
mib := []int32{CTLVm, VmUvmexp}
|
||||
buf, length, err := common.CallSyscall(mib)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if length < sizeOfUvmexp {
|
||||
return 0, fmt.Errorf("short syscall ret %d bytes", length)
|
||||
}
|
||||
var uvmexp Uvmexp
|
||||
br := bytes.NewReader(buf)
|
||||
err = common.Read(br, binary.LittleEndian, &uvmexp)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint64(uvmexp.Pagesize), nil
|
||||
}
|
||||
|
||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
mib := []int32{CTLVm, VmUvmexp}
|
||||
buf, length, err := common.CallSyscall(mib)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if length < sizeOfUvmexp {
|
||||
return nil, fmt.Errorf("short syscall ret %d bytes", length)
|
||||
}
|
||||
var uvmexp Uvmexp
|
||||
br := bytes.NewReader(buf)
|
||||
err = common.Read(br, binary.LittleEndian, &uvmexp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p := uint64(uvmexp.Pagesize)
|
||||
|
||||
ret := &VirtualMemoryStat{
|
||||
Total: uint64(uvmexp.Npages) * p,
|
||||
Free: uint64(uvmexp.Free) * p,
|
||||
Active: uint64(uvmexp.Active) * p,
|
||||
Inactive: uint64(uvmexp.Inactive) * p,
|
||||
Cached: 0, // not available
|
||||
Wired: uint64(uvmexp.Wired) * p,
|
||||
}
|
||||
|
||||
ret.Available = ret.Inactive + ret.Cached + ret.Free
|
||||
ret.Used = ret.Total - ret.Available
|
||||
ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
|
||||
|
||||
mib = []int32{CTLVfs, VfsGeneric, VfsBcacheStat}
|
||||
buf, length, err = common.CallSyscall(mib)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if length < sizeOfBcachestats {
|
||||
return nil, fmt.Errorf("short syscall ret %d bytes", length)
|
||||
}
|
||||
var bcs Bcachestats
|
||||
br = bytes.NewReader(buf)
|
||||
err = common.Read(br, binary.LittleEndian, &bcs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret.Buffers = uint64(bcs.Numbufpages) * p
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Return swapctl summary info
|
||||
func SwapMemory() (*SwapMemoryStat, error) {
|
||||
swapctl, err := exec.LookPath("swapctl")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out, err := invoke.Command(swapctl, "-sk")
|
||||
if err != nil {
|
||||
return &SwapMemoryStat{}, nil
|
||||
}
|
||||
|
||||
line := string(out)
|
||||
var total, used, free uint64
|
||||
|
||||
_, err = fmt.Sscanf(line,
|
||||
"total: %d 1K-blocks allocated, %d used, %d available",
|
||||
&total, &used, &free)
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to parse swapctl output")
|
||||
}
|
||||
|
||||
percent := float64(used) / float64(total) * 100
|
||||
return &SwapMemoryStat{
|
||||
Total: total * 1024,
|
||||
Used: used * 1024,
|
||||
Free: free * 1024,
|
||||
UsedPercent: percent,
|
||||
}, nil
|
||||
}
|
||||
122
vendor/github.com/shirou/gopsutil/mem/mem_openbsd_amd64.go
generated
vendored
Normal file
122
vendor/github.com/shirou/gopsutil/mem/mem_openbsd_amd64.go
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_openbsd.go
|
||||
|
||||
package mem
|
||||
|
||||
const (
|
||||
CTLVm = 2
|
||||
CTLVfs = 10
|
||||
VmUvmexp = 4
|
||||
VfsGeneric = 0
|
||||
VfsBcacheStat = 3
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfUvmexp = 0x154
|
||||
sizeOfBcachestats = 0x78
|
||||
)
|
||||
|
||||
type Uvmexp struct {
|
||||
Pagesize int32
|
||||
Pagemask int32
|
||||
Pageshift int32
|
||||
Npages int32
|
||||
Free int32
|
||||
Active int32
|
||||
Inactive int32
|
||||
Paging int32
|
||||
Wired int32
|
||||
Zeropages int32
|
||||
Reserve_pagedaemon int32
|
||||
Reserve_kernel int32
|
||||
Anonpages int32
|
||||
Vnodepages int32
|
||||
Vtextpages int32
|
||||
Freemin int32
|
||||
Freetarg int32
|
||||
Inactarg int32
|
||||
Wiredmax int32
|
||||
Anonmin int32
|
||||
Vtextmin int32
|
||||
Vnodemin int32
|
||||
Anonminpct int32
|
||||
Vtextminpct int32
|
||||
Vnodeminpct int32
|
||||
Nswapdev int32
|
||||
Swpages int32
|
||||
Swpginuse int32
|
||||
Swpgonly int32
|
||||
Nswget int32
|
||||
Nanon int32
|
||||
Nanonneeded int32
|
||||
Nfreeanon int32
|
||||
Faults int32
|
||||
Traps int32
|
||||
Intrs int32
|
||||
Swtch int32
|
||||
Softs int32
|
||||
Syscalls int32
|
||||
Pageins int32
|
||||
Obsolete_swapins int32
|
||||
Obsolete_swapouts int32
|
||||
Pgswapin int32
|
||||
Pgswapout int32
|
||||
Forks int32
|
||||
Forks_ppwait int32
|
||||
Forks_sharevm int32
|
||||
Pga_zerohit int32
|
||||
Pga_zeromiss int32
|
||||
Zeroaborts int32
|
||||
Fltnoram int32
|
||||
Fltnoanon int32
|
||||
Fltpgwait int32
|
||||
Fltpgrele int32
|
||||
Fltrelck int32
|
||||
Fltrelckok int32
|
||||
Fltanget int32
|
||||
Fltanretry int32
|
||||
Fltamcopy int32
|
||||
Fltnamap int32
|
||||
Fltnomap int32
|
||||
Fltlget int32
|
||||
Fltget int32
|
||||
Flt_anon int32
|
||||
Flt_acow int32
|
||||
Flt_obj int32
|
||||
Flt_prcopy int32
|
||||
Flt_przero int32
|
||||
Pdwoke int32
|
||||
Pdrevs int32
|
||||
Pdswout int32
|
||||
Pdfreed int32
|
||||
Pdscans int32
|
||||
Pdanscan int32
|
||||
Pdobscan int32
|
||||
Pdreact int32
|
||||
Pdbusy int32
|
||||
Pdpageouts int32
|
||||
Pdpending int32
|
||||
Pddeact int32
|
||||
Pdreanon int32
|
||||
Pdrevnode int32
|
||||
Pdrevtext int32
|
||||
Fpswtch int32
|
||||
Kmapent int32
|
||||
}
|
||||
type Bcachestats struct {
|
||||
Numbufs int64
|
||||
Numbufpages int64
|
||||
Numdirtypages int64
|
||||
Numcleanpages int64
|
||||
Pendingwrites int64
|
||||
Pendingreads int64
|
||||
Numwrites int64
|
||||
Numreads int64
|
||||
Cachehits int64
|
||||
Busymapped int64
|
||||
Dmapages int64
|
||||
Highpages int64
|
||||
Delwribufs int64
|
||||
Kvaslots int64
|
||||
Avail int64
|
||||
}
|
||||
34
vendor/github.com/shirou/gopsutil/mem/types_openbsd.go
generated
vendored
Normal file
34
vendor/github.com/shirou/gopsutil/mem/types_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// +build ignore
|
||||
|
||||
/*
|
||||
Input to cgo -godefs.
|
||||
*/
|
||||
|
||||
package mem
|
||||
|
||||
/*
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <uvm/uvmexp.h>
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const (
|
||||
CTLVm = 2
|
||||
CTLVfs = 10
|
||||
VmUvmexp = 4 // get uvmexp
|
||||
VfsGeneric = 0
|
||||
VfsBcacheStat = 3
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfUvmexp = C.sizeof_struct_uvmexp
|
||||
sizeOfBcachestats = C.sizeof_struct_bcachestats
|
||||
)
|
||||
|
||||
type Uvmexp C.struct_uvmexp
|
||||
type Bcachestats C.struct_bcachestats
|
||||
37
vendor/github.com/shirou/gopsutil/mktypes.sh
generated
vendored
37
vendor/github.com/shirou/gopsutil/mktypes.sh
generated
vendored
@@ -1,37 +0,0 @@
|
||||
|
||||
DIRS="cpu disk docker host load mem net process"
|
||||
|
||||
GOOS=`uname | tr '[:upper:]' '[:lower:]'`
|
||||
ARCH=`uname -m`
|
||||
|
||||
case $ARCH in
|
||||
amd64)
|
||||
GOARCH="amd64"
|
||||
;;
|
||||
x86_64)
|
||||
GOARCH="amd64"
|
||||
;;
|
||||
i386)
|
||||
GOARCH="386"
|
||||
;;
|
||||
i686)
|
||||
GOARCH="386"
|
||||
;;
|
||||
arm)
|
||||
GOARCH="arm"
|
||||
;;
|
||||
*)
|
||||
echo "unknown arch: $ARCH"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
for DIR in $DIRS
|
||||
do
|
||||
if [ -e ${DIR}/types_${GOOS}.go ]; then
|
||||
echo "// +build $GOOS" > ${DIR}/${DIR}_${GOOS}_${GOARCH}.go
|
||||
echo "// +build $GOARCH" >> ${DIR}/${DIR}_${GOOS}_${GOARCH}.go
|
||||
go tool cgo -godefs ${DIR}/types_${GOOS}.go >> ${DIR}/${DIR}_${GOOS}_${GOARCH}.go
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
15
vendor/github.com/shirou/gopsutil/net/net.go
generated
vendored
15
vendor/github.com/shirou/gopsutil/net/net.go
generated
vendored
@@ -39,13 +39,14 @@ type Addr struct {
|
||||
}
|
||||
|
||||
type ConnectionStat struct {
|
||||
Fd uint32 `json:"fd"`
|
||||
Family uint32 `json:"family"`
|
||||
Type uint32 `json:"type"`
|
||||
Laddr Addr `json:"localaddr"`
|
||||
Raddr Addr `json:"remoteaddr"`
|
||||
Status string `json:"status"`
|
||||
Pid int32 `json:"pid"`
|
||||
Fd uint32 `json:"fd"`
|
||||
Family uint32 `json:"family"`
|
||||
Type uint32 `json:"type"`
|
||||
Laddr Addr `json:"localaddr"`
|
||||
Raddr Addr `json:"remoteaddr"`
|
||||
Status string `json:"status"`
|
||||
Uids []int32 `json:"uids"`
|
||||
Pid int32 `json:"pid"`
|
||||
}
|
||||
|
||||
// System wide stats about different network protocols
|
||||
|
||||
271
vendor/github.com/shirou/gopsutil/net/net_darwin.go
generated
vendored
271
vendor/github.com/shirou/gopsutil/net/net_darwin.go
generated
vendored
@@ -4,95 +4,248 @@ package net
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
// example of netstat -idbn output on yosemite
|
||||
var (
|
||||
errNetstatHeader = errors.New("Can't parse header of netstat output")
|
||||
netstatLinkRegexp = regexp.MustCompile(`^<Link#(\d+)>$`)
|
||||
)
|
||||
|
||||
const endOfLine = "\n"
|
||||
|
||||
func parseNetstatLine(line string) (stat *IOCountersStat, linkId *uint, err error) {
|
||||
var (
|
||||
numericValue uint64
|
||||
columns = strings.Fields(line)
|
||||
)
|
||||
|
||||
if columns[0] == "Name" {
|
||||
err = errNetstatHeader
|
||||
return
|
||||
}
|
||||
|
||||
// try to extract the numeric value from <Link#123>
|
||||
if subMatch := netstatLinkRegexp.FindStringSubmatch(columns[2]); len(subMatch) == 2 {
|
||||
numericValue, err = strconv.ParseUint(subMatch[1], 10, 64)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
linkIdUint := uint(numericValue)
|
||||
linkId = &linkIdUint
|
||||
}
|
||||
|
||||
base := 1
|
||||
numberColumns := len(columns)
|
||||
// sometimes Address is ommitted
|
||||
if numberColumns < 12 {
|
||||
base = 0
|
||||
}
|
||||
if numberColumns < 11 || numberColumns > 13 {
|
||||
err = fmt.Errorf("Line %q do have an invalid number of columns %d", line, numberColumns)
|
||||
return
|
||||
}
|
||||
|
||||
parsed := make([]uint64, 0, 7)
|
||||
vv := []string{
|
||||
columns[base+3], // Ipkts == PacketsRecv
|
||||
columns[base+4], // Ierrs == Errin
|
||||
columns[base+5], // Ibytes == BytesRecv
|
||||
columns[base+6], // Opkts == PacketsSent
|
||||
columns[base+7], // Oerrs == Errout
|
||||
columns[base+8], // Obytes == BytesSent
|
||||
}
|
||||
if len(columns) == 12 {
|
||||
vv = append(vv, columns[base+10])
|
||||
}
|
||||
|
||||
for _, target := range vv {
|
||||
if target == "-" {
|
||||
parsed = append(parsed, 0)
|
||||
continue
|
||||
}
|
||||
|
||||
if numericValue, err = strconv.ParseUint(target, 10, 64); err != nil {
|
||||
return
|
||||
}
|
||||
parsed = append(parsed, numericValue)
|
||||
}
|
||||
|
||||
stat = &IOCountersStat{
|
||||
Name: strings.Trim(columns[0], "*"), // remove the * that sometimes is on right on interface
|
||||
PacketsRecv: parsed[0],
|
||||
Errin: parsed[1],
|
||||
BytesRecv: parsed[2],
|
||||
PacketsSent: parsed[3],
|
||||
Errout: parsed[4],
|
||||
BytesSent: parsed[5],
|
||||
}
|
||||
if len(parsed) == 7 {
|
||||
stat.Dropout = parsed[6]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type netstatInterface struct {
|
||||
linkId *uint
|
||||
stat *IOCountersStat
|
||||
}
|
||||
|
||||
func parseNetstatOutput(output string) ([]netstatInterface, error) {
|
||||
var (
|
||||
err error
|
||||
lines = strings.Split(strings.Trim(output, endOfLine), endOfLine)
|
||||
)
|
||||
|
||||
// number of interfaces is number of lines less one for the header
|
||||
numberInterfaces := len(lines) - 1
|
||||
|
||||
interfaces := make([]netstatInterface, numberInterfaces)
|
||||
// no output beside header
|
||||
if numberInterfaces == 0 {
|
||||
return interfaces, nil
|
||||
}
|
||||
|
||||
for index := 0; index < numberInterfaces; index++ {
|
||||
nsIface := netstatInterface{}
|
||||
if nsIface.stat, nsIface.linkId, err = parseNetstatLine(lines[index+1]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
interfaces[index] = nsIface
|
||||
}
|
||||
return interfaces, nil
|
||||
}
|
||||
|
||||
// map that hold the name of a network interface and the number of usage
|
||||
type mapInterfaceNameUsage map[string]uint
|
||||
|
||||
func newMapInterfaceNameUsage(ifaces []netstatInterface) mapInterfaceNameUsage {
|
||||
output := make(mapInterfaceNameUsage)
|
||||
for index := range ifaces {
|
||||
if ifaces[index].linkId != nil {
|
||||
ifaceName := ifaces[index].stat.Name
|
||||
usage, ok := output[ifaceName]
|
||||
if ok {
|
||||
output[ifaceName] = usage + 1
|
||||
} else {
|
||||
output[ifaceName] = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
func (min mapInterfaceNameUsage) isTruncated() bool {
|
||||
for _, usage := range min {
|
||||
if usage > 1 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (min mapInterfaceNameUsage) notTruncated() []string {
|
||||
output := make([]string, 0)
|
||||
for ifaceName, usage := range min {
|
||||
if usage == 1 {
|
||||
output = append(output, ifaceName)
|
||||
}
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
// example of `netstat -ibdnW` output on yosemite
|
||||
// Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop
|
||||
// lo0 16384 <Link#1> 869107 0 169411755 869107 0 169411755 0 0
|
||||
// lo0 16384 ::1/128 ::1 869107 - 169411755 869107 - 169411755 - -
|
||||
// lo0 16384 127 127.0.0.1 869107 - 169411755 869107 - 169411755 - -
|
||||
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||
var (
|
||||
ret []IOCountersStat
|
||||
retIndex int
|
||||
)
|
||||
|
||||
netstat, err := exec.LookPath("/usr/sbin/netstat")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// try to get all interface metrics, and hope there won't be any truncated
|
||||
out, err := invoke.Command(netstat, "-ibdnW")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lines := strings.Split(string(out), "\n")
|
||||
ret := make([]IOCountersStat, 0, len(lines)-1)
|
||||
exists := make([]string, 0, len(ret))
|
||||
nsInterfaces, err := parseNetstatOutput(string(out))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, line := range lines {
|
||||
values := strings.Fields(line)
|
||||
if len(values) < 1 || values[0] == "Name" {
|
||||
// skip first line
|
||||
continue
|
||||
}
|
||||
if common.StringsHas(exists, values[0]) {
|
||||
// skip if already get
|
||||
continue
|
||||
}
|
||||
exists = append(exists, values[0])
|
||||
ifaceUsage := newMapInterfaceNameUsage(nsInterfaces)
|
||||
notTruncated := ifaceUsage.notTruncated()
|
||||
ret = make([]IOCountersStat, len(notTruncated))
|
||||
|
||||
base := 1
|
||||
// sometimes Address is ommitted
|
||||
if len(values) < 11 {
|
||||
base = 0
|
||||
}
|
||||
|
||||
parsed := make([]uint64, 0, 7)
|
||||
vv := []string{
|
||||
values[base+3], // Ipkts == PacketsRecv
|
||||
values[base+4], // Ierrs == Errin
|
||||
values[base+5], // Ibytes == BytesRecv
|
||||
values[base+6], // Opkts == PacketsSent
|
||||
values[base+7], // Oerrs == Errout
|
||||
values[base+8], // Obytes == BytesSent
|
||||
}
|
||||
if len(values) == 12 {
|
||||
vv = append(vv, values[base+10])
|
||||
}
|
||||
|
||||
for _, target := range vv {
|
||||
if target == "-" {
|
||||
parsed = append(parsed, 0)
|
||||
continue
|
||||
if !ifaceUsage.isTruncated() {
|
||||
// no truncated interface name, return stats of all interface with <Link#...>
|
||||
for index := range nsInterfaces {
|
||||
if nsInterfaces[index].linkId != nil {
|
||||
ret[retIndex] = *nsInterfaces[index].stat
|
||||
retIndex++
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// duplicated interface, list all interfaces
|
||||
ifconfig, err := exec.LookPath("/sbin/ifconfig")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out, err = invoke.Command(ifconfig, "-l"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
interfaceNames := strings.Fields(strings.TrimRight(string(out), endOfLine))
|
||||
|
||||
t, err := strconv.ParseUint(target, 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// for each of the interface name, run netstat if we don't have any stats yet
|
||||
for _, interfaceName := range interfaceNames {
|
||||
truncated := true
|
||||
for index := range nsInterfaces {
|
||||
if nsInterfaces[index].linkId != nil && nsInterfaces[index].stat.Name == interfaceName {
|
||||
// handle the non truncated name to avoid execute netstat for them again
|
||||
ret[retIndex] = *nsInterfaces[index].stat
|
||||
retIndex++
|
||||
truncated = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if truncated {
|
||||
// run netstat with -I$ifacename
|
||||
if out, err = invoke.Command(netstat, "-ibdnWI"+interfaceName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
parsedIfaces, err := parseNetstatOutput(string(out))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(parsedIfaces) == 0 {
|
||||
// interface had been removed since `ifconfig -l` had been executed
|
||||
continue
|
||||
}
|
||||
for index := range parsedIfaces {
|
||||
if parsedIfaces[index].linkId != nil {
|
||||
ret = append(ret, *parsedIfaces[index].stat)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
parsed = append(parsed, t)
|
||||
}
|
||||
|
||||
n := IOCountersStat{
|
||||
Name: values[0],
|
||||
PacketsRecv: parsed[0],
|
||||
Errin: parsed[1],
|
||||
BytesRecv: parsed[2],
|
||||
PacketsSent: parsed[3],
|
||||
Errout: parsed[4],
|
||||
BytesSent: parsed[5],
|
||||
}
|
||||
if len(parsed) == 7 {
|
||||
n.Dropout = parsed[6]
|
||||
}
|
||||
ret = append(ret, n)
|
||||
}
|
||||
|
||||
if pernic == false {
|
||||
return getIOCountersAll(ret)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
||||
6
vendor/github.com/shirou/gopsutil/net/net_fallback.go
generated
vendored
6
vendor/github.com/shirou/gopsutil/net/net_fallback.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build !darwin,!linux,!freebsd,!windows
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
||||
|
||||
package net
|
||||
|
||||
@@ -19,3 +19,7 @@ func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
|
||||
func Connections(kind string) ([]ConnectionStat, error) {
|
||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
126
vendor/github.com/shirou/gopsutil/net/net_linux.go
generated
vendored
126
vendor/github.com/shirou/gopsutil/net/net_linux.go
generated
vendored
@@ -79,11 +79,11 @@ func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
dropOut, err := strconv.ParseUint(fields[13], 10, 64)
|
||||
dropOut, err := strconv.ParseUint(fields[11], 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
fifoOut, err := strconv.ParseUint(fields[14], 10, 64)
|
||||
fifoOut, err := strconv.ParseUint(fields[12], 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
@@ -185,8 +185,8 @@ func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
|
||||
// the currently in use conntrack count and the max.
|
||||
// If the file does not exist or is invalid it will return nil.
|
||||
func FilterCounters() ([]FilterStat, error) {
|
||||
countfile := common.HostProc("sys/net/netfilter/nf_conntrackCount")
|
||||
maxfile := common.HostProc("sys/net/netfilter/nf_conntrackMax")
|
||||
countfile := common.HostProc("sys/net/netfilter/nf_conntrack_count")
|
||||
maxfile := common.HostProc("sys/net/netfilter/nf_conntrack_max")
|
||||
|
||||
count, err := common.ReadInts(countfile)
|
||||
|
||||
@@ -291,6 +291,12 @@ func Connections(kind string) ([]ConnectionStat, error) {
|
||||
return ConnectionsPid(kind, 0)
|
||||
}
|
||||
|
||||
// Return a list of network connections opened returning at most `max`
|
||||
// connections for each running process.
|
||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
||||
return ConnectionsPidMax(kind, 0, max)
|
||||
}
|
||||
|
||||
// Return a list of network connections opened by a process.
|
||||
func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
tmap, ok := netConnectionKindMap[kind]
|
||||
@@ -301,9 +307,9 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
var err error
|
||||
var inodes map[string][]inodeMap
|
||||
if pid == 0 {
|
||||
inodes, err = getProcInodesAll(root)
|
||||
inodes, err = getProcInodesAll(root, 0)
|
||||
} else {
|
||||
inodes, err = getProcInodes(root, pid)
|
||||
inodes, err = getProcInodes(root, pid, 0)
|
||||
if len(inodes) == 0 {
|
||||
// no connection for the pid
|
||||
return []ConnectionStat{}, nil
|
||||
@@ -312,10 +318,38 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cound not get pid(s), %d", pid)
|
||||
}
|
||||
return statsFromInodes(root, pid, tmap, inodes)
|
||||
}
|
||||
|
||||
dupCheckMap := make(map[string]bool)
|
||||
// Return up to `max` network connections opened by a process.
|
||||
func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
||||
tmap, ok := netConnectionKindMap[kind]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid kind, %s", kind)
|
||||
}
|
||||
root := common.HostProc()
|
||||
var err error
|
||||
var inodes map[string][]inodeMap
|
||||
if pid == 0 {
|
||||
inodes, err = getProcInodesAll(root, max)
|
||||
} else {
|
||||
inodes, err = getProcInodes(root, pid, max)
|
||||
if len(inodes) == 0 {
|
||||
// no connection for the pid
|
||||
return []ConnectionStat{}, nil
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cound not get pid(s), %d", pid)
|
||||
}
|
||||
return statsFromInodes(root, pid, tmap, inodes)
|
||||
}
|
||||
|
||||
func statsFromInodes(root string, pid int32, tmap []netConnectionKindType, inodes map[string][]inodeMap) ([]ConnectionStat, error) {
|
||||
dupCheckMap := make(map[connTmp]struct{})
|
||||
var ret []ConnectionStat
|
||||
|
||||
var err error
|
||||
for _, t := range tmap {
|
||||
var path string
|
||||
var ls []connTmp
|
||||
@@ -332,6 +366,10 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
return nil, err
|
||||
}
|
||||
for _, c := range ls {
|
||||
if _, ok := dupCheckMap[c]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
conn := ConnectionStat{
|
||||
Fd: c.fd,
|
||||
Family: c.family,
|
||||
@@ -346,13 +384,13 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
} else {
|
||||
conn.Pid = c.pid
|
||||
}
|
||||
// check duplicate using JSON format
|
||||
json := conn.String()
|
||||
_, exists := dupCheckMap[json]
|
||||
if !exists {
|
||||
ret = append(ret, conn)
|
||||
dupCheckMap[json] = true
|
||||
}
|
||||
|
||||
// fetch process owner Real, effective, saved set, and filesystem UIDs
|
||||
proc := process{Pid: conn.Pid}
|
||||
conn.Uids, _ = proc.getUids()
|
||||
|
||||
ret = append(ret, conn)
|
||||
dupCheckMap[c] = struct{}{}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -361,11 +399,15 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
}
|
||||
|
||||
// getProcInodes returnes fd of the pid.
|
||||
func getProcInodes(root string, pid int32) (map[string][]inodeMap, error) {
|
||||
func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, error) {
|
||||
ret := make(map[string][]inodeMap)
|
||||
|
||||
dir := fmt.Sprintf("%s/%d/fd", root, pid)
|
||||
files, err := ioutil.ReadDir(dir)
|
||||
f, err := os.Open(dir)
|
||||
if err != nil {
|
||||
return ret, nil
|
||||
}
|
||||
files, err := f.Readdir(max)
|
||||
if err != nil {
|
||||
return ret, nil
|
||||
}
|
||||
@@ -429,7 +471,55 @@ func Pids() ([]int32, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func getProcInodesAll(root string) (map[string][]inodeMap, error) {
|
||||
// Note: the following is based off process_linux structs and methods
|
||||
// we need these to fetch the owner of a process ID
|
||||
// FIXME: Import process occures import cycle.
|
||||
// see remarks on pids()
|
||||
type process struct {
|
||||
Pid int32 `json:"pid"`
|
||||
uids []int32
|
||||
}
|
||||
|
||||
// Uids returns user ids of the process as a slice of the int
|
||||
func (p *process) getUids() ([]int32, error) {
|
||||
err := p.fillFromStatus()
|
||||
if err != nil {
|
||||
return []int32{}, err
|
||||
}
|
||||
return p.uids, nil
|
||||
}
|
||||
|
||||
// Get status from /proc/(pid)/status
|
||||
func (p *process) fillFromStatus() error {
|
||||
pid := p.Pid
|
||||
statPath := common.HostProc(strconv.Itoa(int(pid)), "status")
|
||||
contents, err := ioutil.ReadFile(statPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lines := strings.Split(string(contents), "\n")
|
||||
for _, line := range lines {
|
||||
tabParts := strings.SplitN(line, "\t", 2)
|
||||
if len(tabParts) < 2 {
|
||||
continue
|
||||
}
|
||||
value := tabParts[1]
|
||||
switch strings.TrimRight(tabParts[0], ":") {
|
||||
case "Uid":
|
||||
p.uids = make([]int32, 0, 4)
|
||||
for _, i := range strings.Split(value, "\t") {
|
||||
v, err := strconv.ParseInt(i, 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.uids = append(p.uids, int32(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getProcInodesAll(root string, max int) (map[string][]inodeMap, error) {
|
||||
pids, err := Pids()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -437,7 +527,7 @@ func getProcInodesAll(root string) (map[string][]inodeMap, error) {
|
||||
ret := make(map[string][]inodeMap)
|
||||
|
||||
for _, pid := range pids {
|
||||
t, err := getProcInodes(root, pid)
|
||||
t, err := getProcInodes(root, pid, max)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
153
vendor/github.com/shirou/gopsutil/net/net_openbsd.go
generated
vendored
Normal file
153
vendor/github.com/shirou/gopsutil/net/net_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
// +build openbsd
|
||||
|
||||
package net
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
func ParseNetstat(output string, mode string,
|
||||
iocs map[string]IOCountersStat) error {
|
||||
lines := strings.Split(output, "\n")
|
||||
|
||||
exists := make([]string, 0, len(lines)-1)
|
||||
|
||||
columns := 6
|
||||
if mode == "ind" {
|
||||
columns = 10
|
||||
}
|
||||
for _, line := range lines {
|
||||
values := strings.Fields(line)
|
||||
if len(values) < 1 || values[0] == "Name" {
|
||||
continue
|
||||
}
|
||||
if common.StringsHas(exists, values[0]) {
|
||||
// skip if already get
|
||||
continue
|
||||
}
|
||||
|
||||
if len(values) < columns {
|
||||
continue
|
||||
}
|
||||
base := 1
|
||||
// sometimes Address is ommitted
|
||||
if len(values) < columns {
|
||||
base = 0
|
||||
}
|
||||
|
||||
parsed := make([]uint64, 0, 8)
|
||||
var vv []string
|
||||
if mode == "inb" {
|
||||
vv = []string{
|
||||
values[base+3], // BytesRecv
|
||||
values[base+4], // BytesSent
|
||||
}
|
||||
} else {
|
||||
vv = []string{
|
||||
values[base+3], // Ipkts
|
||||
values[base+4], // Ierrs
|
||||
values[base+5], // Opkts
|
||||
values[base+6], // Oerrs
|
||||
values[base+8], // Drops
|
||||
}
|
||||
}
|
||||
for _, target := range vv {
|
||||
if target == "-" {
|
||||
parsed = append(parsed, 0)
|
||||
continue
|
||||
}
|
||||
|
||||
t, err := strconv.ParseUint(target, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
parsed = append(parsed, t)
|
||||
}
|
||||
exists = append(exists, values[0])
|
||||
|
||||
n, present := iocs[values[0]]
|
||||
if !present {
|
||||
n = IOCountersStat{Name: values[0]}
|
||||
}
|
||||
if mode == "inb" {
|
||||
n.BytesRecv = parsed[0]
|
||||
n.BytesSent = parsed[1]
|
||||
} else {
|
||||
n.PacketsRecv = parsed[0]
|
||||
n.Errin = parsed[1]
|
||||
n.PacketsSent = parsed[2]
|
||||
n.Errout = parsed[3]
|
||||
n.Dropin = parsed[4]
|
||||
n.Dropout = parsed[4]
|
||||
}
|
||||
|
||||
iocs[n.Name] = n
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||
netstat, err := exec.LookPath("/usr/bin/netstat")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out, err := invoke.Command(netstat, "-inb")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out2, err := invoke.Command(netstat, "-ind")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
iocs := make(map[string]IOCountersStat)
|
||||
|
||||
lines := strings.Split(string(out), "\n")
|
||||
ret := make([]IOCountersStat, 0, len(lines)-1)
|
||||
|
||||
err = ParseNetstat(string(out), "inb", iocs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = ParseNetstat(string(out2), "ind", iocs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, ioc := range iocs {
|
||||
ret = append(ret, ioc)
|
||||
}
|
||||
|
||||
if pernic == false {
|
||||
return getIOCountersAll(ret)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// NetIOCountersByFile is an method which is added just a compatibility for linux.
|
||||
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
||||
return IOCounters(pernic)
|
||||
}
|
||||
|
||||
func FilterCounters() ([]FilterStat, error) {
|
||||
return nil, errors.New("NetFilterCounters not implemented for openbsd")
|
||||
}
|
||||
|
||||
// NetProtoCounters returns network statistics for the entire system
|
||||
// If protocols is empty then all protocols are returned, otherwise
|
||||
// just the protocols in the list are returned.
|
||||
// Not Implemented for OpenBSD
|
||||
func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
|
||||
return nil, errors.New("NetProtoCounters not implemented for openbsd")
|
||||
}
|
||||
|
||||
// Return a list of network connections opened.
|
||||
// Not Implemented for OpenBSD
|
||||
func Connections(kind string) ([]ConnectionStat, error) {
|
||||
return nil, errors.New("Connections not implemented for openbsd")
|
||||
}
|
||||
11
vendor/github.com/shirou/gopsutil/net/net_unix.go
generated
vendored
11
vendor/github.com/shirou/gopsutil/net/net_unix.go
generated
vendored
@@ -13,6 +13,12 @@ func Connections(kind string) ([]ConnectionStat, error) {
|
||||
return ConnectionsPid(kind, 0)
|
||||
}
|
||||
|
||||
// Return a list of network connections opened returning at most `max`
|
||||
// connections for each running process.
|
||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
// Return a list of network connections opened by a process.
|
||||
func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
var ret []ConnectionStat
|
||||
@@ -66,3 +72,8 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Return up to `max` network connections opened by a process.
|
||||
func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
65
vendor/github.com/shirou/gopsutil/net/net_windows.go
generated
vendored
65
vendor/github.com/shirou/gopsutil/net/net_windows.go
generated
vendored
@@ -7,7 +7,6 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
@@ -35,37 +34,28 @@ func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ai, err := getAdapterList()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ret []IOCountersStat
|
||||
|
||||
for _, ifi := range ifs {
|
||||
name := ifi.Name
|
||||
for ; ai != nil; ai = ai.Next {
|
||||
name = common.BytePtrToString(&ai.Description[0])
|
||||
c := IOCountersStat{
|
||||
Name: name,
|
||||
}
|
||||
|
||||
row := syscall.MibIfRow{Index: ai.Index}
|
||||
e := syscall.GetIfEntry(&row)
|
||||
if e != nil {
|
||||
return nil, os.NewSyscallError("GetIfEntry", e)
|
||||
}
|
||||
c.BytesSent = uint64(row.OutOctets)
|
||||
c.BytesRecv = uint64(row.InOctets)
|
||||
c.PacketsSent = uint64(row.OutUcastPkts)
|
||||
c.PacketsRecv = uint64(row.InUcastPkts)
|
||||
c.Errin = uint64(row.InErrors)
|
||||
c.Errout = uint64(row.OutErrors)
|
||||
c.Dropin = uint64(row.InDiscards)
|
||||
c.Dropout = uint64(row.OutDiscards)
|
||||
|
||||
ret = append(ret, c)
|
||||
c := IOCountersStat{
|
||||
Name: ifi.Name,
|
||||
}
|
||||
|
||||
row := syscall.MibIfRow{Index: uint32(ifi.Index)}
|
||||
e := syscall.GetIfEntry(&row)
|
||||
if e != nil {
|
||||
return nil, os.NewSyscallError("GetIfEntry", e)
|
||||
}
|
||||
c.BytesSent = uint64(row.OutOctets)
|
||||
c.BytesRecv = uint64(row.InOctets)
|
||||
c.PacketsSent = uint64(row.OutUcastPkts)
|
||||
c.PacketsRecv = uint64(row.InUcastPkts)
|
||||
c.Errin = uint64(row.InErrors)
|
||||
c.Errout = uint64(row.OutErrors)
|
||||
c.Dropin = uint64(row.InDiscards)
|
||||
c.Dropout = uint64(row.OutDiscards)
|
||||
|
||||
ret = append(ret, c)
|
||||
}
|
||||
|
||||
if pernic == false {
|
||||
@@ -86,21 +76,10 @@ func Connections(kind string) ([]ConnectionStat, error) {
|
||||
return ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
// borrowed from src/pkg/net/interface_windows.go
|
||||
func getAdapterList() (*syscall.IpAdapterInfo, error) {
|
||||
b := make([]byte, 1000)
|
||||
l := uint32(len(b))
|
||||
a := (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0]))
|
||||
err := syscall.GetAdaptersInfo(a, &l)
|
||||
if err == syscall.ERROR_BUFFER_OVERFLOW {
|
||||
b = make([]byte, l)
|
||||
a = (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0]))
|
||||
err = syscall.GetAdaptersInfo(a, &l)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, os.NewSyscallError("GetAdaptersInfo", err)
|
||||
}
|
||||
return a, nil
|
||||
// Return a list of network connections opened returning at most `max`
|
||||
// connections for each running process.
|
||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func FilterCounters() ([]FilterStat, error) {
|
||||
|
||||
21
vendor/github.com/shirou/gopsutil/process/process.go
generated
vendored
21
vendor/github.com/shirou/gopsutil/process/process.go
generated
vendored
@@ -60,6 +60,27 @@ type NumCtxSwitchesStat struct {
|
||||
Involuntary int64 `json:"involuntary"`
|
||||
}
|
||||
|
||||
// Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h
|
||||
// from libc6-dev package in Ubuntu 16.10
|
||||
const (
|
||||
RLIMIT_CPU int32 = 0
|
||||
RLIMIT_FSIZE int32 = 1
|
||||
RLIMIT_DATA int32 = 2
|
||||
RLIMIT_STACK int32 = 3
|
||||
RLIMIT_CORE int32 = 4
|
||||
RLIMIT_RSS int32 = 5
|
||||
RLIMIT_NPROC int32 = 6
|
||||
RLIMIT_NOFILE int32 = 7
|
||||
RLIMIT_MEMLOCK int32 = 8
|
||||
RLIMIT_AS int32 = 9
|
||||
RLIMIT_LOCKS int32 = 10
|
||||
RLIMIT_SIGPENDING int32 = 11
|
||||
RLIMIT_MSGQUEUE int32 = 12
|
||||
RLIMIT_NICE int32 = 13
|
||||
RLIMIT_RTPRIO int32 = 14
|
||||
RLIMIT_RTTIME int32 = 15
|
||||
)
|
||||
|
||||
func (p Process) String() string {
|
||||
s, _ := json.Marshal(p)
|
||||
return string(s)
|
||||
|
||||
29
vendor/github.com/shirou/gopsutil/process/process_darwin.go
generated
vendored
29
vendor/github.com/shirou/gopsutil/process/process_darwin.go
generated
vendored
@@ -80,7 +80,34 @@ func (p *Process) Name() (string, error) {
|
||||
return common.IntToString(k.Proc.P_comm[:]), nil
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
lsof_bin, err := exec.LookPath("lsof")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
awk_bin, err := exec.LookPath("awk")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
sed_bin, err := exec.LookPath("sed")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
lsof := exec.Command(lsof_bin, "-p", strconv.Itoa(int(p.Pid)), "-Fn")
|
||||
awk := exec.Command(awk_bin, "NR==3{print}")
|
||||
sed := exec.Command(sed_bin, "s/n\\//\\//")
|
||||
|
||||
output, _, err := common.Pipeline(lsof, awk, sed)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ret := strings.TrimSpace(string(output))
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Cmdline returns the command line arguments of the process as a string with
|
||||
|
||||
234
vendor/github.com/shirou/gopsutil/process/process_darwin_386.go
generated
vendored
Normal file
234
vendor/github.com/shirou/gopsutil/process/process_darwin_386.go
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_darwin.go
|
||||
|
||||
package process
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x8
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x8
|
||||
sizeofLongLong = 0x8
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int64
|
||||
_C_long_long int64
|
||||
)
|
||||
|
||||
type Timespec struct {
|
||||
Sec int64
|
||||
Nsec int64
|
||||
}
|
||||
|
||||
type Timeval struct {
|
||||
Sec int64
|
||||
Usec int32
|
||||
Pad_cgo_0 [4]byte
|
||||
}
|
||||
|
||||
type Rusage struct {
|
||||
Utime Timeval
|
||||
Stime Timeval
|
||||
Maxrss int64
|
||||
Ixrss int64
|
||||
Idrss int64
|
||||
Isrss int64
|
||||
Minflt int64
|
||||
Majflt int64
|
||||
Nswap int64
|
||||
Inblock int64
|
||||
Oublock int64
|
||||
Msgsnd int64
|
||||
Msgrcv int64
|
||||
Nsignals int64
|
||||
Nvcsw int64
|
||||
Nivcsw int64
|
||||
}
|
||||
|
||||
type Rlimit struct {
|
||||
Cur uint64
|
||||
Max uint64
|
||||
}
|
||||
|
||||
type UGid_t uint32
|
||||
|
||||
type KinfoProc struct {
|
||||
Proc ExternProc
|
||||
Eproc Eproc
|
||||
}
|
||||
|
||||
type Eproc struct {
|
||||
Paddr *uint64
|
||||
Sess *Session
|
||||
Pcred Upcred
|
||||
Ucred Uucred
|
||||
Pad_cgo_0 [4]byte
|
||||
Vm Vmspace
|
||||
Ppid int32
|
||||
Pgid int32
|
||||
Jobc int16
|
||||
Pad_cgo_1 [2]byte
|
||||
Tdev int32
|
||||
Tpgid int32
|
||||
Pad_cgo_2 [4]byte
|
||||
Tsess *Session
|
||||
Wmesg [8]int8
|
||||
Xsize int32
|
||||
Xrssize int16
|
||||
Xccount int16
|
||||
Xswrss int16
|
||||
Pad_cgo_3 [2]byte
|
||||
Flag int32
|
||||
Login [12]int8
|
||||
Spare [4]int32
|
||||
Pad_cgo_4 [4]byte
|
||||
}
|
||||
|
||||
type Proc struct{}
|
||||
|
||||
type Session struct{}
|
||||
|
||||
type ucred struct {
|
||||
Link _Ctype_struct___0
|
||||
Ref uint64
|
||||
Posix Posix_cred
|
||||
Label *Label
|
||||
Audit Au_session
|
||||
}
|
||||
|
||||
type Uucred struct {
|
||||
Ref int32
|
||||
UID uint32
|
||||
Ngroups int16
|
||||
Pad_cgo_0 [2]byte
|
||||
Groups [16]uint32
|
||||
}
|
||||
|
||||
type Upcred struct {
|
||||
Pc_lock [72]int8
|
||||
Pc_ucred *ucred
|
||||
P_ruid uint32
|
||||
P_svuid uint32
|
||||
P_rgid uint32
|
||||
P_svgid uint32
|
||||
P_refcnt int32
|
||||
Pad_cgo_0 [4]byte
|
||||
}
|
||||
|
||||
type Vmspace struct {
|
||||
Dummy int32
|
||||
Pad_cgo_0 [4]byte
|
||||
Dummy2 *int8
|
||||
Dummy3 [5]int32
|
||||
Pad_cgo_1 [4]byte
|
||||
Dummy4 [3]*int8
|
||||
}
|
||||
|
||||
type Sigacts struct{}
|
||||
|
||||
type ExternProc struct {
|
||||
P_un [16]byte
|
||||
P_vmspace uint64
|
||||
P_sigacts uint64
|
||||
Pad_cgo_0 [3]byte
|
||||
P_flag int32
|
||||
P_stat int8
|
||||
P_pid int32
|
||||
P_oppid int32
|
||||
P_dupfd int32
|
||||
Pad_cgo_1 [4]byte
|
||||
User_stack uint64
|
||||
Exit_thread uint64
|
||||
P_debugger int32
|
||||
Sigwait int32
|
||||
P_estcpu uint32
|
||||
P_cpticks int32
|
||||
P_pctcpu uint32
|
||||
Pad_cgo_2 [4]byte
|
||||
P_wchan uint64
|
||||
P_wmesg uint64
|
||||
P_swtime uint32
|
||||
P_slptime uint32
|
||||
P_realtimer Itimerval
|
||||
P_rtime Timeval
|
||||
P_uticks uint64
|
||||
P_sticks uint64
|
||||
P_iticks uint64
|
||||
P_traceflag int32
|
||||
Pad_cgo_3 [4]byte
|
||||
P_tracep uint64
|
||||
P_siglist int32
|
||||
Pad_cgo_4 [4]byte
|
||||
P_textvp uint64
|
||||
P_holdcnt int32
|
||||
P_sigmask uint32
|
||||
P_sigignore uint32
|
||||
P_sigcatch uint32
|
||||
P_priority uint8
|
||||
P_usrpri uint8
|
||||
P_nice int8
|
||||
P_comm [17]int8
|
||||
Pad_cgo_5 [4]byte
|
||||
P_pgrp uint64
|
||||
P_addr uint64
|
||||
P_xstat uint16
|
||||
P_acflag uint16
|
||||
Pad_cgo_6 [4]byte
|
||||
P_ru uint64
|
||||
}
|
||||
|
||||
type Itimerval struct {
|
||||
Interval Timeval
|
||||
Value Timeval
|
||||
}
|
||||
|
||||
type Vnode struct{}
|
||||
|
||||
type Pgrp struct{}
|
||||
|
||||
type UserStruct struct{}
|
||||
|
||||
type Au_session struct {
|
||||
Aia_p *AuditinfoAddr
|
||||
Mask AuMask
|
||||
}
|
||||
|
||||
type Posix_cred struct {
|
||||
UID uint32
|
||||
Ruid uint32
|
||||
Svuid uint32
|
||||
Ngroups int16
|
||||
Pad_cgo_0 [2]byte
|
||||
Groups [16]uint32
|
||||
Rgid uint32
|
||||
Svgid uint32
|
||||
Gmuid uint32
|
||||
Flags int32
|
||||
}
|
||||
|
||||
type Label struct{}
|
||||
|
||||
type AuditinfoAddr struct {
|
||||
Auid uint32
|
||||
Mask AuMask
|
||||
Termid AuTidAddr
|
||||
Asid int32
|
||||
Flags uint64
|
||||
}
|
||||
type AuMask struct {
|
||||
Success uint32
|
||||
Failure uint32
|
||||
}
|
||||
type AuTidAddr struct {
|
||||
Port int32
|
||||
Type uint32
|
||||
Addr [4]uint32
|
||||
}
|
||||
|
||||
type UcredQueue struct {
|
||||
Next *ucred
|
||||
Prev **ucred
|
||||
}
|
||||
2
vendor/github.com/shirou/gopsutil/process/process_fallback.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/process/process_fallback.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build !darwin,!linux,!freebsd,!windows
|
||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
||||
|
||||
package process
|
||||
|
||||
|
||||
304
vendor/github.com/shirou/gopsutil/process/process_freebsd_386.go
generated
vendored
304
vendor/github.com/shirou/gopsutil/process/process_freebsd_386.go
generated
vendored
@@ -4,189 +4,189 @@
|
||||
package process
|
||||
|
||||
const (
|
||||
CTLKern = 1
|
||||
KernProc = 14
|
||||
KernProcPID = 1
|
||||
KernProcProc = 8
|
||||
KernProcPathname = 12
|
||||
KernProcArgs = 7
|
||||
CTLKern = 1
|
||||
KernProc = 14
|
||||
KernProcPID = 1
|
||||
KernProcProc = 8
|
||||
KernProcPathname = 12
|
||||
KernProcArgs = 7
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x4
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x4
|
||||
sizeofLongLong = 0x8
|
||||
sizeofPtr = 0x4
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x4
|
||||
sizeofLongLong = 0x8
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfKinfoVmentry = 0x488
|
||||
sizeOfKinfoProc = 0x300
|
||||
sizeOfKinfoVmentry = 0x488
|
||||
sizeOfKinfoProc = 0x300
|
||||
)
|
||||
|
||||
const (
|
||||
SIDL = 1
|
||||
SRUN = 2
|
||||
SSLEEP = 3
|
||||
SSTOP = 4
|
||||
SZOMB = 5
|
||||
SWAIT = 6
|
||||
SLOCK = 7
|
||||
SIDL = 1
|
||||
SRUN = 2
|
||||
SSLEEP = 3
|
||||
SSTOP = 4
|
||||
SZOMB = 5
|
||||
SWAIT = 6
|
||||
SLOCK = 7
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int32
|
||||
_C_long_long int64
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int32
|
||||
_C_long_long int64
|
||||
)
|
||||
|
||||
type Timespec struct {
|
||||
Sec int32
|
||||
Nsec int32
|
||||
Sec int32
|
||||
Nsec int32
|
||||
}
|
||||
|
||||
type Timeval struct {
|
||||
Sec int32
|
||||
Usec int32
|
||||
Sec int32
|
||||
Usec int32
|
||||
}
|
||||
|
||||
type Rusage struct {
|
||||
Utime Timeval
|
||||
Stime Timeval
|
||||
Maxrss int32
|
||||
Ixrss int32
|
||||
Idrss int32
|
||||
Isrss int32
|
||||
Minflt int32
|
||||
Majflt int32
|
||||
Nswap int32
|
||||
Inblock int32
|
||||
Oublock int32
|
||||
Msgsnd int32
|
||||
Msgrcv int32
|
||||
Nsignals int32
|
||||
Nvcsw int32
|
||||
Nivcsw int32
|
||||
Utime Timeval
|
||||
Stime Timeval
|
||||
Maxrss int32
|
||||
Ixrss int32
|
||||
Idrss int32
|
||||
Isrss int32
|
||||
Minflt int32
|
||||
Majflt int32
|
||||
Nswap int32
|
||||
Inblock int32
|
||||
Oublock int32
|
||||
Msgsnd int32
|
||||
Msgrcv int32
|
||||
Nsignals int32
|
||||
Nvcsw int32
|
||||
Nivcsw int32
|
||||
}
|
||||
|
||||
type Rlimit struct {
|
||||
Cur int64
|
||||
Max int64
|
||||
Cur int64
|
||||
Max int64
|
||||
}
|
||||
|
||||
type KinfoProc struct {
|
||||
Structsize int32
|
||||
Layout int32
|
||||
Args int32 /* pargs */
|
||||
Paddr int32 /* proc */
|
||||
Addr int32 /* user */
|
||||
Tracep int32 /* vnode */
|
||||
Textvp int32 /* vnode */
|
||||
Fd int32 /* filedesc */
|
||||
Vmspace int32 /* vmspace */
|
||||
Wchan int32
|
||||
Pid int32
|
||||
Ppid int32
|
||||
Pgid int32
|
||||
Tpgid int32
|
||||
Sid int32
|
||||
Tsid int32
|
||||
Jobc int16
|
||||
Spare_short1 int16
|
||||
Tdev uint32
|
||||
Siglist [16]byte /* sigset */
|
||||
Sigmask [16]byte /* sigset */
|
||||
Sigignore [16]byte /* sigset */
|
||||
Sigcatch [16]byte /* sigset */
|
||||
Uid uint32
|
||||
Ruid uint32
|
||||
Svuid uint32
|
||||
Rgid uint32
|
||||
Svgid uint32
|
||||
Ngroups int16
|
||||
Spare_short2 int16
|
||||
Groups [16]uint32
|
||||
Size uint32
|
||||
Rssize int32
|
||||
Swrss int32
|
||||
Tsize int32
|
||||
Dsize int32
|
||||
Ssize int32
|
||||
Xstat uint16
|
||||
Acflag uint16
|
||||
Pctcpu uint32
|
||||
Estcpu uint32
|
||||
Slptime uint32
|
||||
Swtime uint32
|
||||
Cow uint32
|
||||
Runtime uint64
|
||||
Start Timeval
|
||||
Childtime Timeval
|
||||
Flag int32
|
||||
Kiflag int32
|
||||
Traceflag int32
|
||||
Stat int8
|
||||
Nice int8
|
||||
Lock int8
|
||||
Rqindex int8
|
||||
Oncpu uint8
|
||||
Lastcpu uint8
|
||||
Tdname [17]int8
|
||||
Wmesg [9]int8
|
||||
Login [18]int8
|
||||
Lockname [9]int8
|
||||
Comm [20]int8
|
||||
Emul [17]int8
|
||||
Loginclass [18]int8
|
||||
Sparestrings [50]int8
|
||||
Spareints [7]int32
|
||||
Flag2 int32
|
||||
Fibnum int32
|
||||
Cr_flags uint32
|
||||
Jid int32
|
||||
Numthreads int32
|
||||
Tid int32
|
||||
Pri Priority
|
||||
Rusage Rusage
|
||||
Rusage_ch Rusage
|
||||
Pcb int32 /* pcb */
|
||||
Kstack int32
|
||||
Udata int32
|
||||
Tdaddr int32 /* thread */
|
||||
Spareptrs [6]int32
|
||||
Sparelongs [12]int32
|
||||
Sflag int32
|
||||
Tdflags int32
|
||||
Structsize int32
|
||||
Layout int32
|
||||
Args int32 /* pargs */
|
||||
Paddr int32 /* proc */
|
||||
Addr int32 /* user */
|
||||
Tracep int32 /* vnode */
|
||||
Textvp int32 /* vnode */
|
||||
Fd int32 /* filedesc */
|
||||
Vmspace int32 /* vmspace */
|
||||
Wchan int32
|
||||
Pid int32
|
||||
Ppid int32
|
||||
Pgid int32
|
||||
Tpgid int32
|
||||
Sid int32
|
||||
Tsid int32
|
||||
Jobc int16
|
||||
Spare_short1 int16
|
||||
Tdev uint32
|
||||
Siglist [16]byte /* sigset */
|
||||
Sigmask [16]byte /* sigset */
|
||||
Sigignore [16]byte /* sigset */
|
||||
Sigcatch [16]byte /* sigset */
|
||||
Uid uint32
|
||||
Ruid uint32
|
||||
Svuid uint32
|
||||
Rgid uint32
|
||||
Svgid uint32
|
||||
Ngroups int16
|
||||
Spare_short2 int16
|
||||
Groups [16]uint32
|
||||
Size uint32
|
||||
Rssize int32
|
||||
Swrss int32
|
||||
Tsize int32
|
||||
Dsize int32
|
||||
Ssize int32
|
||||
Xstat uint16
|
||||
Acflag uint16
|
||||
Pctcpu uint32
|
||||
Estcpu uint32
|
||||
Slptime uint32
|
||||
Swtime uint32
|
||||
Cow uint32
|
||||
Runtime uint64
|
||||
Start Timeval
|
||||
Childtime Timeval
|
||||
Flag int32
|
||||
Kiflag int32
|
||||
Traceflag int32
|
||||
Stat int8
|
||||
Nice int8
|
||||
Lock int8
|
||||
Rqindex int8
|
||||
Oncpu uint8
|
||||
Lastcpu uint8
|
||||
Tdname [17]int8
|
||||
Wmesg [9]int8
|
||||
Login [18]int8
|
||||
Lockname [9]int8
|
||||
Comm [20]int8
|
||||
Emul [17]int8
|
||||
Loginclass [18]int8
|
||||
Sparestrings [50]int8
|
||||
Spareints [7]int32
|
||||
Flag2 int32
|
||||
Fibnum int32
|
||||
Cr_flags uint32
|
||||
Jid int32
|
||||
Numthreads int32
|
||||
Tid int32
|
||||
Pri Priority
|
||||
Rusage Rusage
|
||||
Rusage_ch Rusage
|
||||
Pcb int32 /* pcb */
|
||||
Kstack int32
|
||||
Udata int32
|
||||
Tdaddr int32 /* thread */
|
||||
Spareptrs [6]int32
|
||||
Sparelongs [12]int32
|
||||
Sflag int32
|
||||
Tdflags int32
|
||||
}
|
||||
|
||||
type Priority struct {
|
||||
Class uint8
|
||||
Level uint8
|
||||
Native uint8
|
||||
User uint8
|
||||
Class uint8
|
||||
Level uint8
|
||||
Native uint8
|
||||
User uint8
|
||||
}
|
||||
|
||||
type KinfoVmentry struct {
|
||||
Structsize int32
|
||||
Type int32
|
||||
Start uint64
|
||||
End uint64
|
||||
Offset uint64
|
||||
Vn_fileid uint64
|
||||
Vn_fsid uint32
|
||||
Flags int32
|
||||
Resident int32
|
||||
Private_resident int32
|
||||
Protection int32
|
||||
Ref_count int32
|
||||
Shadow_count int32
|
||||
Vn_type int32
|
||||
Vn_size uint64
|
||||
Vn_rdev uint32
|
||||
Vn_mode uint16
|
||||
Status uint16
|
||||
X_kve_ispare [12]int32
|
||||
Path [1024]int8
|
||||
Structsize int32
|
||||
Type int32
|
||||
Start uint64
|
||||
End uint64
|
||||
Offset uint64
|
||||
Vn_fileid uint64
|
||||
Vn_fsid uint32
|
||||
Flags int32
|
||||
Resident int32
|
||||
Private_resident int32
|
||||
Protection int32
|
||||
Ref_count int32
|
||||
Shadow_count int32
|
||||
Vn_type int32
|
||||
Vn_size uint64
|
||||
Vn_rdev uint32
|
||||
Vn_mode uint16
|
||||
Status uint16
|
||||
X_kve_ispare [12]int32
|
||||
Path [1024]int8
|
||||
}
|
||||
|
||||
304
vendor/github.com/shirou/gopsutil/process/process_freebsd_amd64.go
generated
vendored
304
vendor/github.com/shirou/gopsutil/process/process_freebsd_amd64.go
generated
vendored
@@ -4,189 +4,189 @@
|
||||
package process
|
||||
|
||||
const (
|
||||
CTLKern = 1
|
||||
KernProc = 14
|
||||
KernProcPID = 1
|
||||
KernProcProc = 8
|
||||
KernProcPathname = 12
|
||||
KernProcArgs = 7
|
||||
CTLKern = 1
|
||||
KernProc = 14
|
||||
KernProcPID = 1
|
||||
KernProcProc = 8
|
||||
KernProcPathname = 12
|
||||
KernProcArgs = 7
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x8
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x8
|
||||
sizeofLongLong = 0x8
|
||||
sizeofPtr = 0x8
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x8
|
||||
sizeofLongLong = 0x8
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfKinfoVmentry = 0x488
|
||||
sizeOfKinfoProc = 0x440
|
||||
sizeOfKinfoVmentry = 0x488
|
||||
sizeOfKinfoProc = 0x440
|
||||
)
|
||||
|
||||
const (
|
||||
SIDL = 1
|
||||
SRUN = 2
|
||||
SSLEEP = 3
|
||||
SSTOP = 4
|
||||
SZOMB = 5
|
||||
SWAIT = 6
|
||||
SLOCK = 7
|
||||
SIDL = 1
|
||||
SRUN = 2
|
||||
SSLEEP = 3
|
||||
SSTOP = 4
|
||||
SZOMB = 5
|
||||
SWAIT = 6
|
||||
SLOCK = 7
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int64
|
||||
_C_long_long int64
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int64
|
||||
_C_long_long int64
|
||||
)
|
||||
|
||||
type Timespec struct {
|
||||
Sec int64
|
||||
Nsec int64
|
||||
Sec int64
|
||||
Nsec int64
|
||||
}
|
||||
|
||||
type Timeval struct {
|
||||
Sec int64
|
||||
Usec int64
|
||||
Sec int64
|
||||
Usec int64
|
||||
}
|
||||
|
||||
type Rusage struct {
|
||||
Utime Timeval
|
||||
Stime Timeval
|
||||
Maxrss int64
|
||||
Ixrss int64
|
||||
Idrss int64
|
||||
Isrss int64
|
||||
Minflt int64
|
||||
Majflt int64
|
||||
Nswap int64
|
||||
Inblock int64
|
||||
Oublock int64
|
||||
Msgsnd int64
|
||||
Msgrcv int64
|
||||
Nsignals int64
|
||||
Nvcsw int64
|
||||
Nivcsw int64
|
||||
Utime Timeval
|
||||
Stime Timeval
|
||||
Maxrss int64
|
||||
Ixrss int64
|
||||
Idrss int64
|
||||
Isrss int64
|
||||
Minflt int64
|
||||
Majflt int64
|
||||
Nswap int64
|
||||
Inblock int64
|
||||
Oublock int64
|
||||
Msgsnd int64
|
||||
Msgrcv int64
|
||||
Nsignals int64
|
||||
Nvcsw int64
|
||||
Nivcsw int64
|
||||
}
|
||||
|
||||
type Rlimit struct {
|
||||
Cur int64
|
||||
Max int64
|
||||
Cur int64
|
||||
Max int64
|
||||
}
|
||||
|
||||
type KinfoProc struct {
|
||||
Structsize int32
|
||||
Layout int32
|
||||
Args int64 /* pargs */
|
||||
Paddr int64 /* proc */
|
||||
Addr int64 /* user */
|
||||
Tracep int64 /* vnode */
|
||||
Textvp int64 /* vnode */
|
||||
Fd int64 /* filedesc */
|
||||
Vmspace int64 /* vmspace */
|
||||
Wchan int64
|
||||
Pid int32
|
||||
Ppid int32
|
||||
Pgid int32
|
||||
Tpgid int32
|
||||
Sid int32
|
||||
Tsid int32
|
||||
Jobc int16
|
||||
Spare_short1 int16
|
||||
Tdev uint32
|
||||
Siglist [16]byte /* sigset */
|
||||
Sigmask [16]byte /* sigset */
|
||||
Sigignore [16]byte /* sigset */
|
||||
Sigcatch [16]byte /* sigset */
|
||||
Uid uint32
|
||||
Ruid uint32
|
||||
Svuid uint32
|
||||
Rgid uint32
|
||||
Svgid uint32
|
||||
Ngroups int16
|
||||
Spare_short2 int16
|
||||
Groups [16]uint32
|
||||
Size uint64
|
||||
Rssize int64
|
||||
Swrss int64
|
||||
Tsize int64
|
||||
Dsize int64
|
||||
Ssize int64
|
||||
Xstat uint16
|
||||
Acflag uint16
|
||||
Pctcpu uint32
|
||||
Estcpu uint32
|
||||
Slptime uint32
|
||||
Swtime uint32
|
||||
Cow uint32
|
||||
Runtime uint64
|
||||
Start Timeval
|
||||
Childtime Timeval
|
||||
Flag int64
|
||||
Kiflag int64
|
||||
Traceflag int32
|
||||
Stat int8
|
||||
Nice int8
|
||||
Lock int8
|
||||
Rqindex int8
|
||||
Oncpu uint8
|
||||
Lastcpu uint8
|
||||
Tdname [17]int8
|
||||
Wmesg [9]int8
|
||||
Login [18]int8
|
||||
Lockname [9]int8
|
||||
Comm [20]int8
|
||||
Emul [17]int8
|
||||
Loginclass [18]int8
|
||||
Sparestrings [50]int8
|
||||
Spareints [7]int32
|
||||
Flag2 int32
|
||||
Fibnum int32
|
||||
Cr_flags uint32
|
||||
Jid int32
|
||||
Numthreads int32
|
||||
Tid int32
|
||||
Pri Priority
|
||||
Rusage Rusage
|
||||
Rusage_ch Rusage
|
||||
Pcb int64 /* pcb */
|
||||
Kstack int64
|
||||
Udata int64
|
||||
Tdaddr int64 /* thread */
|
||||
Spareptrs [6]int64
|
||||
Sparelongs [12]int64
|
||||
Sflag int64
|
||||
Tdflags int64
|
||||
Structsize int32
|
||||
Layout int32
|
||||
Args int64 /* pargs */
|
||||
Paddr int64 /* proc */
|
||||
Addr int64 /* user */
|
||||
Tracep int64 /* vnode */
|
||||
Textvp int64 /* vnode */
|
||||
Fd int64 /* filedesc */
|
||||
Vmspace int64 /* vmspace */
|
||||
Wchan int64
|
||||
Pid int32
|
||||
Ppid int32
|
||||
Pgid int32
|
||||
Tpgid int32
|
||||
Sid int32
|
||||
Tsid int32
|
||||
Jobc int16
|
||||
Spare_short1 int16
|
||||
Tdev uint32
|
||||
Siglist [16]byte /* sigset */
|
||||
Sigmask [16]byte /* sigset */
|
||||
Sigignore [16]byte /* sigset */
|
||||
Sigcatch [16]byte /* sigset */
|
||||
Uid uint32
|
||||
Ruid uint32
|
||||
Svuid uint32
|
||||
Rgid uint32
|
||||
Svgid uint32
|
||||
Ngroups int16
|
||||
Spare_short2 int16
|
||||
Groups [16]uint32
|
||||
Size uint64
|
||||
Rssize int64
|
||||
Swrss int64
|
||||
Tsize int64
|
||||
Dsize int64
|
||||
Ssize int64
|
||||
Xstat uint16
|
||||
Acflag uint16
|
||||
Pctcpu uint32
|
||||
Estcpu uint32
|
||||
Slptime uint32
|
||||
Swtime uint32
|
||||
Cow uint32
|
||||
Runtime uint64
|
||||
Start Timeval
|
||||
Childtime Timeval
|
||||
Flag int64
|
||||
Kiflag int64
|
||||
Traceflag int32
|
||||
Stat int8
|
||||
Nice int8
|
||||
Lock int8
|
||||
Rqindex int8
|
||||
Oncpu uint8
|
||||
Lastcpu uint8
|
||||
Tdname [17]int8
|
||||
Wmesg [9]int8
|
||||
Login [18]int8
|
||||
Lockname [9]int8
|
||||
Comm [20]int8
|
||||
Emul [17]int8
|
||||
Loginclass [18]int8
|
||||
Sparestrings [50]int8
|
||||
Spareints [7]int32
|
||||
Flag2 int32
|
||||
Fibnum int32
|
||||
Cr_flags uint32
|
||||
Jid int32
|
||||
Numthreads int32
|
||||
Tid int32
|
||||
Pri Priority
|
||||
Rusage Rusage
|
||||
Rusage_ch Rusage
|
||||
Pcb int64 /* pcb */
|
||||
Kstack int64
|
||||
Udata int64
|
||||
Tdaddr int64 /* thread */
|
||||
Spareptrs [6]int64
|
||||
Sparelongs [12]int64
|
||||
Sflag int64
|
||||
Tdflags int64
|
||||
}
|
||||
|
||||
type Priority struct {
|
||||
Class uint8
|
||||
Level uint8
|
||||
Native uint8
|
||||
User uint8
|
||||
Class uint8
|
||||
Level uint8
|
||||
Native uint8
|
||||
User uint8
|
||||
}
|
||||
|
||||
type KinfoVmentry struct {
|
||||
Structsize int32
|
||||
Type int32
|
||||
Start uint64
|
||||
End uint64
|
||||
Offset uint64
|
||||
Vn_fileid uint64
|
||||
Vn_fsid uint32
|
||||
Flags int32
|
||||
Resident int32
|
||||
Private_resident int32
|
||||
Protection int32
|
||||
Ref_count int32
|
||||
Shadow_count int32
|
||||
Vn_type int32
|
||||
Vn_size uint64
|
||||
Vn_rdev uint32
|
||||
Vn_mode uint16
|
||||
Status uint16
|
||||
X_kve_ispare [12]int32
|
||||
Path [1024]int8
|
||||
Structsize int32
|
||||
Type int32
|
||||
Start uint64
|
||||
End uint64
|
||||
Offset uint64
|
||||
Vn_fileid uint64
|
||||
Vn_fsid uint32
|
||||
Flags int32
|
||||
Resident int32
|
||||
Private_resident int32
|
||||
Protection int32
|
||||
Ref_count int32
|
||||
Shadow_count int32
|
||||
Vn_type int32
|
||||
Vn_size uint64
|
||||
Vn_rdev uint32
|
||||
Vn_mode uint16
|
||||
Status uint16
|
||||
X_kve_ispare [12]int32
|
||||
Path [1024]int8
|
||||
}
|
||||
|
||||
192
vendor/github.com/shirou/gopsutil/process/process_freebsd_arm.go
generated
vendored
Normal file
192
vendor/github.com/shirou/gopsutil/process/process_freebsd_arm.go
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_freebsd.go
|
||||
|
||||
package process
|
||||
|
||||
const (
|
||||
CTLKern = 1
|
||||
KernProc = 14
|
||||
KernProcPID = 1
|
||||
KernProcProc = 8
|
||||
KernProcPathname = 12
|
||||
KernProcArgs = 7
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x4
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x4
|
||||
sizeofLongLong = 0x8
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfKinfoVmentry = 0x488
|
||||
sizeOfKinfoProc = 0x440
|
||||
)
|
||||
|
||||
const (
|
||||
SIDL = 1
|
||||
SRUN = 2
|
||||
SSLEEP = 3
|
||||
SSTOP = 4
|
||||
SZOMB = 5
|
||||
SWAIT = 6
|
||||
SLOCK = 7
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int32
|
||||
_C_long_long int64
|
||||
)
|
||||
|
||||
type Timespec struct {
|
||||
Sec int64
|
||||
Nsec int64
|
||||
}
|
||||
|
||||
type Timeval struct {
|
||||
Sec int64
|
||||
Usec int64
|
||||
}
|
||||
|
||||
type Rusage struct {
|
||||
Utime Timeval
|
||||
Stime Timeval
|
||||
Maxrss int32
|
||||
Ixrss int32
|
||||
Idrss int32
|
||||
Isrss int32
|
||||
Minflt int32
|
||||
Majflt int32
|
||||
Nswap int32
|
||||
Inblock int32
|
||||
Oublock int32
|
||||
Msgsnd int32
|
||||
Msgrcv int32
|
||||
Nsignals int32
|
||||
Nvcsw int32
|
||||
Nivcsw int32
|
||||
}
|
||||
|
||||
type Rlimit struct {
|
||||
Cur int32
|
||||
Max int32
|
||||
}
|
||||
|
||||
type KinfoProc struct {
|
||||
Structsize int32
|
||||
Layout int32
|
||||
Args int32 /* pargs */
|
||||
Paddr int32 /* proc */
|
||||
Addr int32 /* user */
|
||||
Tracep int32 /* vnode */
|
||||
Textvp int32 /* vnode */
|
||||
Fd int32 /* filedesc */
|
||||
Vmspace int32 /* vmspace */
|
||||
Wchan int32
|
||||
Pid int32
|
||||
Ppid int32
|
||||
Pgid int32
|
||||
Tpgid int32
|
||||
Sid int32
|
||||
Tsid int32
|
||||
Jobc int16
|
||||
Spare_short1 int16
|
||||
Tdev uint32
|
||||
Siglist [16]byte /* sigset */
|
||||
Sigmask [16]byte /* sigset */
|
||||
Sigignore [16]byte /* sigset */
|
||||
Sigcatch [16]byte /* sigset */
|
||||
Uid uint32
|
||||
Ruid uint32
|
||||
Svuid uint32
|
||||
Rgid uint32
|
||||
Svgid uint32
|
||||
Ngroups int16
|
||||
Spare_short2 int16
|
||||
Groups [16]uint32
|
||||
Size uint32
|
||||
Rssize int32
|
||||
Swrss int32
|
||||
Tsize int32
|
||||
Dsize int32
|
||||
Ssize int32
|
||||
Xstat uint16
|
||||
Acflag uint16
|
||||
Pctcpu uint32
|
||||
Estcpu uint32
|
||||
Slptime uint32
|
||||
Swtime uint32
|
||||
Cow uint32
|
||||
Runtime uint64
|
||||
Start Timeval
|
||||
Childtime Timeval
|
||||
Flag int32
|
||||
Kiflag int32
|
||||
Traceflag int32
|
||||
Stat int8
|
||||
Nice int8
|
||||
Lock int8
|
||||
Rqindex int8
|
||||
Oncpu uint8
|
||||
Lastcpu uint8
|
||||
Tdname [17]int8
|
||||
Wmesg [9]int8
|
||||
Login [18]int8
|
||||
Lockname [9]int8
|
||||
Comm [20]int8
|
||||
Emul [17]int8
|
||||
Loginclass [18]int8
|
||||
Sparestrings [50]int8
|
||||
Spareints [4]int32
|
||||
Flag2 int32
|
||||
Fibnum int32
|
||||
Cr_flags uint32
|
||||
Jid int32
|
||||
Numthreads int32
|
||||
Tid int32
|
||||
Pri Priority
|
||||
Rusage Rusage
|
||||
Rusage_ch Rusage
|
||||
Pcb int32 /* pcb */
|
||||
Kstack int32
|
||||
Udata int32
|
||||
Tdaddr int32 /* thread */
|
||||
Spareptrs [6]int64
|
||||
Sparelongs [12]int64
|
||||
Sflag int64
|
||||
Tdflags int64
|
||||
}
|
||||
|
||||
type Priority struct {
|
||||
Class uint8
|
||||
Level uint8
|
||||
Native uint8
|
||||
User uint8
|
||||
}
|
||||
|
||||
type KinfoVmentry struct {
|
||||
Structsize int32
|
||||
Type int32
|
||||
Start uint64
|
||||
End uint64
|
||||
Offset uint64
|
||||
Vn_fileid uint64
|
||||
Vn_fsid uint32
|
||||
Flags int32
|
||||
Resident int32
|
||||
Private_resident int32
|
||||
Protection int32
|
||||
Ref_count int32
|
||||
Shadow_count int32
|
||||
Vn_type int32
|
||||
Vn_size uint64
|
||||
Vn_rdev uint32
|
||||
Vn_mode uint16
|
||||
Status uint16
|
||||
X_kve_ispare [12]int32
|
||||
Path [1024]int8
|
||||
}
|
||||
129
vendor/github.com/shirou/gopsutil/process/process_linux.go
generated
vendored
129
vendor/github.com/shirou/gopsutil/process/process_linux.go
generated
vendored
@@ -3,11 +3,13 @@
|
||||
package process
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -20,10 +22,14 @@ import (
|
||||
"github.com/shirou/gopsutil/net"
|
||||
)
|
||||
|
||||
var ErrorNoChildren = errors.New("process does not have children")
|
||||
var (
|
||||
ErrorNoChildren = errors.New("process does not have children")
|
||||
PageSize = uint64(os.Getpagesize())
|
||||
)
|
||||
|
||||
const (
|
||||
PrioProcess = 0 // linux/resource.h
|
||||
PrioProcess = 0 // linux/resource.h
|
||||
ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
|
||||
)
|
||||
|
||||
// MemoryInfoExStat is different between OSes
|
||||
@@ -194,7 +200,7 @@ func (p *Process) IOnice() (int32, error) {
|
||||
|
||||
// Rlimit returns Resource Limits.
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
return p.fillFromLimits()
|
||||
}
|
||||
|
||||
// IOCounters returns IO Counters.
|
||||
@@ -403,6 +409,111 @@ func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
** Internal functions
|
||||
**/
|
||||
|
||||
func limitToInt(val string) (int32, error) {
|
||||
if val == "unlimited" {
|
||||
return math.MaxInt32, nil
|
||||
} else {
|
||||
res, err := strconv.ParseInt(val, 10, 32)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int32(res), nil
|
||||
}
|
||||
}
|
||||
|
||||
// Get num_fds from /proc/(pid)/limits
|
||||
func (p *Process) fillFromLimits() ([]RlimitStat, error) {
|
||||
pid := p.Pid
|
||||
limitsFile := common.HostProc(strconv.Itoa(int(pid)), "limits")
|
||||
d, err := os.Open(limitsFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
var limitStats []RlimitStat
|
||||
|
||||
limitsScanner := bufio.NewScanner(d)
|
||||
for limitsScanner.Scan() {
|
||||
var statItem RlimitStat
|
||||
|
||||
str := strings.Fields(limitsScanner.Text())
|
||||
|
||||
// Remove the header line
|
||||
if strings.Contains(str[len(str)-1], "Units") {
|
||||
continue
|
||||
}
|
||||
|
||||
// Assert that last item is a Hard limit
|
||||
statItem.Hard, err = limitToInt(str[len(str)-1])
|
||||
if err != nil {
|
||||
// On error remove last item an try once again since it can be unit or header line
|
||||
str = str[:len(str)-1]
|
||||
statItem.Hard, err = limitToInt(str[len(str)-1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Remove last item from string
|
||||
str = str[:len(str)-1]
|
||||
|
||||
//Now last item is a Soft limit
|
||||
statItem.Soft, err = limitToInt(str[len(str)-1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Remove last item from string
|
||||
str = str[:len(str)-1]
|
||||
|
||||
//The rest is a stats name
|
||||
resourceName := strings.Join(str, " ")
|
||||
switch resourceName {
|
||||
case "Max cpu time":
|
||||
statItem.Resource = RLIMIT_CPU
|
||||
case "Max file size":
|
||||
statItem.Resource = RLIMIT_FSIZE
|
||||
case "Max data size":
|
||||
statItem.Resource = RLIMIT_DATA
|
||||
case "Max stack size":
|
||||
statItem.Resource = RLIMIT_STACK
|
||||
case "Max core file size":
|
||||
statItem.Resource = RLIMIT_CORE
|
||||
case "Max resident set":
|
||||
statItem.Resource = RLIMIT_RSS
|
||||
case "Max processes":
|
||||
statItem.Resource = RLIMIT_NPROC
|
||||
case "Max open files":
|
||||
statItem.Resource = RLIMIT_NOFILE
|
||||
case "Max locked memory":
|
||||
statItem.Resource = RLIMIT_MEMLOCK
|
||||
case "Max address space":
|
||||
statItem.Resource = RLIMIT_AS
|
||||
case "Max file locks":
|
||||
statItem.Resource = RLIMIT_LOCKS
|
||||
case "Max pending signals":
|
||||
statItem.Resource = RLIMIT_SIGPENDING
|
||||
case "Max msgqueue size":
|
||||
statItem.Resource = RLIMIT_MSGQUEUE
|
||||
case "Max nice priority":
|
||||
statItem.Resource = RLIMIT_NICE
|
||||
case "Max realtime priority":
|
||||
statItem.Resource = RLIMIT_RTPRIO
|
||||
case "Max realtime timeout":
|
||||
statItem.Resource = RLIMIT_RTTIME
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
||||
limitStats = append(limitStats, statItem)
|
||||
}
|
||||
|
||||
if err := limitsScanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return limitStats, nil
|
||||
}
|
||||
|
||||
// Get num_fds from /proc/(pid)/fd
|
||||
func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) {
|
||||
pid := p.Pid
|
||||
@@ -609,6 +720,18 @@ func (p *Process) fillFromStatus() error {
|
||||
switch strings.TrimRight(tabParts[0], ":") {
|
||||
case "Name":
|
||||
p.name = strings.Trim(value, " \t")
|
||||
if len(p.name) >= 15 {
|
||||
cmdlineSlice, err := p.CmdlineSlice()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(cmdlineSlice) > 0 {
|
||||
extendedName := filepath.Base(cmdlineSlice[0])
|
||||
if strings.HasPrefix(extendedName, p.name) {
|
||||
p.name = extendedName
|
||||
}
|
||||
}
|
||||
}
|
||||
case "State":
|
||||
p.status = value[0:1]
|
||||
case "PPid", "Ppid":
|
||||
|
||||
9
vendor/github.com/shirou/gopsutil/process/process_linux_386.go
generated
vendored
9
vendor/github.com/shirou/gopsutil/process/process_linux_386.go
generated
vendored
@@ -1,9 +0,0 @@
|
||||
// +build linux
|
||||
// +build 386
|
||||
|
||||
package process
|
||||
|
||||
const (
|
||||
ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
|
||||
PageSize = 4096 // C.sysconf(C._SC_PAGE_SIZE)
|
||||
)
|
||||
9
vendor/github.com/shirou/gopsutil/process/process_linux_amd64.go
generated
vendored
9
vendor/github.com/shirou/gopsutil/process/process_linux_amd64.go
generated
vendored
@@ -1,9 +0,0 @@
|
||||
// +build linux
|
||||
// +build amd64
|
||||
|
||||
package process
|
||||
|
||||
const (
|
||||
ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
|
||||
PageSize = 4096 // C.sysconf(C._SC_PAGE_SIZE)
|
||||
)
|
||||
9
vendor/github.com/shirou/gopsutil/process/process_linux_arm.go
generated
vendored
9
vendor/github.com/shirou/gopsutil/process/process_linux_arm.go
generated
vendored
@@ -1,9 +0,0 @@
|
||||
// +build linux
|
||||
// +build arm
|
||||
|
||||
package process
|
||||
|
||||
const (
|
||||
ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
|
||||
PageSize = 4096 // C.sysconf(C._SC_PAGE_SIZE)
|
||||
)
|
||||
9
vendor/github.com/shirou/gopsutil/process/process_linux_arm64.go
generated
vendored
9
vendor/github.com/shirou/gopsutil/process/process_linux_arm64.go
generated
vendored
@@ -1,9 +0,0 @@
|
||||
// +build linux
|
||||
// +build arm64
|
||||
|
||||
package process
|
||||
|
||||
const (
|
||||
ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
|
||||
PageSize = 4096 // C.sysconf(C._SC_PAGE_SIZE)
|
||||
)
|
||||
362
vendor/github.com/shirou/gopsutil/process/process_openbsd.go
generated
vendored
Normal file
362
vendor/github.com/shirou/gopsutil/process/process_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,362 @@
|
||||
// +build openbsd
|
||||
|
||||
package process
|
||||
|
||||
import (
|
||||
"C"
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
cpu "github.com/shirou/gopsutil/cpu"
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
mem "github.com/shirou/gopsutil/mem"
|
||||
net "github.com/shirou/gopsutil/net"
|
||||
)
|
||||
|
||||
// MemoryInfoExStat is different between OSes
|
||||
type MemoryInfoExStat struct {
|
||||
}
|
||||
|
||||
type MemoryMapsStat struct {
|
||||
}
|
||||
|
||||
func Pids() ([]int32, error) {
|
||||
var ret []int32
|
||||
procs, err := processes()
|
||||
if err != nil {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
for _, p := range procs {
|
||||
ret = append(ret, p.Pid)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (p *Process) Ppid() (int32, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return k.Ppid, nil
|
||||
}
|
||||
func (p *Process) Name() (string, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return common.IntToString(k.Comm[:]), nil
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) CmdlineSlice() ([]string, error) {
|
||||
mib := []int32{CTLKern, KernProcArgs, p.Pid, KernProcArgv}
|
||||
buf, _, err := common.CallSyscall(mib)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
argc := 0
|
||||
argvp := unsafe.Pointer(&buf[0])
|
||||
argv := *(**C.char)(unsafe.Pointer(argvp))
|
||||
size := unsafe.Sizeof(argv)
|
||||
var strParts []string
|
||||
|
||||
for argv != nil {
|
||||
strParts = append(strParts, C.GoString(argv))
|
||||
|
||||
argc++
|
||||
argv = *(**C.char)(unsafe.Pointer(uintptr(argvp) + uintptr(argc)*size))
|
||||
}
|
||||
return strParts, nil
|
||||
}
|
||||
|
||||
func (p *Process) Cmdline() (string, error) {
|
||||
argv, err := p.CmdlineSlice()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strings.Join(argv, " "), nil
|
||||
}
|
||||
|
||||
func (p *Process) CreateTime() (int64, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
return p, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Status() (string, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var s string
|
||||
switch k.Stat {
|
||||
case SIDL:
|
||||
case SRUN:
|
||||
case SONPROC:
|
||||
s = "R"
|
||||
case SSLEEP:
|
||||
s = "S"
|
||||
case SSTOP:
|
||||
s = "T"
|
||||
case SDEAD:
|
||||
s = "Z"
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
func (p *Process) Uids() ([]int32, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uids := make([]int32, 0, 3)
|
||||
|
||||
uids = append(uids, int32(k.Ruid), int32(k.Uid), int32(k.Svuid))
|
||||
|
||||
return uids, nil
|
||||
}
|
||||
func (p *Process) Gids() ([]int32, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gids := make([]int32, 0, 3)
|
||||
gids = append(gids, int32(k.Rgid), int32(k.Ngroups), int32(k.Svgid))
|
||||
|
||||
return gids, nil
|
||||
}
|
||||
func (p *Process) Terminal() (string, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ttyNr := uint64(k.Tdev)
|
||||
|
||||
termmap, err := getTerminalMap()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return termmap[ttyNr], nil
|
||||
}
|
||||
func (p *Process) Nice() (int32, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int32(k.Nice), nil
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
var rlimit []RlimitStat
|
||||
return rlimit, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IOCountersStat{
|
||||
ReadCount: uint64(k.Uru_inblock),
|
||||
WriteCount: uint64(k.Uru_oublock),
|
||||
}, nil
|
||||
}
|
||||
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
/* not supported, just return 1 */
|
||||
return 1, nil
|
||||
}
|
||||
func (p *Process) Threads() (map[string]string, error) {
|
||||
ret := make(map[string]string, 0)
|
||||
return ret, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Times() (*cpu.TimesStat, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cpu.TimesStat{
|
||||
CPU: "cpu",
|
||||
User: float64(k.Uutime_sec) + float64(k.Uutime_usec)/1000000,
|
||||
System: float64(k.Ustime_sec) + float64(k.Ustime_usec)/1000000,
|
||||
}, nil
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pageSize, err := mem.GetPageSize()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MemoryInfoStat{
|
||||
RSS: uint64(k.Vm_rssize) * pageSize,
|
||||
VMS: uint64(k.Vm_tsize) + uint64(k.Vm_dsize) +
|
||||
uint64(k.Vm_ssize),
|
||||
}, nil
|
||||
}
|
||||
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
pids, err := common.CallPgrep(invoke, p.Pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := make([]*Process, 0, len(pids))
|
||||
for _, pid := range pids {
|
||||
np, err := NewProcess(pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret = append(ret, np)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Connections() ([]net.ConnectionStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
var ret []MemoryMapsStat
|
||||
return &ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func processes() ([]Process, error) {
|
||||
results := make([]Process, 0, 50)
|
||||
|
||||
buf, length, err := CallKernProcSyscall(KernProcAll, 0)
|
||||
|
||||
if err != nil {
|
||||
return results, err
|
||||
}
|
||||
|
||||
// get kinfo_proc size
|
||||
count := int(length / uint64(sizeOfKinfoProc))
|
||||
|
||||
// parse buf to procs
|
||||
for i := 0; i < count; i++ {
|
||||
b := buf[i*sizeOfKinfoProc : (i+1)*sizeOfKinfoProc]
|
||||
k, err := parseKinfoProc(b)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
p, err := NewProcess(int32(k.Pid))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
results = append(results, *p)
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func parseKinfoProc(buf []byte) (KinfoProc, error) {
|
||||
var k KinfoProc
|
||||
br := bytes.NewReader(buf)
|
||||
err := common.Read(br, binary.LittleEndian, &k)
|
||||
return k, err
|
||||
}
|
||||
|
||||
func (p *Process) getKProc() (*KinfoProc, error) {
|
||||
buf, length, err := CallKernProcSyscall(KernProcPID, p.Pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if length != sizeOfKinfoProc {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k, err := parseKinfoProc(buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &k, nil
|
||||
}
|
||||
|
||||
func NewProcess(pid int32) (*Process, error) {
|
||||
p := &Process{Pid: pid}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func CallKernProcSyscall(op int32, arg int32) ([]byte, uint64, error) {
|
||||
mib := []int32{CTLKern, KernProc, op, arg, sizeOfKinfoProc, 0}
|
||||
mibptr := unsafe.Pointer(&mib[0])
|
||||
miblen := uint64(len(mib))
|
||||
length := uint64(0)
|
||||
_, _, err := syscall.Syscall6(
|
||||
syscall.SYS___SYSCTL,
|
||||
uintptr(mibptr),
|
||||
uintptr(miblen),
|
||||
0,
|
||||
uintptr(unsafe.Pointer(&length)),
|
||||
0,
|
||||
0)
|
||||
if err != 0 {
|
||||
return nil, length, err
|
||||
}
|
||||
|
||||
count := int32(length / uint64(sizeOfKinfoProc))
|
||||
mib = []int32{CTLKern, KernProc, op, arg, sizeOfKinfoProc, count}
|
||||
mibptr = unsafe.Pointer(&mib[0])
|
||||
miblen = uint64(len(mib))
|
||||
// get proc info itself
|
||||
buf := make([]byte, length)
|
||||
_, _, err = syscall.Syscall6(
|
||||
syscall.SYS___SYSCTL,
|
||||
uintptr(mibptr),
|
||||
uintptr(miblen),
|
||||
uintptr(unsafe.Pointer(&buf[0])),
|
||||
uintptr(unsafe.Pointer(&length)),
|
||||
0,
|
||||
0)
|
||||
if err != 0 {
|
||||
return buf, length, err
|
||||
}
|
||||
|
||||
return buf, length, nil
|
||||
}
|
||||
200
vendor/github.com/shirou/gopsutil/process/process_openbsd_amd64.go
generated
vendored
Normal file
200
vendor/github.com/shirou/gopsutil/process/process_openbsd_amd64.go
generated
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_openbsd.go
|
||||
|
||||
package process
|
||||
|
||||
const (
|
||||
CTLKern = 1
|
||||
KernProc = 66
|
||||
KernProcAll = 0
|
||||
KernProcPID = 1
|
||||
KernProcProc = 8
|
||||
KernProcPathname = 12
|
||||
KernProcArgs = 55
|
||||
KernProcArgv = 1
|
||||
KernProcEnv = 3
|
||||
)
|
||||
|
||||
const (
|
||||
ArgMax = 256 * 1024
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofPtr = 0x8
|
||||
sizeofShort = 0x2
|
||||
sizeofInt = 0x4
|
||||
sizeofLong = 0x8
|
||||
sizeofLongLong = 0x8
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfKinfoVmentry = 0x50
|
||||
sizeOfKinfoProc = 0x268
|
||||
)
|
||||
|
||||
const (
|
||||
SIDL = 1
|
||||
SRUN = 2
|
||||
SSLEEP = 3
|
||||
SSTOP = 4
|
||||
SZOMB = 5
|
||||
SDEAD = 6
|
||||
SONPROC = 7
|
||||
)
|
||||
|
||||
type (
|
||||
_C_short int16
|
||||
_C_int int32
|
||||
_C_long int64
|
||||
_C_long_long int64
|
||||
)
|
||||
|
||||
type Timespec struct {
|
||||
Sec int64
|
||||
Nsec int64
|
||||
}
|
||||
|
||||
type Timeval struct {
|
||||
Sec int64
|
||||
Usec int64
|
||||
}
|
||||
|
||||
type Rusage struct {
|
||||
Utime Timeval
|
||||
Stime Timeval
|
||||
Maxrss int64
|
||||
Ixrss int64
|
||||
Idrss int64
|
||||
Isrss int64
|
||||
Minflt int64
|
||||
Majflt int64
|
||||
Nswap int64
|
||||
Inblock int64
|
||||
Oublock int64
|
||||
Msgsnd int64
|
||||
Msgrcv int64
|
||||
Nsignals int64
|
||||
Nvcsw int64
|
||||
Nivcsw int64
|
||||
}
|
||||
|
||||
type Rlimit struct {
|
||||
Cur uint64
|
||||
Max uint64
|
||||
}
|
||||
|
||||
type KinfoProc struct {
|
||||
Forw uint64
|
||||
Back uint64
|
||||
Paddr uint64
|
||||
Addr uint64
|
||||
Fd uint64
|
||||
Stats uint64
|
||||
Limit uint64
|
||||
Vmspace uint64
|
||||
Sigacts uint64
|
||||
Sess uint64
|
||||
Tsess uint64
|
||||
Ru uint64
|
||||
Eflag int32
|
||||
Exitsig int32
|
||||
Flag int32
|
||||
Pid int32
|
||||
Ppid int32
|
||||
Sid int32
|
||||
X_pgid int32
|
||||
Tpgid int32
|
||||
Uid uint32
|
||||
Ruid uint32
|
||||
Gid uint32
|
||||
Rgid uint32
|
||||
Groups [16]uint32
|
||||
Ngroups int16
|
||||
Jobc int16
|
||||
Tdev uint32
|
||||
Estcpu uint32
|
||||
Rtime_sec uint32
|
||||
Rtime_usec uint32
|
||||
Cpticks int32
|
||||
Pctcpu uint32
|
||||
Swtime uint32
|
||||
Slptime uint32
|
||||
Schedflags int32
|
||||
Uticks uint64
|
||||
Sticks uint64
|
||||
Iticks uint64
|
||||
Tracep uint64
|
||||
Traceflag int32
|
||||
Holdcnt int32
|
||||
Siglist int32
|
||||
Sigmask uint32
|
||||
Sigignore uint32
|
||||
Sigcatch uint32
|
||||
Stat int8
|
||||
Priority uint8
|
||||
Usrpri uint8
|
||||
Nice uint8
|
||||
Xstat uint16
|
||||
Acflag uint16
|
||||
Comm [24]int8
|
||||
Wmesg [8]int8
|
||||
Wchan uint64
|
||||
Login [32]int8
|
||||
Vm_rssize int32
|
||||
Vm_tsize int32
|
||||
Vm_dsize int32
|
||||
Vm_ssize int32
|
||||
Uvalid int64
|
||||
Ustart_sec uint64
|
||||
Ustart_usec uint32
|
||||
Uutime_sec uint32
|
||||
Uutime_usec uint32
|
||||
Ustime_sec uint32
|
||||
Ustime_usec uint32
|
||||
Pad_cgo_0 [4]byte
|
||||
Uru_maxrss uint64
|
||||
Uru_ixrss uint64
|
||||
Uru_idrss uint64
|
||||
Uru_isrss uint64
|
||||
Uru_minflt uint64
|
||||
Uru_majflt uint64
|
||||
Uru_nswap uint64
|
||||
Uru_inblock uint64
|
||||
Uru_oublock uint64
|
||||
Uru_msgsnd uint64
|
||||
Uru_msgrcv uint64
|
||||
Uru_nsignals uint64
|
||||
Uru_nvcsw uint64
|
||||
Uru_nivcsw uint64
|
||||
Uctime_sec uint32
|
||||
Uctime_usec uint32
|
||||
Psflags int32
|
||||
Spare int32
|
||||
Svuid uint32
|
||||
Svgid uint32
|
||||
Emul [8]int8
|
||||
Rlim_rss_cur uint64
|
||||
Cpuid uint64
|
||||
Vm_map_size uint64
|
||||
Tid int32
|
||||
Rtableid uint32
|
||||
}
|
||||
|
||||
type Priority struct{}
|
||||
|
||||
type KinfoVmentry struct {
|
||||
Start uint64
|
||||
End uint64
|
||||
Guard uint64
|
||||
Fspace uint64
|
||||
Fspace_augment uint64
|
||||
Offset uint64
|
||||
Wired_count int32
|
||||
Etype int32
|
||||
Protection int32
|
||||
Max_protection int32
|
||||
Advice int32
|
||||
Inheritance int32
|
||||
Flags uint8
|
||||
Pad_cgo_0 [7]byte
|
||||
}
|
||||
22
vendor/github.com/shirou/gopsutil/process/process_posix.go
generated
vendored
22
vendor/github.com/shirou/gopsutil/process/process_posix.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// +build linux freebsd darwin
|
||||
// +build linux freebsd openbsd darwin
|
||||
|
||||
package process
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
@@ -31,15 +32,22 @@ func getTerminalMap() (map[uint64]string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
var ptsnames []string
|
||||
ptsd, err := os.Open("/dev/pts")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
ptsnames, _ = filepath.Glob("/dev/ttyp*")
|
||||
if ptsnames == nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
defer ptsd.Close()
|
||||
|
||||
ptsnames, err := ptsd.Readdirnames(-1)
|
||||
for _, ptsname := range ptsnames {
|
||||
termfiles = append(termfiles, "/dev/pts/"+ptsname)
|
||||
if ptsnames == nil {
|
||||
defer ptsd.Close()
|
||||
ptsnames, err = ptsd.Readdirnames(-1)
|
||||
for _, ptsname := range ptsnames {
|
||||
termfiles = append(termfiles, "/dev/pts/"+ptsname)
|
||||
}
|
||||
} else {
|
||||
termfiles = ptsnames
|
||||
}
|
||||
|
||||
for _, name := range termfiles {
|
||||
|
||||
13
vendor/github.com/shirou/gopsutil/process/process_windows.go
generated
vendored
13
vendor/github.com/shirou/gopsutil/process/process_windows.go
generated
vendored
@@ -308,9 +308,20 @@ func (p *Process) Suspend() error {
|
||||
func (p *Process) Resume() error {
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Terminate() error {
|
||||
return common.ErrNotImplementedError
|
||||
// PROCESS_TERMINATE = 0x0001
|
||||
proc := w32.OpenProcess(0x0001, false, uint32(p.Pid))
|
||||
ret := w32.TerminateProcess(proc, 0)
|
||||
w32.CloseHandle(proc)
|
||||
|
||||
if ret == false {
|
||||
return syscall.GetLastError()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Process) Kill() error {
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
103
vendor/github.com/shirou/gopsutil/process/types_openbsd.go
generated
vendored
Normal file
103
vendor/github.com/shirou/gopsutil/process/types_openbsd.go
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
// +build ignore
|
||||
|
||||
// We still need editing by hands.
|
||||
// go tool cgo -godefs types_openbsd.go | sed 's/\*int64/int64/' | sed 's/\*byte/int64/' > process_openbsd_amd64.go
|
||||
|
||||
/*
|
||||
Input to cgo -godefs.
|
||||
*/
|
||||
|
||||
// +godefs map struct_pargs int64 /* pargs */
|
||||
// +godefs map struct_proc int64 /* proc */
|
||||
// +godefs map struct_user int64 /* user */
|
||||
// +godefs map struct_vnode int64 /* vnode */
|
||||
// +godefs map struct_vnode int64 /* vnode */
|
||||
// +godefs map struct_filedesc int64 /* filedesc */
|
||||
// +godefs map struct_vmspace int64 /* vmspace */
|
||||
// +godefs map struct_pcb int64 /* pcb */
|
||||
// +godefs map struct_thread int64 /* thread */
|
||||
// +godefs map struct___sigset [16]byte /* sigset */
|
||||
|
||||
package process
|
||||
|
||||
/*
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
enum {
|
||||
sizeofPtr = sizeof(void*),
|
||||
};
|
||||
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const (
|
||||
CTLKern = 1 // "high kernel": proc, limits
|
||||
KernProc = 66 // struct: process entries
|
||||
KernProcAll = 0
|
||||
KernProcPID = 1 // by process id
|
||||
KernProcProc = 8 // only return procs
|
||||
KernProcPathname = 12 // path to executable
|
||||
KernProcArgs = 55 // get/set arguments/proctitle
|
||||
KernProcArgv = 1
|
||||
KernProcEnv = 3
|
||||
)
|
||||
|
||||
const (
|
||||
ArgMax = 256 * 1024 // sys/syslimits.h:#define ARG_MAX
|
||||
)
|
||||
|
||||
const (
|
||||
sizeofPtr = C.sizeofPtr
|
||||
sizeofShort = C.sizeof_short
|
||||
sizeofInt = C.sizeof_int
|
||||
sizeofLong = C.sizeof_long
|
||||
sizeofLongLong = C.sizeof_longlong
|
||||
)
|
||||
|
||||
const (
|
||||
sizeOfKinfoVmentry = C.sizeof_struct_kinfo_vmentry
|
||||
sizeOfKinfoProc = C.sizeof_struct_kinfo_proc
|
||||
)
|
||||
|
||||
// from sys/proc.h
|
||||
const (
|
||||
SIDL = 1 /* Process being created by fork. */
|
||||
SRUN = 2 /* Currently runnable. */
|
||||
SSLEEP = 3 /* Sleeping on an address. */
|
||||
SSTOP = 4 /* Process debugging or suspension. */
|
||||
SZOMB = 5 /* Awaiting collection by parent. */
|
||||
SDEAD = 6 /* Thread is almost gone */
|
||||
SONPROC = 7 /* Thread is currently on a CPU. */
|
||||
)
|
||||
|
||||
// Basic types
|
||||
|
||||
type (
|
||||
_C_short C.short
|
||||
_C_int C.int
|
||||
_C_long C.long
|
||||
_C_long_long C.longlong
|
||||
)
|
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec
|
||||
|
||||
type Timeval C.struct_timeval
|
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage
|
||||
|
||||
type Rlimit C.struct_rlimit
|
||||
|
||||
type KinfoProc C.struct_kinfo_proc
|
||||
|
||||
type Priority C.struct_priority
|
||||
|
||||
type KinfoVmentry C.struct_kinfo_vmentry
|
||||
134
vendor/github.com/shirou/gopsutil/v2migration.sh
generated
vendored
134
vendor/github.com/shirou/gopsutil/v2migration.sh
generated
vendored
@@ -1,134 +0,0 @@
|
||||
# This script is a helper of migration to gopsutil v2 using gorename
|
||||
#
|
||||
# go get golang.org/x/tools/cmd/gorename
|
||||
|
||||
IFS=$'\n'
|
||||
|
||||
## Part 1. rename Functions to pass golint. ex) cpu.CPUTimesStat -> cpu.TimesStat
|
||||
|
||||
#
|
||||
# Note:
|
||||
# process has IOCounters() for file IO, and also NetIOCounters() for Net IO.
|
||||
# This scripts replace process.NetIOCounters() to IOCounters().
|
||||
# So you need hand-fixing process.
|
||||
|
||||
TARGETS=`cat <<EOF
|
||||
CPUTimesStat -> TimesStat
|
||||
CPUInfoStat -> InfoStat
|
||||
CPUTimes -> Times
|
||||
CPUInfo -> Info
|
||||
CPUCounts -> Counts
|
||||
CPUPercent -> Percent
|
||||
DiskUsageStat -> UsageStat
|
||||
DiskPartitionStat -> PartitionStat
|
||||
DiskIOCountersStat -> IOCountersStat
|
||||
DiskPartitions -> Partitions
|
||||
DiskIOCounters -> IOCounters
|
||||
DiskUsage -> Usage
|
||||
HostInfoStat -> InfoStat
|
||||
HostInfo -> Info
|
||||
GetVirtualization -> Virtualization
|
||||
GetPlatformInformation -> PlatformInformation
|
||||
LoadAvgStat -> AvgStat
|
||||
LoadAvg -> Avg
|
||||
NetIOCountersStat -> IOCountersStat
|
||||
NetConnectionStat -> ConnectionStat
|
||||
NetProtoCountersStat -> ProtoCountersStat
|
||||
NetInterfaceAddr -> InterfaceAddr
|
||||
NetInterfaceStat -> InterfaceStat
|
||||
NetFilterStat -> FilterStat
|
||||
NetInterfaces -> Interfaces
|
||||
getNetIOCountersAll -> getIOCountersAll
|
||||
NetIOCounters -> IOCounters
|
||||
NetIOCountersByFile -> IOCountersByFile
|
||||
NetProtoCounters -> ProtoCounters
|
||||
NetFilterCounters -> FilterCounters
|
||||
NetConnections -> Connections
|
||||
NetConnectionsPid -> ConnectionsPid
|
||||
Uid -> UID
|
||||
Id -> ID
|
||||
convertCpuTimes -> convertCPUTimes
|
||||
EOF`
|
||||
|
||||
for T in $TARGETS
|
||||
do
|
||||
echo $T
|
||||
gofmt -w -r "$T" ./*.go
|
||||
done
|
||||
|
||||
|
||||
###### Part 2 rename JSON key name
|
||||
## Google JSOn style
|
||||
## https://google.github.io/styleguide/jsoncstyleguide.xml
|
||||
|
||||
sed -i "" 's/guest_nice/guestNice/g' cpu/*.go
|
||||
sed -i "" 's/vendor_id/vendorId/g' cpu/*.go
|
||||
sed -i "" 's/physical_id/physicalId/g' cpu/*.go
|
||||
sed -i "" 's/model_name/modelName/g' cpu/*.go
|
||||
sed -i "" 's/cache_size/cacheSize/g' cpu/*.go
|
||||
sed -i "" 's/core_id/coreId/g' cpu/*.go
|
||||
|
||||
sed -i "" 's/inodes_total/inodesTotal/g' disk/*.go
|
||||
sed -i "" 's/inodes_used/inodesUsed/g' disk/*.go
|
||||
sed -i "" 's/inodes_free/inodesFree/g' disk/*.go
|
||||
sed -i "" 's/inodes_used_percent/inodesUsedPercent/g' disk/*.go
|
||||
sed -i "" 's/read_count/readCount/g' disk/*.go
|
||||
sed -i "" 's/write_count/writeCount/g' disk/*.go
|
||||
sed -i "" 's/read_bytes/readBytes/g' disk/*.go
|
||||
sed -i "" 's/write_bytes/writeBytes/g' disk/*.go
|
||||
sed -i "" 's/read_time/readTime/g' disk/*.go
|
||||
sed -i "" 's/write_time/writeTime/g' disk/*.go
|
||||
sed -i "" 's/io_time/ioTime/g' disk/*.go
|
||||
sed -i "" 's/serial_number/serialNumber/g' disk/*.go
|
||||
sed -i "" 's/used_percent/usedPercent/g' disk/*.go
|
||||
sed -i "" 's/inodesUsed_percent/inodesUsedPercent/g' disk/*.go
|
||||
|
||||
sed -i "" 's/total_cache/totalCache/g' docker/*.go
|
||||
sed -i "" 's/total_rss_huge/totalRssHuge/g' docker/*.go
|
||||
sed -i "" 's/total_rss/totalRss/g' docker/*.go
|
||||
sed -i "" 's/total_mapped_file/totalMappedFile/g' docker/*.go
|
||||
sed -i "" 's/total_pgpgin/totalPgpgin/g' docker/*.go
|
||||
sed -i "" 's/total_pgpgout/totalPgpgout/g' docker/*.go
|
||||
sed -i "" 's/total_pgfault/totalPgfault/g' docker/*.go
|
||||
sed -i "" 's/total_pgmajfault/totalPgmajfault/g' docker/*.go
|
||||
sed -i "" 's/total_inactive_anon/totalInactiveAnon/g' docker/*.go
|
||||
sed -i "" 's/total_active_anon/totalActiveAnon/g' docker/*.go
|
||||
sed -i "" 's/total_inactive_file/totalInactiveFile/g' docker/*.go
|
||||
sed -i "" 's/total_active_file/totalActiveFile/g' docker/*.go
|
||||
sed -i "" 's/total_unevictable/totalUnevictable/g' docker/*.go
|
||||
sed -i "" 's/mem_usage_in_bytes/memUsageInBytes/g' docker/*.go
|
||||
sed -i "" 's/mem_max_usage_in_bytes/memMaxUsageInBytes/g' docker/*.go
|
||||
sed -i "" 's/memory.limit_in_bytes/memoryLimitInBbytes/g' docker/*.go
|
||||
sed -i "" 's/memory.failcnt/memoryFailcnt/g' docker/*.go
|
||||
sed -i "" 's/mapped_file/mappedFile/g' docker/*.go
|
||||
sed -i "" 's/container_id/containerID/g' docker/*.go
|
||||
sed -i "" 's/rss_huge/rssHuge/g' docker/*.go
|
||||
sed -i "" 's/inactive_anon/inactiveAnon/g' docker/*.go
|
||||
sed -i "" 's/active_anon/activeAnon/g' docker/*.go
|
||||
sed -i "" 's/inactive_file/inactiveFile/g' docker/*.go
|
||||
sed -i "" 's/active_file/activeFile/g' docker/*.go
|
||||
sed -i "" 's/hierarchical_memory_limit/hierarchicalMemoryLimit/g' docker/*.go
|
||||
|
||||
sed -i "" 's/boot_time/bootTime/g' host/*.go
|
||||
sed -i "" 's/platform_family/platformFamily/g' host/*.go
|
||||
sed -i "" 's/platform_version/platformVersion/g' host/*.go
|
||||
sed -i "" 's/virtualization_system/virtualizationSystem/g' host/*.go
|
||||
sed -i "" 's/virtualization_role/virtualizationRole/g' host/*.go
|
||||
|
||||
sed -i "" 's/used_percent/usedPercent/g' mem/*.go
|
||||
|
||||
sed -i "" 's/bytes_sent/bytesSent/g' net/*.go
|
||||
sed -i "" 's/bytes_recv/bytesRecv/g' net/*.go
|
||||
sed -i "" 's/packets_sent/packetsSent/g' net/*.go
|
||||
sed -i "" 's/packets_recv/packetsRecv/g' net/*.go
|
||||
sed -i "" 's/conntrack_count/conntrackCount/g' net/*.go
|
||||
sed -i "" 's/conntrack_max/conntrackMax/g' net/*.go
|
||||
|
||||
sed -i "" 's/read_count/readCount/g' process/*.go
|
||||
sed -i "" 's/write_count/writeCount/g' process/*.go
|
||||
sed -i "" 's/read_bytes/readBytes/g' process/*.go
|
||||
sed -i "" 's/write_bytes/writeBytes/g' process/*.go
|
||||
sed -i "" 's/shared_clean/sharedClean/g' process/*.go
|
||||
sed -i "" 's/shared_dirty/sharedDirty/g' process/*.go
|
||||
sed -i "" 's/private_clean/privateClean/g' process/*.go
|
||||
sed -i "" 's/private_dirty/privateDirty/g' process/*.go
|
||||
36
vendor/github.com/shirou/gopsutil/windows_memo.rst
generated
vendored
36
vendor/github.com/shirou/gopsutil/windows_memo.rst
generated
vendored
@@ -1,36 +0,0 @@
|
||||
Windows memo
|
||||
=====================
|
||||
|
||||
Size
|
||||
----------
|
||||
|
||||
DWORD
|
||||
32-bit unsigned integer
|
||||
DWORDLONG
|
||||
64-bit unsigned integer
|
||||
DWORD_PTR
|
||||
unsigned long type for pointer precision
|
||||
DWORD32
|
||||
32-bit unsigned integer
|
||||
DWORD64
|
||||
64-bit unsigned integer
|
||||
HALF_PTR
|
||||
_WIN64 = int, else short
|
||||
INT
|
||||
32-bit signed integer
|
||||
INT_PTR
|
||||
_WIN64 = __int64 else int
|
||||
LONG
|
||||
32-bit signed integer
|
||||
LONGLONG
|
||||
64-bit signed integer
|
||||
LONG_PTR
|
||||
_WIN64 = __int64 else long
|
||||
SHORT
|
||||
16-bit integer
|
||||
SIZE_T
|
||||
maximum number of bytes to which a pointer can point. typedef ULONG_PTR SIZE_T;
|
||||
SSIZE_T
|
||||
signed version of SIZE_T. typedef LONG_PTR SSIZE_T;
|
||||
WORD
|
||||
16-bit unsigned integer
|
||||
2
vendor/github.com/shirou/w32/advapi32.go
generated
vendored
2
vendor/github.com/shirou/w32/advapi32.go
generated
vendored
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package w32
|
||||
|
||||
import (
|
||||
|
||||
2
vendor/github.com/shirou/w32/comctl32.go
generated
vendored
2
vendor/github.com/shirou/w32/comctl32.go
generated
vendored
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package w32
|
||||
|
||||
import (
|
||||
|
||||
2
vendor/github.com/shirou/w32/comdlg32.go
generated
vendored
2
vendor/github.com/shirou/w32/comdlg32.go
generated
vendored
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package w32
|
||||
|
||||
import (
|
||||
|
||||
4
vendor/github.com/shirou/w32/constants.go
generated
vendored
4
vendor/github.com/shirou/w32/constants.go
generated
vendored
@@ -1047,7 +1047,7 @@ const (
|
||||
MB_DEFBUTTON4 = 0x00000300
|
||||
)
|
||||
|
||||
//COM
|
||||
//COM
|
||||
const (
|
||||
E_INVALIDARG = 0x80070057
|
||||
E_OUTOFMEMORY = 0x8007000E
|
||||
@@ -2281,7 +2281,7 @@ const (
|
||||
SC_MANAGER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG
|
||||
)
|
||||
|
||||
// Service Types (Bit Mask)
|
||||
// Service Types (Bit Mask)
|
||||
const (
|
||||
SERVICE_KERNEL_DRIVER = 0x00000001
|
||||
SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
|
||||
|
||||
2
vendor/github.com/shirou/w32/dwmapi.go
generated
vendored
2
vendor/github.com/shirou/w32/dwmapi.go
generated
vendored
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package w32
|
||||
|
||||
import (
|
||||
|
||||
2
vendor/github.com/shirou/w32/gdi32.go
generated
vendored
2
vendor/github.com/shirou/w32/gdi32.go
generated
vendored
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package w32
|
||||
|
||||
import (
|
||||
|
||||
2
vendor/github.com/shirou/w32/gdiplus.go
generated
vendored
2
vendor/github.com/shirou/w32/gdiplus.go
generated
vendored
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package w32
|
||||
|
||||
import (
|
||||
|
||||
2
vendor/github.com/shirou/w32/idispatch.go
generated
vendored
2
vendor/github.com/shirou/w32/idispatch.go
generated
vendored
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package w32
|
||||
|
||||
import (
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user