Add kernel version, Docker version and awsvpc setting to checkpoint info

This commit is contained in:
Bryan Boreham committed 2016-06-14 12:24:37 +01:00
1 parent e1edce84d9
commit 1fe5c65fd4
3 files changed
+41 -3

No files matched your search

+9
View File
@@ -84,6 +84,15 @@ func (c *Client) Info() string {
return fmt.Sprintf("Docker API on %s: %v", c.Endpoint(), env) return fmt.Sprintf("Docker API on %s: %v", c.Endpoint(), env)
} }
func (c *Client) DockerVersion() string {
if env, err := c.Version(); err == nil {
if v, found := env.Map()["Version"]; found {
return v
}
}
return "unknown"
}
// AddObserver adds an observer for docker events // AddObserver adds an observer for docker events
func (c *Client) AddObserver(ob ContainerObserver) error { func (c *Client) AddObserver(ob ContainerObserver) error {
go func() { go func() {
+25 -1
View File
@@ -2,6 +2,7 @@ package main
import ( import (
"sync/atomic" "sync/atomic"
"syscall"
"time" "time"
"github.com/weaveworks/go-checkpoint" "github.com/weaveworks/go-checkpoint"
@@ -14,7 +15,7 @@ const (
updateCheckPeriod = 6 * time.Hour updateCheckPeriod = 6 * time.Hour
) )
func checkForUpdates() { func checkForUpdates(dockerVersion string, network string) {
newVersion.Store("") newVersion.Store("")
handleResponse := func(r *checkpoint.CheckResponse, err error) { handleResponse := func(r *checkpoint.CheckResponse, err error) {
@@ -29,11 +30,34 @@ func checkForUpdates() {
} }
} }
var uts syscall.Utsname
syscall.Uname(&uts)
flags := map[string]string{
"docker-version": dockerVersion,
"kernel-version": charsToString(uts.Release[:]),
}
if network != "" {
flags["network"] = network
}
// Start background version checking // Start background version checking
params := checkpoint.CheckParams{ params := checkpoint.CheckParams{
Product: "weave-net", Product: "weave-net",
Version: version, Version: version,
SignatureFile: "", SignatureFile: "",
Flags: flags,
} }
checker = checkpoint.CheckInterval(&params, updateCheckPeriod, handleResponse) checker = checkpoint.CheckInterval(&params, updateCheckPeriod, handleResponse)
} }
func charsToString(ca []int8) string {
s := make([]byte, len(ca))
i := 0
for ; i < len(ca); i++ {
if ca[i] == 0 {
break
}
s[i] = uint8(ca[i])
}
return string(s[:i])
}
+7 -2
View File
@@ -204,8 +204,6 @@ func main() {
Log.Println("Command line options:", options()) Log.Println("Command line options:", options())
checkForUpdates()
if prof != "" { if prof != "" {
defer profile.Start(profile.CPUProfile, profile.ProfilePath(prof), profile.NoShutdownHook).Stop() defer profile.Start(profile.CPUProfile, profile.ProfilePath(prof), profile.NoShutdownHook).Stop()
} }
@@ -257,6 +255,13 @@ func main() {
} }
dockerCli = dc dockerCli = dc
} }
network := ""
if isAWSVPC {
network = "awsvpc"
}
checkForUpdates(dockerCli.DockerVersion(), network)
observeContainers := func(o docker.ContainerObserver) { observeContainers := func(o docker.ContainerObserver) {
if dockerCli != nil { if dockerCli != nil {
if err := dockerCli.AddObserver(o); err != nil { if err := dockerCli.AddObserver(o); err != nil {