blob: 2422bc98eb11c3e04ee36fc45b0430cdfdf93840 (
plain)
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
|
// SPDX-License-Identifier: GPL-3.0-or-later
package dockerd
import (
"fmt"
"github.com/netdata/netdata/go/go.d.plugin/agent/discovery/sd/model"
)
type targetGroup struct {
source string
targets []model.Target
}
func (g *targetGroup) Provider() string { return "sd:docker" }
func (g *targetGroup) Source() string { return g.source }
func (g *targetGroup) Targets() []model.Target { return g.targets }
type target struct {
model.Base
hash uint64
ID string
Name string
Image string
Command string
Labels map[string]any
PrivatePort string // Port on the container
PublicPort string // Port exposed on the host
PublicPortIP string // Host IP address that the container's port is mapped to
PortProtocol string
NetworkMode string
NetworkDriver string
IPAddress string
Address string // "IPAddress:PrivatePort"
}
func (t *target) TUID() string {
if t.PublicPort != "" {
return fmt.Sprintf("%s_%s_%s_%s_%s_%s",
t.Name, t.IPAddress, t.PublicPortIP, t.PortProtocol, t.PublicPort, t.PrivatePort)
}
if t.PrivatePort != "" {
return fmt.Sprintf("%s_%s_%s_%s",
t.Name, t.IPAddress, t.PortProtocol, t.PrivatePort)
}
return fmt.Sprintf("%s_%s", t.Name, t.IPAddress)
}
func (t *target) Hash() uint64 {
return t.hash
}
|