Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goshimmer
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
iota-imt
goshimmer
Commits
c9d53013
Unverified
Commit
c9d53013
authored
5 years ago
by
bingyanglin
Browse files
Options
Downloads
Patches
Plain Diff
correct modularization
parent
4bb43dc2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/dashboard/plugin.go
+18
-0
18 additions, 0 deletions
plugins/dashboard/plugin.go
plugins/metrics/dashboard.html
+0
-315
0 additions, 315 deletions
plugins/metrics/dashboard.html
plugins/metrics/plugin.go
+1
-10
1 addition, 10 deletions
plugins/metrics/plugin.go
with
19 additions
and
325 deletions
plugins/dashboard/
server
.go
→
plugins/dashboard/
plugin
.go
+
18
−
0
View file @
c9d53013
...
@@ -5,7 +5,10 @@ import (
...
@@ -5,7 +5,10 @@ import (
"log"
"log"
"net/http"
"net/http"
"runtime"
"runtime"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
"github.com/iotaledger/goshimmer/packages/daemon"
"github.com/iotaledger/goshimmer/packages/node"
)
)
var
(
var
(
...
@@ -58,6 +61,21 @@ func ServeHome(w http.ResponseWriter, r *http.Request) {
...
@@ -58,6 +61,21 @@ func ServeHome(w http.ResponseWriter, r *http.Request) {
homeTempl
.
Execute
(
w
,
&
v
)
homeTempl
.
Execute
(
w
,
&
v
)
}
}
func
configure
(
plugin
*
node
.
Plugin
)
{
}
func
run
(
plugin
*
node
.
Plugin
)
{
plugin
.
LogInfo
(
"Starting XXXXX ..."
)
daemon
.
BackgroundWorker
(
"Dashboard Updater"
,
func
()
{
http
.
HandleFunc
(
"/dashboard"
,
ServeHome
)
http
.
HandleFunc
(
"/ws"
,
ServeWs
)
if
err
:=
http
.
ListenAndServe
(
":8081"
,
nil
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
})
}
var
PLUGIN
=
node
.
NewPlugin
(
"Dashboard"
,
configure
,
run
)
var
TPSQ
[]
uint32
var
TPSQ
[]
uint32
var
dashboardHTML
=
`
var
dashboardHTML
=
`
<!DOCTYPE html>
<!DOCTYPE html>
...
...
This diff is collapsed.
Click to expand it.
plugins/metrics/dashboard.html
deleted
100644 → 0
+
0
−
315
View file @
4bb43dc2
<!DOCTYPE html>
<html>
<head>
<script
src=
"https://code.jquery.com/jquery-3.1.1.min.js"
></script>
<script
src=
"https://code.highcharts.com/stock/highstock.js"
></script>
<script
src=
"https://code.highcharts.com/stock/modules/exporting.js"
></script>
<script
src=
"https://code.highcharts.com/stock/modules/export-data.js"
></script>
<div
id=
"container"
style=
"height: 400px; min-width: 310px"
></div>
</head>
<body>
<script>
Highcharts
.
createElement
(
'
link
'
,
{
href
:
'
https://fonts.googleapis.com/css?family=Unica+One
'
,
rel
:
'
stylesheet
'
,
type
:
'
text/css
'
},
null
,
document
.
getElementsByTagName
(
'
head
'
)[
0
]);
Highcharts
.
theme
=
{
colors
:
[
'
#2b908f
'
,
'
#90ee7e
'
,
'
#f45b5b
'
,
'
#7798BF
'
,
'
#aaeeee
'
,
'
#ff0066
'
,
'
#eeaaee
'
,
'
#55BF3B
'
,
'
#DF5353
'
,
'
#7798BF
'
,
'
#aaeeee
'
],
chart
:
{
backgroundColor
:
{
linearGradient
:
{
x1
:
0
,
y1
:
0
,
x2
:
1
,
y2
:
1
},
stops
:
[
[
0
,
'
#2a2a2b
'
],
[
1
,
'
#3e3e40
'
]
]
},
// style: {
// fontFamily: 'sans-serif'
// },
plotBorderColor
:
'
#606063
'
},
title
:
{
style
:
{
color
:
'
#E0E0E3
'
,
// textTransform: 'uppercase',
fontSize
:
'
20px
'
}
},
subtitle
:
{
style
:
{
color
:
'
#E0E0E3
'
,
// textTransform: 'uppercase'
}
},
xAxis
:
{
gridLineColor
:
'
#707073
'
,
labels
:
{
style
:
{
color
:
'
#E0E0E3
'
}
},
lineColor
:
'
#707073
'
,
minorGridLineColor
:
'
#505053
'
,
tickColor
:
'
#707073
'
,
title
:
{
style
:
{
color
:
'
#A0A0A3
'
}
}
},
yAxis
:
{
gridLineColor
:
'
#707073
'
,
labels
:
{
style
:
{
color
:
'
#E0E0E3
'
}
},
lineColor
:
'
#707073
'
,
minorGridLineColor
:
'
#505053
'
,
tickColor
:
'
#707073
'
,
tickWidth
:
1
,
title
:
{
style
:
{
color
:
'
#A0A0A3
'
}
}
},
tooltip
:
{
backgroundColor
:
'
rgba(0, 0, 0, 0.85)
'
,
style
:
{
color
:
'
#F0F0F0
'
}
},
plotOptions
:
{
series
:
{
dataLabels
:
{
color
:
'
#B0B0B3
'
},
marker
:
{
lineColor
:
'
#333
'
}
},
boxplot
:
{
fillColor
:
'
#505053
'
},
candlestick
:
{
lineColor
:
'
white
'
},
errorbar
:
{
color
:
'
white
'
}
},
legend
:
{
itemStyle
:
{
color
:
'
#E0E0E3
'
},
itemHoverStyle
:
{
color
:
'
#FFF
'
},
itemHiddenStyle
:
{
color
:
'
#606063
'
}
},
credits
:
{
style
:
{
color
:
'
#666
'
}
},
labels
:
{
style
:
{
color
:
'
#707073
'
}
},
drilldown
:
{
activeAxisLabelStyle
:
{
color
:
'
#F0F0F3
'
},
activeDataLabelStyle
:
{
color
:
'
#F0F0F3
'
}
},
navigation
:
{
buttonOptions
:
{
symbolStroke
:
'
#DDDDDD
'
,
theme
:
{
fill
:
'
#505053
'
}
}
},
// scroll charts
rangeSelector
:
{
buttonTheme
:
{
fill
:
'
#505053
'
,
stroke
:
'
#000000
'
,
style
:
{
color
:
'
#CCC
'
},
states
:
{
hover
:
{
fill
:
'
#707073
'
,
stroke
:
'
#000000
'
,
style
:
{
color
:
'
white
'
}
},
select
:
{
fill
:
'
#000003
'
,
stroke
:
'
#000000
'
,
style
:
{
color
:
'
white
'
}
}
}
},
inputBoxBorderColor
:
'
#505053
'
,
inputStyle
:
{
backgroundColor
:
'
#333
'
,
color
:
'
silver
'
},
labelStyle
:
{
color
:
'
silver
'
}
},
navigator
:
{
handles
:
{
backgroundColor
:
'
#666
'
,
borderColor
:
'
#AAA
'
},
outlineColor
:
'
#CCC
'
,
maskFill
:
'
rgba(255,255,255,0.1)
'
,
series
:
{
color
:
'
#7798BF
'
,
lineColor
:
'
#A6C7ED
'
},
xAxis
:
{
gridLineColor
:
'
#505053
'
}
},
scrollbar
:
{
barBackgroundColor
:
'
#808083
'
,
barBorderColor
:
'
#808083
'
,
buttonArrowColor
:
'
#CCC
'
,
buttonBackgroundColor
:
'
#606063
'
,
buttonBorderColor
:
'
#606063
'
,
rifleColor
:
'
#FFF
'
,
trackBackgroundColor
:
'
#404043
'
,
trackBorderColor
:
'
#404043
'
},
// special colors for some of the
legendBackgroundColor
:
'
rgba(0, 0, 0, 0.5)
'
,
background2
:
'
#505053
'
,
dataLabelsColor
:
'
#B0B0B3
'
,
textColor
:
'
#C0C0C0
'
,
contrastTextColor
:
'
#F0F0F3
'
,
maskColor
:
'
rgba(255,255,255,0.3)
'
};
// Apply the theme
Highcharts
.
setOptions
(
Highcharts
.
theme
);
// Start Here
var
time
=
Date
.
now
()
-
3000
;
var
start_draw
=
time
+
5000
;
const
update_rate
=
5
;
var
counter
=
0
;
data
=
[[
time
-
5000
,
0
]];
var
tzoffset
=
new
Date
().
getTimezoneOffset
();
var
chart
=
Highcharts
.
stockChart
(
'
container
'
,
{
rangeSelector
:
{
selected
:
1
},
title
:
{
text
:
'
Transactions per second
'
},
time
:
{
timezoneOffset
:
tzoffset
},
rangeSelector
:
{
buttons
:
[
{
type
:
'
minute
'
,
count
:
5
,
text
:
'
5m
'
},
{
type
:
'
minute
'
,
count
:
15
,
text
:
'
15m
'
},
{
type
:
'
minute
'
,
count
:
30
,
text
:
'
30m
'
},
{
type
:
'
hour
'
,
count
:
60
,
text
:
'
1h
'
}],
inputEnabled
:
false
},
series
:
[{
name
:
'
Transactions per second
'
,
data
:
data
,
type
:
'
areaspline
'
,
threshold
:
null
,
tooltip
:
{
valueDecimals
:
0
},
fillColor
:
{
linearGradient
:
{
x1
:
0
,
y1
:
0
,
x2
:
0
,
y2
:
1
},
stops
:
[
[
0
,
Highcharts
.
getOptions
().
colors
[
0
]],
[
1
,
Highcharts
.
Color
(
Highcharts
.
getOptions
().
colors
[
0
]).
setOpacity
(
0
).
get
(
'
rgba
'
)]
]
}
}]
});
const
conn
=
new
WebSocket
(
"
ws://{{.Host}}/ws
"
);
conn
.
binaryType
=
'
arraybuffer
'
;
conn
.
onopen
=
evt
=>
{
console
.
log
(
"
WebSocket is open now.
"
);
const
dataStr
=
'
{{.Data}}
'
const
data
=
JSON
.
parse
(
dataStr
.
replace
(
/ /g
,
'
,
'
));
time
=
Date
.
now
()
-
1000
*
(
data
.
length
+
1
);
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
chart
.
series
[
0
].
addPoint
([
time
+=
1000
,
parseInt
(
data
[
i
],
10
)],
true
);
}
console
.
log
(
data
);
console
.
log
(
"
WebSocket done.
"
);
}
conn
.
onclose
=
()
=>
{
// console.log('Connection closed');
}
conn
.
onmessage
=
evt
=>
{
console
.
log
(
'
metric updated
'
);
const
data
=
evt
.
data
;
const
dv
=
new
DataView
(
data
);
// var value = dv.getUint32(4, true)
<<
32
|
dv
.
getUint32
(
0
,
true
);
const
value
=
dv
.
getUint32
(
0
,
true
);
chart
.
series
[
0
].
addPoint
([
time
+=
1000
,
value
],
true
);
//((counter += 1) % update_rate == 4));
console
.
log
(
value
);
console
.
log
(
dv
);
}
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
plugins/metrics/plugin.go
+
1
−
10
View file @
c9d53013
...
@@ -2,8 +2,6 @@ package metrics
...
@@ -2,8 +2,6 @@ package metrics
import
(
import
(
"encoding/binary"
"encoding/binary"
"log"
"net/http"
"time"
"time"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
...
@@ -12,8 +10,8 @@ import (
...
@@ -12,8 +10,8 @@ import (
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/node"
"github.com/iotaledger/goshimmer/packages/node"
"github.com/iotaledger/goshimmer/packages/timeutil"
"github.com/iotaledger/goshimmer/packages/timeutil"
"github.com/iotaledger/goshimmer/plugins/gossip"
"github.com/iotaledger/goshimmer/plugins/dashboard"
"github.com/iotaledger/goshimmer/plugins/dashboard"
"github.com/iotaledger/goshimmer/plugins/gossip"
)
)
// create configure handler (get's called when the PLUGIN is "loaded" by the node)
// create configure handler (get's called when the PLUGIN is "loaded" by the node)
...
@@ -42,13 +40,6 @@ func configure(plugin *node.Plugin) {
...
@@ -42,13 +40,6 @@ func configure(plugin *node.Plugin) {
func
run
(
plugin
*
node
.
Plugin
)
{
func
run
(
plugin
*
node
.
Plugin
)
{
// create a background worker that "measures" the TPS value every second
// create a background worker that "measures" the TPS value every second
daemon
.
BackgroundWorker
(
"Metrics TPS Updater"
,
func
()
{
timeutil
.
Ticker
(
measureReceivedTPS
,
1
*
time
.
Second
)
})
daemon
.
BackgroundWorker
(
"Metrics TPS Updater"
,
func
()
{
timeutil
.
Ticker
(
measureReceivedTPS
,
1
*
time
.
Second
)
})
daemon
.
BackgroundWorker
(
"Dashboard Updater"
,
func
()
{
http
.
HandleFunc
(
"/dashboard"
,
dashboard
.
ServeHome
)
http
.
HandleFunc
(
"/ws"
,
dashboard
.
ServeWs
)
if
err
:=
http
.
ListenAndServe
(
":8081"
,
nil
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
})
}
}
// export plugin
// export plugin
...
...
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