tools

package
v0.0.0-...-032b0eb Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *zap.Logger

Functions

func Aggregate

func Aggregate(out, model, query interface{}, cond string, args ...interface{}) *gorm.DB

aggregate search search table bb into AA struct e.g: Aggregate(&AA{}, &BB{}, "id <= ?", "Max(a) as max_a, Max(b) as max_b, Min(c) as min_c", 4) select Max(a) as max_a, Max(b) as max_b, Min(c) as min_c from bb where id <= 4;

func CheckSuffix

func CheckSuffix(path string) string

func Client

func Client() *minio.Client

func Count

func Count(model, out, query interface{}, args ...interface{}) *gorm.DB

func Delete

func Delete(value interface{}, where ...interface{}) *gorm.DB

delete by example

func Find

func Find(out interface{}, where ...interface{}) *gorm.DB

select by example

func First

func First(out interface{}, where ...interface{}) *gorm.DB

select by example

func GetMacByName

func GetMacByName(name string) string

get mac address

func GetTempDownloadPath

func GetTempDownloadPath(bucketName string, objectName string) (tempDownloadPath *url.URL)

func HasNvDriver

func HasNvDriver() bool

check nvidia driver

func Init

func Init()

Initialize NVIDIA

func Insert

func Insert(value interface{}) *gorm.DB

create row

func MakePath

func MakePath(path string) string

func Shutdown

func Shutdown()

Shutdown NVIDIA

func UUID

func UUID() string

func Update

func Update(value interface{}) *gorm.DB

update by example

func Updates

func Updates(value, where, updateValue interface{}) *gorm.DB

update by example

func WriteFile

func WriteFile(prefix, filename, content string) error

write string to file

Types

type CPUStat

type CPUStat struct {
	Cores       int     `json:"cores"`
	Index       int     `json:"index"`
	UsedPercent float64 `json:"usedPercent"`
}

CPU stat information struct

func GetCpuInfo

func GetCpuInfo(percpu bool) ([]*CPUStat, error)

get cpu information

type CWA

type CWA struct {
	ID            uint    `gorm:"primary_key AUTO_INCREMENT;not null;column:id" json:"-"`
	CPU           float64 `gorm:"column:cpu" json:"cpu"`
	GPU           uint64  `gorm:"column:gpu" json:"gpu"`
	MEM           uint64  `gorm:"column:mem" json:"mem"`
	Disk          uint64  `gorm:"column:disk" json:"disk"`
	JobId         string  `gorm:"column:jobid" json:"jobid"`
	CpuCores      int     `gorm:"column:cpu_cores" json:"cpu_cores"`
	MemTotal      uint64  `gorm:"column:mem_total" json:"mem_total"`
	GpuTotal      uint64  `gorm:"column:gpu_total" json:"gpu_total"`
	ImageSize     int64   `gorm:"column:image_size" json:"image_size"`
	DiskTotal     uint64  `gorm:"column:disk_total" json:"disk_total"`
	DetectionTime int64   `gorm:"column:detection_time" json:"detection_time"`
	Numerator     uint    `gorm:"column:gpu_numerator" json:"gpu_numerator"`
	Denominator   uint    `gorm:"column:gpu_denominator" json:"gpu_denominator"`
}

////////////////////// CWA info /////////////////////

func (CWA) TableName

func (CWA) TableName() string

set table name

type CurrentGpu

type CurrentGpu struct {
	Used        uint64
	Total       uint64
	Numerator   uint
	Denominator uint
}

////////////////////// current gpu stat count /////////////////////

type Db

type Db struct {
	// contains filtered or unexported fields
}

func (Db) LoadConf

func (Db) LoadConf(conf *conf.Config) error

init database

type DiskStat

type DiskStat struct {
	Total       uint64  `json:"total"`
	Free        uint64  `json:"free"`
	Path        string  `json:"path"`
	Used        uint64  `json:"used"`
	UsedPercent float64 `json:"usedPercent"`
}

Disk stat information struct

func GetDiskInfo

func GetDiskInfo(all bool) ([]*DiskStat, error)

get disk information

type EdgeCmJob

type EdgeCmJob struct {
	ID               uint   `gorm:"primary_key AUTO_INCREMENT;not null;column:id" json:"-"`
	Mac              string `gorm:"-" json:"mac"`              // mac 地址
	RDS              string `gorm:"column:rds" json:"rds"`     // 结果数据存放路径
	DDM              string `gorm:"column:ddm" json:"ddm"`     // 拆分类型
	DDS              string `gorm:"column:dds" json:"dds"`     // 数据集文件地址
	NCP              string `gorm:"column:ncp" json:"ncp"`     // 用户程序名称
	Type             string `gorm:"column:type" json:"type"`   // 任务类型
	Index            int    `gorm:"column:index" json:"index"` // 索引
	Count            int    `gorm:"column:count" json:"count"` // 拆分数量
	JobId            string `gorm:"column:jobid;not null;unique" json:"jobId"`
	TaskId           string `gorm:"column:taskid;not null;" json:"taskId"`
	NcpArgs          string `gorm:"column:ncp_args" json:"ncpArgs"` // 用户程序参数
	JobStatus        int    `gorm:"column:job_status;default:0" json:"-"`
	Dockerfile       string `gorm:"column:dockerfile;not null" json:"dockerfile"`
	NcpCommand       string `gorm:"ncp_command" json:"ncpCommand"`              // 用户启动命令
	DsmCommand       string `gorm:"dsm_command" json:"dsmCommand"`              // 数据拆分启动命令
	RdsFileLocal     string `gorm:"rds_file_local" json:"rds_file_local"`       // 结果集本地输出路径
	SdsFileLocal     string `gorm:"sds_file_local" json:"sds_file_local"`       // 数据集本地拆分路径
	ReceiveTimestamp int64  `gorm:"receive_timestamp" json:"receive_timestamp"` // 接收到任务的时间戳
}

