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
|
// SPDX-License-Identifier: GPL-3.0-or-later
package example
import (
"fmt"
"github.com/netdata/netdata/go/go.d.plugin/agent/module"
)
var chartTemplate = module.Chart{
ID: "random_%d",
Title: "A Random Number",
Units: "random",
Fam: "random",
Ctx: "example.random",
}
var hiddenChartTemplate = module.Chart{
ID: "hidden_random_%d",
Title: "A Random Number",
Units: "random",
Fam: "random",
Ctx: "example.random",
Opts: module.Opts{
Hidden: true,
},
}
func newChart(num, ctx, labels int, typ module.ChartType) *module.Chart {
chart := chartTemplate.Copy()
chart.ID = fmt.Sprintf(chart.ID, num)
chart.Type = typ
if ctx > 0 {
chart.Ctx += fmt.Sprintf("_%d", ctx)
}
for i := 0; i < labels; i++ {
chart.Labels = append(chart.Labels, module.Label{
Key: fmt.Sprintf("example_name_%d", i),
Value: fmt.Sprintf("example_value_%d_%d", num, i),
})
}
return chart
}
func newHiddenChart(num, ctx, labels int, typ module.ChartType) *module.Chart {
chart := hiddenChartTemplate.Copy()
chart.ID = fmt.Sprintf(chart.ID, num)
chart.Type = typ
if ctx > 0 {
chart.Ctx += fmt.Sprintf("_%d", ctx)
}
for i := 0; i < labels; i++ {
chart.Labels = append(chart.Labels, module.Label{
Key: fmt.Sprintf("example_name_%d", i),
Value: fmt.Sprintf("example_value_%d_%d", num, i),
})
}
return chart
}
|