global

package
v0.1.43 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DateLayout      = "2006-01-02"
	DateTimeLayout  = "2006-01-02 15:04:05"
	TimeLayout      = "15:04:05"
	BuildTimeLayout = "2006.0102.150405"
	TimestampLayout = "20060102150405"
)

日期格式

Variables

View Source
var (
	ErrConnectFail    = errors.New("SSH 连接失败")
	ErrNewSessionFail = errors.New("SSH 新建会话失败")
	ErrRunCommandFail = errors.New("SSH 执行命令失败")
)
View Source
var StartTime = time.Now()

Functions

func GetDuration

func GetDuration(t int64, v string) time.Duration

func GetLocation

func GetLocation() (*time.Location, error)

获取时区

func GetMacAddr added in v0.1.34

func GetMacAddr() string

func IsPortInUse added in v0.0.4

func IsPortInUse(host string, port int64) bool

func LocalIP

func LocalIP(network string) string

func OverTimeNow

func OverTimeNow(compareTime, subTime time.Time, sub int64) (bool, int64, error)

OverTimeNow 超时比较

func SleepRandomDuration

func SleepRandomDuration()

func UpTime

func UpTime() time.Duration

func UpTimeString

func UpTimeString() string

Types

type Cli added in v0.0.2

type Cli struct {
	IP       string //IP地址
	Username string //用户名
	Password string //密码
	Port     int    //端口号

	LastResult string //最近一次Run的结果
	Debug      bool
	// contains filtered or unexported fields
}

func NewSSH added in v0.0.2

func NewSSH(ip string, username string, password string, debug bool, port ...int) *Cli

创建命令行对象 @param ip IP地址 @param username 用户名 @param password 密码 @param debug 是否调试 @param port 端口号,默认22

func (*Cli) GetCpuTemp added in v0.0.8

func (c *Cli) GetCpuTemp() (float64, error)

GetCpuTemp CPU温度

func (*Cli) GetDatetime added in v0.0.2

func (c *Cli) GetDatetime() (string, error)

GetDatetime 当前时间

func (*Cli) GetDf added in v0.0.2

func (c *Cli) GetDf() (string, error)

GetDf 硬盘率

func (*Cli) GetMem added in v0.0.2

func (c *Cli) GetMem() (DeviceMem, error)

GetMem 内存信息

func (*Cli) GetSignal added in v0.0.2

func (c *Cli) GetSignal() (string, error)

GetSignal wifi信号

func (Cli) Run added in v0.0.2

func (c Cli) Run(shell string) (string, error)

执行shell @param shell shell脚本命令

type DateTime

type DateTime time.Time

DateTime 自定义事件类型

func (DateTime) MarshalJSON

func (dt DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) Scan

func (dt *DateTime) Scan(v interface{}) error

func (DateTime) String

func (dt DateTime) String() string

func (*DateTime) UnmarshalJSON

func (dt *DateTime) UnmarshalJSON(data []byte) (err error)

func (DateTime) Value

func (dt DateTime) Value() (driver.Value, error)

type DeviceMem added in v0.0.2

type DeviceMem struct {
	Free      decimal.Decimal
	Total     decimal.Decimal
	FreeRound decimal.Decimal
}

Jump to

Keyboard shortcuts

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