Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COLLET Ismael
Goshimmer_without_tipselection
Commits
fb60fb39
Unverified
Commit
fb60fb39
authored
4 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
afb05103
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/metrics/plugin.go
+2
-6
2 additions, 6 deletions
plugins/metrics/plugin.go
plugins/metrics/process.go
+5
-11
5 additions, 11 deletions
plugins/metrics/process.go
with
7 additions
and
17 deletions
plugins/metrics/plugin.go
+
2
−
6
View file @
fb60fb39
...
...
@@ -43,14 +43,10 @@ func configure(_ *node.Plugin) {
analysisOutboundBytes
.
Add
(
amountBytes
)
}))
metrics
.
Events
()
.
CPUUsage
.
Attach
(
events
.
NewClosure
(
func
(
cpuPercent
float64
)
{
cpuLock
.
Lock
()
defer
cpuLock
.
Unlock
()
_cpuUsage
=
cpuPercent
cpuUsage
.
Store
(
cpuPercent
)
}))
metrics
.
Events
()
.
MemUsage
.
Attach
(
events
.
NewClosure
(
func
(
memAllocBytes
uint64
)
{
memUsageLock
.
Lock
()
defer
memUsageLock
.
Unlock
()
_memUsageBytes
=
memAllocBytes
memUsageBytes
.
Store
(
memAllocBytes
)
}))
metrics
.
Events
()
.
Synced
.
Attach
(
events
.
NewClosure
(
func
(
synced
bool
)
{
syncLock
.
Lock
()
...
...
This diff is collapsed.
Click to expand it.
plugins/metrics/process.go
+
5
−
11
View file @
fb60fb39
...
...
@@ -5,22 +5,18 @@ import (
"time"
"github.com/iotaledger/goshimmer/packages/metrics"
"github.com/iotaledger/hive.go/syncutils"
"github.com/shirou/gopsutil/cpu"
"go.uber.org/atomic"
)
var
(
_cpuUsage
float64
cpuLock
syncutils
.
RWMutex
_memUsageBytes
uint64
memUsageLock
syncutils
.
RWMutex
cpuUsage
atomic
.
Float64
memUsageBytes
atomic
.
Uint64
)
// CpuUsage returns the current cpu usage
func
CpuUsage
()
float64
{
cpuLock
.
RLock
()
defer
cpuLock
.
RUnlock
()
return
_cpuUsage
return
cpuUsage
.
Load
()
}
func
measureCPUUsage
()
{
...
...
@@ -42,7 +38,5 @@ func measureMemUsage() {
// MemUsage returns the current memory allocated as bytes
func
MemUsage
()
uint64
{
memUsageLock
.
RLock
()
defer
memUsageLock
.
RUnlock
()
return
_memUsageBytes
return
memUsageBytes
.
Load
()
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment