Documentation ¶
Index ¶
- Constants
- func BashCommand(cmd string) ([]byte, error)
- func BuildImageFromDockerfile(ctx context.Context, dockerfile string, name string, version string) error
- func CPUArch() (arch string)
- func CPUInfo() (map[string]CPU, error)
- func CPULoad() (*load.AvgStat, error)
- func CPULogicalCount() (int, error)
- func CPUNum() (coreNum int)
- func CPUPhysicalCount() (int, error)
- func CPUTimesPer() ([]cpu.TimesStat, error)
- func CPUTimesTotal() (cpu.TimesStat, error)
- func CPUUsagePer() ([]float64, error)
- func CPUUsageTotal() (float64, error)
- func Caller(level int) (file string, line int, pkgName string, funcName string)
- func CommandAlwaysWithContext(ctx context.Context, outReader **bufio.Reader, exeName string, args ...string) error
- func CommandOnceWithContext(ctx context.Context, exeName string, args ...string) ([]byte, error)
- func ContainerUsage(ctx context.Context) (<-chan ContainerState, error)
- func CreateContainer(ctx context.Context, baseImage string, name string, arg ...string) (string, error)
- func DebugServerMode(port int)
- func GetDockerVersion(ctx context.Context) (string, error)
- func GetGoroutineID() int64
- func GetNowGMTDatetime() (string, error)
- func GetOS() (os string)
- func GetPID() int
- func GetPath() (string, error)
- func LocalIP() (string, error)
- func NetInfo() ([]net.IOCountersStat, error)
- func OutboundIP(server string) (string, error)
- func RemoveContainer(ctx context.Context, id string) error
- func RestartContainer(ctx context.Context, id string) error
- func SecurityExitProcess(exitFunc exitFunc)
- func SecurityExitProcessWithNotify(exitFunc exitFunc, cc chan string)
- func StartContainer(ctx context.Context, id string) error
- func StopContainer(ctx context.Context, id string) error
- func System() (*host.InfoStat, error)
- func TimeDataNow() string
- func TimeToTimestamp(timeStr string, layout string) (int64, error)
- func TimestampMicNow() int64
- func TimestampMilNow() int64
- func TimestampNanoNow() int64
- func TimestampNow() int64
- func TimestampToTime(nanoSec int64) time.Time
- type CPU
- type ContainerInfo
- type ContainerState
- type Disk
- type Memory
- type Partition
- type PipeServer
- type PrecessState
Constants ¶
const (
DataScanPeriodOfMin = time.Duration(100) * time.Millisecond
)
Variables ¶
This section is empty.
Functions ¶
func BashCommand ¶
func BuildImageFromDockerfile ¶
func BuildImageFromDockerfile(ctx context.Context, dockerfile string, name string, version string) error
dockerfile中ADD、COPY等命令中的src是相对与此执行程序所在目录的相对路径
func CPUNum ¶
func CPUNum() (coreNum int)
CPUNum get the number of logical CPUs usable by the current process.
func CPUPhysicalCount ¶
CPUPhysicalCount get CPU physical count.
func Caller ¶
Caller returns information of the assigned level calling function. level = 0 - get Caller() itself info; level = 1 - get Caller()'s father info; level = 2 - get Caller()'s grandfather info;
func CommandOnceWithContext ¶
func ContainerUsage ¶
func ContainerUsage(ctx context.Context) (<-chan ContainerState, error)
func CreateContainer ¶
func DebugServerMode ¶
func DebugServerMode(port int)
DebugServerMode Turn on debugging information logging, and you can view the specific usage of program memory, coroutines, etc. in the link. Note you need at main package import _ "net/http/pprof". More, recommend you add import _ "github.com/mkevac/debugcharts" to see more char info.
func GetDockerVersion ¶
docker version --format '{{.Server.Version}}'
func GetGoroutineID ¶
func GetGoroutineID() int64
GetGoroutineID Get the coroutine ID (this method affects performance and is only used for debugging).
func GetNowGMTDatetime ¶
func OutboundIP ¶
OutboundIP get local PC outbound IP.
func SecurityExitProcess ¶
func SecurityExitProcess(exitFunc exitFunc)
SecurityExitProcess Listen for system signals, execute exitFunc to release program resources, and exit gracefully.
func SecurityExitProcessWithNotify ¶
func SecurityExitProcessWithNotify(exitFunc exitFunc, cc chan string)
SecurityExitProcessWithNotify Listen for system signals and notify, execute exitFunc to release program resources, and exit gracefully.
func TimeToTimestamp ¶
TimeToTimestamp Convert a datetime string into a timestamp by layout. Layout see in go/src/time/format.go, eq:time.RFC3339Nano.
func TimestampMicNow ¶
func TimestampMicNow() int64
TimestampMicNow Current timestamp, accurate to the micsecond.
func TimestampMilNow ¶
func TimestampMilNow() int64
TimestampMilNow Current timestamp, accurate to the millisecond.
func TimestampNanoNow ¶
func TimestampNanoNow() int64
TimestampNanoNow Current timestamp, accurate to nanosecond.
func TimestampNow ¶
func TimestampNow() int64
TimestampNow Current timestamp, accurate to the second.
func TimestampToTime ¶
TimestampToTime converts a timestamp nano to time.Time.
Types ¶
type ContainerInfo ¶
type ContainerInfo struct { ID string `json:"ID"` Image string `json:"Image"` Command string `json:"Command"` CreatedAt string `json:"CreatedAt"` RunningFor string `json:"RunningFor"` Ports string `json:"Ports"` State string `json:"State"` Status string `json:"Status"` Size string `json:"Size"` Names string `json:"Names"` Labels string `json:"Labels"` Mounts string `json:"Mounts"` Networks string `json:"Networks"` }
func ContainerAllList ¶
func ContainerAllList(ctx context.Context) ([]ContainerInfo, error)
type ContainerState ¶
type Memory ¶
type Memory struct { Total float64 `json:"total"` Free float64 `json:"free"` Usage float64 `json:"usage"` Used float64 `json:"used"` }
Memory info.
type PipeServer ¶
type PipeServer struct {
// contains filtered or unexported fields
}
func NewPipeServer ¶
func NewPipeServer(file string, period time.Duration) *PipeServer
func (*PipeServer) Close ¶
func (ps *PipeServer) Close()
func (*PipeServer) GetDataCh ¶
func (ps *PipeServer) GetDataCh() <-chan []byte
func (*PipeServer) Start ¶
func (ps *PipeServer) Start() error
type PrecessState ¶
type PrecessState struct { Pid int64 `json:"pid"` CpuPerc float64 `json:"cpuPerc"` MemPerc float64 `json:"memPerc"` VSZ int64 `json:"vsz"` RSS int64 `json:"rss"` State string `json:"state"` StartAt string `json:"startAt"` Time string `json:"time"` Cmd string `json:"cmd"` }
func GetProcessInfo ¶
func GetProcessInfo(server string) (PrecessState, error)