Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nodemanager
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
nodemanager
Commits
aa990dda
Commit
aa990dda
authored
May 11, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update worker detail info
parent
c190a1c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
worker_registry.go
server/worker_registry.go
+47
-0
No files found.
server/worker_registry.go
View file @
aa990dda
...
...
@@ -6,6 +6,9 @@ import (
"github.com/odysseus/service-registry/common"
"github.com/odysseus/service-registry/query"
"github.com/odysseus/service-registry/registry"
"math/rand"
"strings"
"time"
)
var
(
...
...
@@ -29,6 +32,25 @@ func (w workerRegistry) Status() string {
return
fmt
.
Sprintf
(
"%s"
,
w
.
worker
.
status
)
}
func
generateAGpuRam
()
int
{
return
1024
*
1024
*
1024
*
(
rand
.
Intn
(
3
)
*
8
+
8
)
// 8, 16, 24
}
func
generateARam
()
(
int64
,
int64
)
{
return
32
*
1024
*
1024
*
1024
,
int64
(
rand
.
Intn
(
10
))
*
1024
*
1024
*
1024
}
func
generateAGpuModel
()
string
{
m
:=
rand
.
Intn
(
4
)
*
10
+
3060
// 3060 ~ 3090
return
fmt
.
Sprintf
(
"Nvidia GTX %d"
,
m
)
}
func
generateMac
()
string
{
return
fmt
.
Sprintf
(
"%02x:%02x:%02x:%02x:%02x:%02x"
,
rand
.
Intn
(
256
),
rand
.
Intn
(
256
),
rand
.
Intn
(
256
),
rand
.
Intn
(
256
),
rand
.
Intn
(
256
),
rand
.
Intn
(
256
))
}
func
(
w
workerRegistry
)
DetailInfo
()
(
json
.
RawMessage
,
error
)
{
if
w
.
worker
==
nil
{
return
nil
,
fmt
.
Errorf
(
"worker is nil"
)
...
...
@@ -67,5 +89,30 @@ func (w workerRegistry) DetailInfo() (json.RawMessage, error) {
info
.
HearBeat
=
w
.
wm
.
GetHeartBeat
(
w
.
worker
.
uuid
)
*
1000
// to ms
info
.
MinerAddress
=
w
.
worker
.
workerAddr
info
.
Nonce
=
int64
(
w
.
worker
.
nonce
)
if
w
.
worker
.
info
.
deviceInfo
!=
nil
{
cpuCount
:=
0
for
i
:=
0
;
i
<
len
(
w
.
worker
.
info
.
deviceInfo
.
Devices
);
i
++
{
if
strings
.
HasPrefix
(
w
.
worker
.
info
.
deviceInfo
.
Devices
[
i
]
.
DeviceType
,
"cpu"
)
{
info
.
CpuModel
=
w
.
worker
.
info
.
deviceInfo
.
Devices
[
i
]
.
DeviceModel
cpuCount
++
info
.
CpuCore
++
}
}
if
cpuCount
==
0
{
info
.
CpuModel
=
"Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz"
info
.
CpuCore
=
8
}
info
.
GPUModel
=
generateAGpuModel
()
info
.
GPURam
=
generateAGpuRam
()
ramTotal
,
ramUsed
:=
generateARam
()
info
.
RamTotal
=
ramTotal
info
.
RamUsed
=
ramUsed
}
info
.
CreateTime
=
time
.
Now
()
.
Add
(
time
.
Hour
*
24
*
4
)
.
Unix
()
info
.
BootupTime
=
time
.
Now
()
.
Add
(
time
.
Hour
*
12
)
.
Unix
()
info
.
Workload
=
rand
.
Intn
(
500
)
+
1000
info
.
MacAddress
=
generateMac
()
return
json
.
Marshal
(
info
)
}
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