Skip to content

Commit

Permalink
Merge pull request #16 from bobrik/tls
Browse files Browse the repository at this point in the history
Support for TLS connections to docker
  • Loading branch information
bobrik committed Aug 16, 2015
2 parents 3a0ed70 + af360ca commit 02210dd
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions collector/cmd/collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,37 @@ import (

"github.com/bobrik/collectd-docker/collector"
"github.com/fsouza/go-dockerclient"
"path"
)

func main() {
endpoint := flag.String("endpoint", "unix:///var/run/docker.sock", "docker endpoint")
host := flag.String("host", "", "host to report")
interval := flag.Int("interval", 1, "interval to report")
e := flag.String("endpoint", "unix:///var/run/docker.sock", "docker endpoint")
c := flag.String("cert", "", "cert path for tls")
h := flag.String("host", "", "host to report")
i := flag.Int("interval", 1, "interval to report")
flag.Parse()

if *host == "" {
if *h == "" {
flag.PrintDefaults()
os.Exit(1)
}

client, err := docker.NewClient(*endpoint)
var client *docker.Client
var err error

if *c != "" {
client, err = docker.NewTLSClient(*e, path.Join(*c, "cert.pem"), path.Join(*c, "key.pem"), path.Join(*c, "ca.pem"))
} else {
client, err = docker.NewClient(*e)
}

if err != nil {
log.Fatal(err)
}

writer := collector.NewCollectdWriter(*host, os.Stdout)
writer := collector.NewCollectdWriter(*h, os.Stdout)

collector := collector.NewCollector(client, writer, *interval)
collector := collector.NewCollector(client, writer, *i)

err = collector.Run(5)
if err != nil {
Expand Down

0 comments on commit 02210dd

Please sign in to comment.