////////////////////// job info /////////////////////

func (*EdgeCmJob) String

func (e *EdgeCmJob) String() string

func (EdgeCmJob) TableName

func (EdgeCmJob) TableName() string

set table name

type FailedMessage

type FailedMessage struct {
	ID      uint   `gorm:"primary_key AUTO_INCREMENT;not null;column:id" json:"-"`
	Message []byte `gorm:"column:message" json:"message"`
	Topic   string `gorm:"column:topic" json:"topic"`
}

////////////////////// failed message /////////////////////

type GPUStat

type GPUStat struct {
	Index             uint   `json:"index"`
	Model             string `json:"model"`
	Power             uint   `json:"power"`
	Temperature       uint   `json:"temperature"`
	TotalMemory       uint64 `json:"totalMemory"`
	UsedMemory        uint64 `json:"usedMemory"`
	FreeMemory        uint64 `json:"freeMemory"`
	UtilizationGPU    uint   `json:"gpuUtilization"`
	UtilizationMemory uint   `json:"memoryUtilization"`
}

GPU stat information struct

func GetGpuInfo

func GetGpuInfo() ([]*GPUStat, error)

get gpu information

type HardwareGenerate

type HardwareGenerate struct {
	C <-chan *HardwareStat
}

Hardware generator get hardware information e.g: <- hardware.C

func HardwareGenerator

func HardwareGenerator(d time.Duration) *HardwareGenerate

generate hardware information

type HardwareStat

type HardwareStat struct {
	MemoryStat *MemoryStat `json:"memory"`
	DickStat   []*DiskStat `json:"disk"`
	GPUStat    []*GPUStat  `json:"gpu"`
	CPUStat    []*CPUStat  `json:"cpu"`
	Timestamp  int64       `json:"timestamp"`
	Mac        string      `json:"mac"`
}

Hardware stat information struct

func GetHardwareInfo

func GetHardwareInfo() *HardwareStat

get hardware information

type JobStatus

type JobStatus struct {
	Msg       string     `json:"msg"`
	Mac       string     `json:"mac"`
	Code      int        `json:"code"`
	Status    int        `json:"status"`
	TaskId    string     `json:"taskId"`
	JobId     string     `json:"jobId"`
	PeakInfo  *PeakValue `json:"peakInfo"`
	Timestamp int64      `json:"timestamp"`
}

////////////////////// job status /////////////////////

type Log

type Log struct {
}

func (Log) LoadConf

func (Log) LoadConf(conf *conf.Config) error

type MemoryStat

type MemoryStat struct {
	Total       uint64  `json:"total"`
	Free        uint64  `json:"free"`
	Used        uint64  `json:"used"`
	UsedPercent float64 `json:"usedPercent"`
}

Memory stat information struct

func GetMemoryInfo

func GetMemoryInfo() (*MemoryStat, error)

get memory information

type PeakValue

type PeakValue struct {
	GpuMax       uint    `gorm:"column:gpuMax" json:"gpuMax"`
	GpuMin       uint    `gorm:"column:gpuMin" json:"gpuMin"`
	CpuMax       float64 `gorm:"column:cpuMax" json:"cpuMax"`
	CpuMin       float64 `gorm:"column:cpuMin" json:"cpuMin"`
	MemMax       float64 `gorm:"column:memMax" json:"memMax"`
	MemMin       float64 `gorm:"column:memMin" json:"memMin"`
	DiskMax      float64 `gorm:"column:diskMax" json:"diskMax"`
	DiskMin      float64 `gorm:"column:diskMin" json:"diskMin"`
	CpuCores     int     `gorm:"column:cpuCores" json:"cpuCores"`
	MemTotal     uint64  `gorm:"column:memTotal" json:"memTotal"`
	GpuTotal     uint64  `gorm:"column:gpuTotal" json:"gpuTotal"`
	ImageSize    int64   `gorm:"column:imageSize" json:"imageSize"`
	DiskTotal    uint64  `gorm:"column:diskTotal" json:"diskTotal"`
	Denominator  uint    `gorm:"column:gpuDenominator" json:"gpuDenominator"`
	NumeratorMax uint    `gorm:"column:numeratorMax" json:"gpuNumeratorMax"`
	NumeratorMin uint    `gorm:"column:numeratorMin" json:"gpuNumeratorMin"`
}

cpu,gpu peak value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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