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
Show 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 (
...
@@ -4,6 +4,7 @@ import (
"context"
"context"
"fmt"
"fmt"
"strconv"
"strconv"
"strings"
"syscall"
"syscall"
"time"
"time"
...
@@ -30,6 +31,7 @@ type Cpu struct {
...
@@ -30,6 +31,7 @@ type Cpu struct {
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
...
...
docs/swagger.yaml
View file @
b27a2460
...
@@ -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
gpu.go
View file @
b27a2460
...
@@ -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
)
}
}
...
...
main.go
View file @
b27a2460
...
@@ -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"`
}
}
...
...
mem.go
View file @
b27a2460
...
@@ -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
}
}
...
...
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