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
79dea08a
Commit
79dea08a
authored
May 27, 2024
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor.dcgm:v.0.0.5
parent
bef83893
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
8 deletions
+18
-8
cpu.go
cpu.go
+16
-6
docker-compose-dcgm.yml
docker-compose-dcgm.yml
+2
-2
monitorapi
test/monitorapi
+0
-0
No files found.
cpu.go
View file @
79dea08a
...
...
@@ -52,7 +52,7 @@ func (c *ProApi) Cpus() (Cpu, error) {
// inCpus := make(map[string]Cpu)
modelname
,
core
,
thread
,
err
:=
c
.
CpuItems
()
modelname
,
packageNum
,
core
,
thread
,
err
:=
c
.
CpuItems
()
if
err
!=
nil
{
return
Cpu
{},
err
}
...
...
@@ -78,13 +78,14 @@ func (c *ProApi) Cpus() (Cpu, error) {
Threads
:
int64
(
thread
)
+
1
,
Cores
:
int64
(
core
),
Frequency
:
strings
.
TrimSpace
(
freq
),
Number
:
int64
(
packageNum
),
}
return
result
,
nil
}
// node_cpu_seconds_total{mode="idle"}
func
(
c
ProApi
)
CpuItems
()
(
string
,
int
,
int
,
error
)
{
func
(
c
ProApi
)
CpuItems
()
(
string
,
int
,
int
,
int
,
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Second
)
defer
cancel
()
...
...
@@ -93,7 +94,7 @@ func (c ProApi) CpuItems() (string, int, int, error) {
result
,
warnings
,
err
:=
c
.
API
.
Query
(
ctx
,
queryParam
,
time
.
Now
(),
v1
.
WithTimeout
(
5
*
time
.
Second
))
if
err
!=
nil
{
return
""
,
0
,
0
,
err
return
""
,
0
,
0
,
0
,
err
}
if
len
(
warnings
)
>
0
{
fmt
.
Printf
(
"Warnings: %v
\n
"
,
warnings
)
...
...
@@ -111,6 +112,8 @@ func (c ProApi) CpuItems() (string, int, int, error) {
countCore
:=
make
(
map
[
string
]
bool
)
packageNum
:=
make
(
map
[
string
]
bool
)
for
k
,
elem
:=
range
vectorVal
{
// int64(elem.Value), nil
...
...
@@ -141,11 +144,18 @@ func (c ProApi) CpuItems() (string, int, int, error) {
continue
}
if
packageNumAsStr
,
ok
:=
elem
.
Metric
[
"package"
];
ok
{
packageNum
[
string
(
packageNumAsStr
)]
=
true
}
else
{
continue
}
if
cpuStr
,
ok
:=
elem
.
Metric
[
"cpu"
];
ok
{
newCpu
,
err
:=
strconv
.
Atoi
(
string
(
cpuStr
))
if
err
!=
nil
{
return
""
,
0
,
0
,
err
return
""
,
0
,
0
,
0
,
err
}
if
newCpu
>
thread
{
...
...
@@ -167,10 +177,10 @@ func (c ProApi) CpuItems() (string, int, int, error) {
// c = c + 1
// }
return
model_name
,
len
(
countCore
),
thread
,
nil
return
model_name
,
len
(
packageNum
),
len
(
countCore
),
thread
,
nil
}
return
""
,
0
,
0
,
errors
.
Errorf
(
"cpu can not find the query %s value"
,
queryParam
)
return
""
,
0
,
0
,
0
,
errors
.
Errorf
(
"cpu can not find the query %s value"
,
queryParam
)
}
...
...
docker-compose-dcgm.yml
View file @
79dea08a
version
:
"
3.9"
services
:
monitor.
multi
:
image
:
docker.ai.17xuexi.com/monitorapi/monitor.dcgm:v.0.0.
4
monitor.
dcgm
:
image
:
docker.ai.17xuexi.com/monitorapi/monitor.dcgm:v.0.0.
5
ports
:
-
9093:9090
-
4000:4000
...
...
test/monitorapi
View file @
79dea08a
No preview for this file type
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