mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Add GPU resources
This commit is contained in:
47
docs/docs.go
47
docs/docs.go
@@ -5208,6 +5208,39 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"api.AboutGPUResources": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"memory_limit_bytes": {
|
||||||
|
"description": "Defined memory limit in bytes",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"memory_total_bytes": {
|
||||||
|
"description": "Total available memory in bytes",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"memory_used_bytes": {
|
||||||
|
"description": "Currently used memory in bytes",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"usage_decoder": {
|
||||||
|
"description": "Current decoder usage, 0-100",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usage_encoder": {
|
||||||
|
"description": "Current encoder usage, 0-100",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usage_general": {
|
||||||
|
"description": "Current general usage, 0-100",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usage_limit": {
|
||||||
|
"description": "Defined general usage limit, 0-100",
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"api.AboutResources": {
|
"api.AboutResources": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -5223,6 +5256,13 @@ const docTemplate = `{
|
|||||||
"description": "Current CPU load, 0-100*ncpu",
|
"description": "Current CPU load, 0-100*ncpu",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"gpu": {
|
||||||
|
"description": "GPU resources",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/api.AboutGPUResources"
|
||||||
|
}
|
||||||
|
},
|
||||||
"is_throttling": {
|
"is_throttling": {
|
||||||
"description": "Whether this core is currently throttling",
|
"description": "Whether this core is currently throttling",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@@ -7082,26 +7122,33 @@ const docTemplate = `{
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"cpu_usage": {
|
"cpu_usage": {
|
||||||
|
"description": "percent 0-100*ncpu",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"gpu_decoder": {
|
"gpu_decoder": {
|
||||||
|
"description": "percent 0-100",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"gpu_encoder": {
|
"gpu_encoder": {
|
||||||
|
"description": "percent 0-100",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"gpu_memory_mbytes": {
|
"gpu_memory_mbytes": {
|
||||||
|
"description": "megabytes",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "uint64"
|
"format": "uint64"
|
||||||
},
|
},
|
||||||
"gpu_usage": {
|
"gpu_usage": {
|
||||||
|
"description": "percent 0-100",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"memory_mbytes": {
|
"memory_mbytes": {
|
||||||
|
"description": "megabytes",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "uint64"
|
"format": "uint64"
|
||||||
},
|
},
|
||||||
"waitfor_seconds": {
|
"waitfor_seconds": {
|
||||||
|
"description": "seconds",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "uint64"
|
"format": "uint64"
|
||||||
}
|
}
|
||||||
|
@@ -5201,6 +5201,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"api.AboutGPUResources": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"memory_limit_bytes": {
|
||||||
|
"description": "Defined memory limit in bytes",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"memory_total_bytes": {
|
||||||
|
"description": "Total available memory in bytes",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"memory_used_bytes": {
|
||||||
|
"description": "Currently used memory in bytes",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"usage_decoder": {
|
||||||
|
"description": "Current decoder usage, 0-100",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usage_encoder": {
|
||||||
|
"description": "Current encoder usage, 0-100",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usage_general": {
|
||||||
|
"description": "Current general usage, 0-100",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usage_limit": {
|
||||||
|
"description": "Defined general usage limit, 0-100",
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"api.AboutResources": {
|
"api.AboutResources": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -5216,6 +5249,13 @@
|
|||||||
"description": "Current CPU load, 0-100*ncpu",
|
"description": "Current CPU load, 0-100*ncpu",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"gpu": {
|
||||||
|
"description": "GPU resources",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/api.AboutGPUResources"
|
||||||
|
}
|
||||||
|
},
|
||||||
"is_throttling": {
|
"is_throttling": {
|
||||||
"description": "Whether this core is currently throttling",
|
"description": "Whether this core is currently throttling",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@@ -7075,26 +7115,33 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"cpu_usage": {
|
"cpu_usage": {
|
||||||
|
"description": "percent 0-100*ncpu",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"gpu_decoder": {
|
"gpu_decoder": {
|
||||||
|
"description": "percent 0-100",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"gpu_encoder": {
|
"gpu_encoder": {
|
||||||
|
"description": "percent 0-100",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"gpu_memory_mbytes": {
|
"gpu_memory_mbytes": {
|
||||||
|
"description": "megabytes",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "uint64"
|
"format": "uint64"
|
||||||
},
|
},
|
||||||
"gpu_usage": {
|
"gpu_usage": {
|
||||||
|
"description": "percent 0-100",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"memory_mbytes": {
|
"memory_mbytes": {
|
||||||
|
"description": "megabytes",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "uint64"
|
"format": "uint64"
|
||||||
},
|
},
|
||||||
"waitfor_seconds": {
|
"waitfor_seconds": {
|
||||||
|
"description": "seconds",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "uint64"
|
"format": "uint64"
|
||||||
}
|
}
|
||||||
|
@@ -95,6 +95,30 @@ definitions:
|
|||||||
version:
|
version:
|
||||||
$ref: '#/definitions/api.AboutVersion'
|
$ref: '#/definitions/api.AboutVersion'
|
||||||
type: object
|
type: object
|
||||||
|
api.AboutGPUResources:
|
||||||
|
properties:
|
||||||
|
memory_limit_bytes:
|
||||||
|
description: Defined memory limit in bytes
|
||||||
|
type: integer
|
||||||
|
memory_total_bytes:
|
||||||
|
description: Total available memory in bytes
|
||||||
|
type: integer
|
||||||
|
memory_used_bytes:
|
||||||
|
description: Currently used memory in bytes
|
||||||
|
type: integer
|
||||||
|
usage_decoder:
|
||||||
|
description: Current decoder usage, 0-100
|
||||||
|
type: number
|
||||||
|
usage_encoder:
|
||||||
|
description: Current encoder usage, 0-100
|
||||||
|
type: number
|
||||||
|
usage_general:
|
||||||
|
description: Current general usage, 0-100
|
||||||
|
type: number
|
||||||
|
usage_limit:
|
||||||
|
description: Defined general usage limit, 0-100
|
||||||
|
type: number
|
||||||
|
type: object
|
||||||
api.AboutResources:
|
api.AboutResources:
|
||||||
properties:
|
properties:
|
||||||
cpu_core:
|
cpu_core:
|
||||||
@@ -106,6 +130,11 @@ definitions:
|
|||||||
cpu_used:
|
cpu_used:
|
||||||
description: Current CPU load, 0-100*ncpu
|
description: Current CPU load, 0-100*ncpu
|
||||||
type: number
|
type: number
|
||||||
|
gpu:
|
||||||
|
description: GPU resources
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/api.AboutGPUResources'
|
||||||
|
type: array
|
||||||
is_throttling:
|
is_throttling:
|
||||||
description: Whether this core is currently throttling
|
description: Whether this core is currently throttling
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -1357,20 +1386,27 @@ definitions:
|
|||||||
api.ProcessConfigLimits:
|
api.ProcessConfigLimits:
|
||||||
properties:
|
properties:
|
||||||
cpu_usage:
|
cpu_usage:
|
||||||
|
description: percent 0-100*ncpu
|
||||||
type: number
|
type: number
|
||||||
gpu_decoder:
|
gpu_decoder:
|
||||||
|
description: percent 0-100
|
||||||
type: number
|
type: number
|
||||||
gpu_encoder:
|
gpu_encoder:
|
||||||
|
description: percent 0-100
|
||||||
type: number
|
type: number
|
||||||
gpu_memory_mbytes:
|
gpu_memory_mbytes:
|
||||||
|
description: megabytes
|
||||||
format: uint64
|
format: uint64
|
||||||
type: integer
|
type: integer
|
||||||
gpu_usage:
|
gpu_usage:
|
||||||
|
description: percent 0-100
|
||||||
type: number
|
type: number
|
||||||
memory_mbytes:
|
memory_mbytes:
|
||||||
|
description: megabytes
|
||||||
format: uint64
|
format: uint64
|
||||||
type: integer
|
type: integer
|
||||||
waitfor_seconds:
|
waitfor_seconds:
|
||||||
|
description: seconds
|
||||||
format: uint64
|
format: uint64
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
|
@@ -24,15 +24,26 @@ type AboutVersion struct {
|
|||||||
|
|
||||||
// AboutResources holds information about the current resource usage
|
// AboutResources holds information about the current resource usage
|
||||||
type AboutResources struct {
|
type AboutResources struct {
|
||||||
IsThrottling bool `json:"is_throttling"` // Whether this core is currently throttling
|
IsThrottling bool `json:"is_throttling"` // Whether this core is currently throttling
|
||||||
NCPU float64 `json:"ncpu"` // Number of CPU on this node
|
NCPU float64 `json:"ncpu"` // Number of CPU on this node
|
||||||
CPU float64 `json:"cpu_used"` // Current CPU load, 0-100*ncpu
|
CPU float64 `json:"cpu_used"` // Current CPU load, 0-100*ncpu
|
||||||
CPULimit float64 `json:"cpu_limit"` // Defined CPU load limit, 0-100*ncpu
|
CPULimit float64 `json:"cpu_limit"` // Defined CPU load limit, 0-100*ncpu
|
||||||
CPUCore float64 `json:"cpu_core"` // Current CPU load of the core itself, 0-100*ncpu
|
CPUCore float64 `json:"cpu_core"` // Current CPU load of the core itself, 0-100*ncpu
|
||||||
Mem uint64 `json:"memory_used_bytes"` // Currently used memory in bytes
|
Mem uint64 `json:"memory_used_bytes"` // Currently used memory in bytes
|
||||||
MemLimit uint64 `json:"memory_limit_bytes"` // Defined memory limit in bytes
|
MemLimit uint64 `json:"memory_limit_bytes"` // Defined memory limit in bytes
|
||||||
MemTotal uint64 `json:"memory_total_bytes"` // Total available memory in bytes
|
MemTotal uint64 `json:"memory_total_bytes"` // Total available memory in bytes
|
||||||
MemCore uint64 `json:"memory_core_bytes"` // Current used memory of the core itself in bytes
|
MemCore uint64 `json:"memory_core_bytes"` // Current used memory of the core itself in bytes
|
||||||
|
GPU []AboutGPUResources `json:"gpu"` // GPU resources
|
||||||
|
}
|
||||||
|
|
||||||
|
type AboutGPUResources struct {
|
||||||
|
Mem uint64 `json:"memory_used_bytes"` // Currently used memory in bytes
|
||||||
|
MemLimit uint64 `json:"memory_limit_bytes"` // Defined memory limit in bytes
|
||||||
|
MemTotal uint64 `json:"memory_total_bytes"` // Total available memory in bytes
|
||||||
|
Usage float64 `json:"usage_general"` // Current general usage, 0-100
|
||||||
|
UsageLimit float64 `json:"usage_limit"` // Defined general usage limit, 0-100
|
||||||
|
Encoder float64 `json:"usage_encoder"` // Current encoder usage, 0-100
|
||||||
|
Decoder float64 `json:"usage_decoder"` // Current decoder usage, 0-100
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinimalAbout is the minimal information about the API
|
// MinimalAbout is the minimal information about the API
|
||||||
|
@@ -71,6 +71,7 @@ func (p *AboutHandler) About(c echo.Context) error {
|
|||||||
|
|
||||||
if p.resources != nil {
|
if p.resources != nil {
|
||||||
res := p.resources.Info()
|
res := p.resources.Info()
|
||||||
|
|
||||||
about.Resources.IsThrottling = res.CPU.Throttling
|
about.Resources.IsThrottling = res.CPU.Throttling
|
||||||
about.Resources.NCPU = res.CPU.NCPU
|
about.Resources.NCPU = res.CPU.NCPU
|
||||||
about.Resources.CPU = (100 - res.CPU.Idle) * res.CPU.NCPU
|
about.Resources.CPU = (100 - res.CPU.Idle) * res.CPU.NCPU
|
||||||
@@ -80,6 +81,19 @@ func (p *AboutHandler) About(c echo.Context) error {
|
|||||||
about.Resources.MemLimit = res.Mem.Limit
|
about.Resources.MemLimit = res.Mem.Limit
|
||||||
about.Resources.MemTotal = res.Mem.Total
|
about.Resources.MemTotal = res.Mem.Total
|
||||||
about.Resources.MemCore = res.Mem.Core
|
about.Resources.MemCore = res.Mem.Core
|
||||||
|
|
||||||
|
about.Resources.GPU = make([]api.AboutGPUResources, len(res.GPU.GPU))
|
||||||
|
for i, gpu := range res.GPU.GPU {
|
||||||
|
about.Resources.GPU[i] = api.AboutGPUResources{
|
||||||
|
Mem: gpu.MemoryUsed,
|
||||||
|
MemLimit: gpu.MemoryLimit,
|
||||||
|
MemTotal: gpu.MemoryTotal,
|
||||||
|
Usage: gpu.Usage,
|
||||||
|
UsageLimit: gpu.UsageLimit,
|
||||||
|
Encoder: gpu.Encoder,
|
||||||
|
Decoder: gpu.Decoder,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(http.StatusOK, about)
|
return c.JSON(http.StatusOK, about)
|
||||||
|
Reference in New Issue
Block a user