Newer
Older
Angelo Capossele
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package prometheus
import (
"github.com/iotaledger/goshimmer/plugins/autopeering"
"github.com/iotaledger/goshimmer/plugins/metrics"
"github.com/prometheus/client_golang/prometheus"
)
var (
fpcInboundBytes prometheus.Gauge
fpcOutboundBytes prometheus.Gauge
analysisOutboundBytes prometheus.Gauge
gossipInboundBytes prometheus.Gauge
gossipOutboundBytes prometheus.Gauge
autopeeringInboundBytes prometheus.Gauge
autopeeringOutboundBytes prometheus.Gauge
)
func registerNetworkMetrics() {
fpcInboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "traffic_fpc_inbound_bytes",
Help: "FPC RX network traffic [bytes].",
})
fpcOutboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "traffic_fpc_outbound_bytes",
Help: "FPC TX network traffic [bytes].",
})
autopeeringInboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "traffic_autopeering_inbound_bytes",
Help: "traffic_autopeering RX network traffic [bytes].",
})
autopeeringOutboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "traffic_autopeering_outbound_bytes",
Help: "traffic_autopeering TX network traffic [bytes].",
})
gossipInboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "traffic_gossip_inbound_bytes",
Help: "traffic_gossip RX network traffic [bytes].",
})
gossipOutboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "traffic_gossip_outbound_bytes",
Help: "traffic_gossip TX network traffic [bytes].",
})
analysisOutboundBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "traffic_analysis_outbound_bytes",
Help: "traffic_Analysis client TX network traffic [bytes].",
})
registry.MustRegister(fpcInboundBytes)
registry.MustRegister(fpcOutboundBytes)
registry.MustRegister(analysisOutboundBytes)
registry.MustRegister(autopeeringInboundBytes)
registry.MustRegister(autopeeringOutboundBytes)
registry.MustRegister(gossipInboundBytes)
registry.MustRegister(gossipOutboundBytes)
addCollect(collectNetworkMetrics)
}
func collectNetworkMetrics() {
fpcInboundBytes.Set(float64(metrics.FPCInboundBytes()))
fpcOutboundBytes.Set(float64(metrics.FPCOutboundBytes()))
analysisOutboundBytes.Set(float64(metrics.AnalysisOutboundBytes()))
autopeeringInboundBytes.Set(float64(autopeering.Conn.RXBytes()))
autopeeringOutboundBytes.Set(float64(autopeering.Conn.TXBytes()))
gossipInboundBytes.Set(float64(metrics.GossipInboundBytes()))
gossipOutboundBytes.Set(float64(metrics.GossipOutboundBytes()))
}