Commit b27a2460 authored by Your Name's avatar Your Name

add mem util

parent f9fd9a12
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"strconv" "strconv"
"strings"
"syscall" "syscall"
"time" "time"
...@@ -25,11 +26,12 @@ import ( ...@@ -25,11 +26,12 @@ import (
// } // }
type Cpu struct { type Cpu struct {
Model string `json:"model"` Model string `json:"model"`
Number int64 `json:"number"` Number int64 `json:"number"`
Cores int64 `json:"cores"` Cores int64 `json:"cores"`
Threads int64 `json:"threads"` Threads int64 `json:"threads"`
Usage int64 `json:"usage"` Usage int64 `json:"usage"`
Frequency string `json:"frequency"`
} }
// type Cpu struct { // type Cpu struct {
...@@ -62,11 +64,20 @@ func (c *ProApi) Cpus() (Cpu, error) { ...@@ -62,11 +64,20 @@ func (c *ProApi) Cpus() (Cpu, error) {
// Cores: int64(core) + 1, // Cores: int64(core) + 1,
// }) // })
idx := strings.IndexAny(modelname, "@")
freq := ""
if idx != -1 && (idx+1) < len(modelname) {
freq = modelname[idx+1:]
}
result := Cpu{ result := Cpu{
Usage: totalUtil, Usage: totalUtil,
Model: modelname, Model: modelname,
Threads: int64(thread) + 1, Threads: int64(thread) + 1,
Cores: int64(core) + 1, Cores: int64(core) + 1,
Frequency: strings.TrimSpace(freq),
} }
return result, nil return result, nil
......
...@@ -122,6 +122,8 @@ components: ...@@ -122,6 +122,8 @@ components:
usage: usage:
type: integer type: integer
format: int64 format: int64
frequency:
type: string
GPU: GPU:
type: array type: array
items: items:
...@@ -135,6 +137,9 @@ components: ...@@ -135,6 +137,9 @@ components:
free: free:
type: integer type: integer
format: int64 format: int64
mem_util:
type: integer
format: int64
DISK: DISK:
type: array type: array
items: items:
...@@ -204,18 +209,4 @@ components: ...@@ -204,18 +209,4 @@ components:
power_rt: power_rt:
type: integer type: integer
format: int64 format: int64
cpu:
type: object
properties:
seq:
type: integer
format: int64
model:
description: addr
type: string
thread:
type: integer
format: int64
core:
type: integer
format: int64
...@@ -98,6 +98,7 @@ func (c *ProApi) Gpus() ([]Gpu, error) { ...@@ -98,6 +98,7 @@ func (c *ProApi) Gpus() ([]Gpu, error) {
for uuidStr, gpu := range gpuMemFree { for uuidStr, gpu := range gpuMemFree {
gpu.UUIDStr = uuidStr gpu.UUIDStr = uuidStr
gpu.Performance = int64(comput[gpu.Model])
res = append(res, gpu) res = append(res, gpu)
} }
......
...@@ -289,7 +289,7 @@ type Response struct { ...@@ -289,7 +289,7 @@ type Response struct {
} }
type NewResponse struct { type NewResponse struct {
Data Data `json:"data"` Data Data `json:"hardware"`
Code int `json:"code"` Code int `json:"code"`
Msg string `json:"msg"` Msg string `json:"msg"`
} }
......
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
type Mem struct { type Mem struct {
Total int64 `json:"total"` Total int64 `json:"total"`
Free int64 `json:"free"` Free int64 `json:"free"`
// Util int64 `json:"mem_util"` Util int64 `json:"mem_util"`
} }
func (c *ProApi) Mem() (Mem, error) { func (c *ProApi) Mem() (Mem, error) {
...@@ -32,16 +32,16 @@ func (c *ProApi) Mem() (Mem, error) { ...@@ -32,16 +32,16 @@ func (c *ProApi) Mem() (Mem, error) {
if err != nil { if err != nil {
return Mem{}, err return Mem{}, err
} }
// util, err := c.MemUtil() util, err := c.MemUtil()
// if err != nil { if err != nil {
// return Mem{}, err return Mem{}, err
// } }
return Mem{ return Mem{
Total: total, Total: total,
Free: free, Free: free,
// Util: util, Util: util,
}, nil }, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment