-
Notifications
You must be signed in to change notification settings - Fork 18
/
metrics.go
103 lines (93 loc) · 1.84 KB
/
metrics.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
package main
import (
"fmt"
zsend "github.com/blacked/go-zabbix"
)
var (
globalMetrics = []string{
"Aborted_clients",
"Aborted_connects",
"Innodb_rows_deleted",
"Innodb_rows_inserted",
"Innodb_rows_read",
"Innodb_rows_updated",
"Com_begin",
"Com_commit",
"Com_rollback",
"Com_delete",
"Com_insert",
"Com_select",
"Com_update",
"Queries",
"Slow_queries",
"Uptime",
"Threads_running",
"Bytes_received",
"Bytes_sent",
}
galeraMetrics = []string{
"wsrep_cluster_size",
"wsrep_cluster_state_uuid",
"wsrep_gcomm_uuid",
"wsrep_cluster_status",
"wsrep_connected",
"wsrep_evs_state",
"wsrep_evs_repl_latency",
"wsrep_last_committed",
"wsrep_local_bf_aborts",
"wsrep_local_cert_failures",
"wsrep_local_recv_queue",
"wsrep_local_recv_queue_avg",
"wsrep_local_recv_queue_max",
"wsrep_local_recv_queue_min",
"wsrep_local_send_queue",
"wsrep_local_send_queue_avg",
"wsrep_local_send_queue_max",
"wsrep_local_send_queue_min",
"wsrep_local_state",
"wsrep_local_state_comment",
"wsrep_local_state_uuid",
"wsrep_protocol_version",
"wsrep_provider_name",
"wsrep_ready",
}
slaveMetrics = []string{
"Slave_IO_Running",
"Slave_SQL_Running",
"Seconds_Behind_Master",
"Master_Host",
"Master_Port",
}
processMetrics = []string{
"processlist_count",
"query_max_time",
}
)
func makePrefix(prefix, key string) string {
return fmt.Sprintf(
"%s.%s", prefix, key,
)
}
func createMetrics(
hostname string,
stats map[string]string,
statsType string,
filterMetrics []string,
metrics []*zsend.Metric,
prefix string,
) []*zsend.Metric {
for _, filterMetric := range filterMetrics {
metrics = append(
metrics,
zsend.NewMetric(
hostname,
makePrefix(
prefix,
fmt.Sprintf("%s.[%s]", filterMetric, statsType),
),
stats[filterMetric],
),
)
}
return metrics
}