Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gpuhw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
gpuhw
Commits
b27a2460
Commit
b27a2460
authored
May 10, 2024
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mem util
parent
f9fd9a12
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
31 deletions
+34
-31
cpu.go
cpu.go
+20
-9
swagger.yaml
docs/swagger.yaml
+6
-15
gpu.go
gpu.go
+1
-0
main.go
main.go
+1
-1
mem.go
mem.go
+6
-6
No files found.
cpu.go
View file @
b27a2460
...
...
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strconv"
"strings"
"syscall"
"time"
...
...
@@ -25,11 +26,12 @@ import (
// }
type
Cpu
struct
{
Model
string
`json:"model"`
Number
int64
`json:"number"`
Cores
int64
`json:"cores"`
Threads
int64
`json:"threads"`
Usage
int64
`json:"usage"`
Model
string
`json:"model"`
Number
int64
`json:"number"`
Cores
int64
`json:"cores"`
Threads
int64
`json:"threads"`
Usage
int64
`json:"usage"`
Frequency
string
`json:"frequency"`
}
// type Cpu struct {
...
...
@@ -62,11 +64,20 @@ func (c *ProApi) Cpus() (Cpu, error) {
// Cores: int64(core) + 1,
// })
idx
:=
strings
.
IndexAny
(
modelname
,
"@"
)
freq
:=
""
if
idx
!=
-
1
&&
(
idx
+
1
)
<
len
(
modelname
)
{
freq
=
modelname
[
idx
+
1
:
]
}
result
:=
Cpu
{
Usage
:
totalUtil
,
Model
:
modelname
,
Threads
:
int64
(
thread
)
+
1
,
Cores
:
int64
(
core
)
+
1
,
Usage
:
totalUtil
,
Model
:
modelname
,
Threads
:
int64
(
thread
)
+
1
,
Cores
:
int64
(
core
)
+
1
,
Frequency
:
strings
.
TrimSpace
(
freq
),
}
return
result
,
nil
...
...
docs/swagger.yaml
View file @
b27a2460
...
...
@@ -122,6 +122,8 @@ components:
usage
:
type
:
integer
format
:
int64
frequency
:
type
:
string
GPU
:
type
:
array
items
:
...
...
@@ -135,6 +137,9 @@ components:
free
:
type
:
integer
format
:
int64
mem_util
:
type
:
integer
format
:
int64
DISK
:
type
:
array
items
:
...
...
@@ -204,18 +209,4 @@ components:
power_rt
:
type
:
integer
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
gpu.go
View file @
b27a2460
...
...
@@ -98,6 +98,7 @@ func (c *ProApi) Gpus() ([]Gpu, error) {
for
uuidStr
,
gpu
:=
range
gpuMemFree
{
gpu
.
UUIDStr
=
uuidStr
gpu
.
Performance
=
int64
(
comput
[
gpu
.
Model
])
res
=
append
(
res
,
gpu
)
}
...
...
main.go
View file @
b27a2460
...
...
@@ -289,7 +289,7 @@ type Response struct {
}
type
NewResponse
struct
{
Data
Data
`json:"
data
"`
Data
Data
`json:"
hardware
"`
Code
int
`json:"code"`
Msg
string
`json:"msg"`
}
...
...
mem.go
View file @
b27a2460
...
...
@@ -16,7 +16,7 @@ import (
type
Mem
struct
{
Total
int64
`json:"total"`
Free
int64
`json:"free"`
//
Util int64 `json:"mem_util"`
Util
int64
`json:"mem_util"`
}
func
(
c
*
ProApi
)
Mem
()
(
Mem
,
error
)
{
...
...
@@ -32,16 +32,16 @@ func (c *ProApi) Mem() (Mem, error) {
if
err
!=
nil
{
return
Mem
{},
err
}
//
util, err := c.MemUtil()
util
,
err
:=
c
.
MemUtil
()
//
if err != nil {
//
return Mem{}, err
//
}
if
err
!=
nil
{
return
Mem
{},
err
}
return
Mem
{
Total
:
total
,
Free
:
free
,
//
Util: util,
Util
:
util
,
},
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment