-
Notifications
You must be signed in to change notification settings - Fork 0
/
soliton_monitor.go
155 lines (80 loc) · 2.79 KB
/
soliton_monitor.go
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package Frego
import (
"github.com/prometheus/client_golang/prometheus"
)
type (
executor struct {
ID string `json:"executor_id"`
Name string `json:"executor_name"`
FrameworkID string `json:"framework_id"`
Source string `json:"source"`
Statistics *statistics `json:"statistics"`
Tasks []task `json:"tasks"`
}
statistics struct {
Processes float64 `json:"processes"`
Threads float64 `json:"threads"`
CpusLimit float64 `json:"cpus_limit"`
CpusSystemTimeSecs float64 `json:"cpus_system_time_secs"`
CpusUserTimeSecs float64 `json:"cpus_user_time_secs"`
CpusThrottledTimeSecs float64 `json:"cpus_throttled_time_secs"`
CpusNrPeriods float64 `json:"cpus_nr_periods"`
CpusNrThrottled float64 `json:cpus_nr_throttled`
MemLimitBytes float64 `json:"mem_limit_bytes"`
MemRssBytes float64 `json:"mem_rss_bytes"`
MemTotalBytes float64 `json:"mem_total_bytes"`
MemCacheBytes float64 `json:"mem_cache_bytes"`
MemSwapBytes float64 `json:"mem_swap_bytes"`
DiskLimitBytes float64 `json:"disk_limit_bytes"`
DiskUsedBytes float64 `json:"disk_used_bytes"`
NetRxBytes float64 `json:"net_rx_bytes"`
NetRxDropped float64 `json:"net_rx_dropped"`
NetRxErrors float64 `json:"net_rx_errors"`
NetRxPackets float64 `json:"net_rx_packets"`
NetTxBytes float64 `json:"net_tx_bytes"`
NetTxErrors float64 `json:"net_tx_errors"`
NetTxPackets float64 `json:"net_tx_packets"`
}
slaveCollector struct {
*httpClient
metrics map[*prometheus.Desc]metric
}
metric struct {
valueType prometheus.ValueType
get func(*statistics) float64
}
)
func newSlaveMonitorCollector(http *httpClient) prometheus.Collector {
labels := []string{
"id",
"framework_id",
"source"
}
return &slaveCollector{
httpClient: httpClient,
metrics: map[*prometheus.Desc]metric {
//Processes
prometheus.NewDesc(
"processes",
"Current Number of processes",
labels, nil,
): metric{prometheus.GaugeValue, func(s *statistics) float64 {return s.Processes}},
prometheus.NewDesc(
"threads",
"Current number of threads",
labels, nil,
): metric{prometheus.GaugeValue, func(s *statistics) float64 { return s.Threads}},
//CPU
prometheus.NewDesc(
"cpus_limit",
"Current limit of CPUS for task",
labels, nil,
): metric{[prometheus.GaugeValue, func(s *statistics) float64 { return s.CpusLimit}]},
prometheus.NewDesc(
"cpus_user_seconds_total",
"Total user CPU seconds",
labels, nil
)
}
}
}