open-nomad/command/agent/host/windows.go
Lang Martin 6c22cd587d
api: nomad debug new /agent/host (#8325)
* command/agent/host: collect host data, multi platform

* nomad/structs/structs: new HostDataRequest/Response

* client/agent_endpoint: add RPC endpoint

* command/agent/agent_endpoint: add Host

* api/agent: add the Host endpoint

* nomad/client_agent_endpoint: add Agent Host with forwarding

* nomad/client_agent_endpoint: use findClientConn

This changes forwardMonitorClient and forwardProfileClient to use
findClientConn, which was cribbed from the common parts of those
funcs.

* command/debug: call agent hosts

* command/agent/host: eliminate calling external programs
2020-07-02 09:51:25 -04:00

66 lines
937 B
Go

// +build windows
package host
import (
"os"
"syscall"
"unsafe"
)
func uname() string {
return ""
}
func resolvConf() string {
return ""
}
func etcHosts() string {
return ""
}
func mountedPaths() (disks []string) {
for _, c := range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" {
d := string(c) + ":\\"
_, err := os.Stat(d)
if err == nil {
disks = append(disks, d)
}
}
return disks
}
type df struct {
size int64
avail int64
}
func makeDf(path string) (*df, error) {
h, err := syscall.LoadDLL("kernel32.dll")
if err != nil {
return nil, err
}
c, err := h.FindProc("GetDiskFreeSpaceExW")
if err != nil {
return nil, err
}
df := &df{}
c.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))),
uintptr(unsafe.Pointer(&df.size)),
uintptr(unsafe.Pointer(&df.avail)))
return df, nil
}
func (d *df) total() uint64 {
return uint64(d.size)
}
func (d *df) available() uint64 {
return uint64(d.avail)
}