Skip to content

Commit

Permalink
cherry-pick: influxdata#1818
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc committed Mar 12, 2018
1 parent 3b58328 commit 5ba1adb
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/v1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,7 @@ type DebugVars struct {
NumTasks int `json:"num_tasks"`
Memstats map[string]interface{} `json:"memstats"`
Version string `json:"version"`
Platform string `json:"platform"`
}

type Stat struct {
Expand Down
3 changes: 2 additions & 1 deletion cmd/kapacitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,7 @@ func doStats(args []string) error {
fmt.Fprintf(os.Stdout, outFmtNum, "Tasks:", vars.NumTasks)
fmt.Fprintf(os.Stdout, outFmtNum, "Enabled Tasks:", vars.NumEnabledTasks)
fmt.Fprintf(os.Stdout, outFmtNum, "Subscriptions:", vars.NumSubscriptions)
fmt.Fprintf(os.Stdout, outFmtStr, "Platform:", vars.Platform)
fmt.Fprintf(os.Stdout, outFmtStr, "Version:", vars.Version)
case "ingress":
maxDB := 8 // len("Database")
Expand Down Expand Up @@ -2219,7 +2220,7 @@ func versionUsage() {
}

func doVersion(args []string) error {
fmt.Fprintf(os.Stdout, "Kapacitor %s (git: %s %s)\n", version, branch, commit)
fmt.Fprintf(os.Stdout, "Kapacitor OSS %s (git: %s %s)\n", version, branch, commit)
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/kapacitord/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (m *Main) Run(args ...string) error {
cmd.Version = version
cmd.Commit = commit
cmd.Branch = branch
cmd.Platform = "OSS"

err := cmd.Run(args...)
// Use diagnostic from cmd since it may have special config now.
Expand Down Expand Up @@ -198,7 +199,7 @@ func (cmd *VersionCommand) Run(args ...string) error {
}

// Print version info.
fmt.Fprintf(cmd.Stdout, "Kapacitor %s (git: %s %s)\n", version, branch, commit)
fmt.Fprintf(cmd.Stdout, "Kapacitor OSS version %s (git: %s %s)\n", version, branch, commit)

return nil
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/kapacitord/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ type Diagnostic interface {

// Command represents the command executed by "kapacitord run".
type Command struct {
Version string
Branch string
Commit string
Version string
Branch string
Commit string
Platform string

closing chan struct{}
pidfile string
Expand Down Expand Up @@ -122,7 +123,7 @@ func (cmd *Command) Run(args ...string) error {
cmd.pidfile = options.PIDFile

// Create server from config and start it.
buildInfo := server.BuildInfo{Version: cmd.Version, Commit: cmd.Commit, Branch: cmd.Branch}
buildInfo := server.BuildInfo{Version: cmd.Version, Commit: cmd.Commit, Branch: cmd.Branch, Platform: cmd.Platform}
s, err := server.New(config, buildInfo, cmd.diagService)
if err != nil {
return fmt.Errorf("create server: %s", err)
Expand Down
7 changes: 6 additions & 1 deletion integrations/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ type serverInfo struct {

hostname,
version,
product string
product,
platform string

numTasks,
numEnabledTasks,
Expand Down Expand Up @@ -217,6 +218,10 @@ func (i serverInfo) Product() string {
return i.product
}

func (i serverInfo) Platform() string {
return i.platform
}

func (i serverInfo) NumTasks() int64 {
return i.numTasks
}
Expand Down
8 changes: 5 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ const serverIDFilename = "server.id"

// BuildInfo represents the build details for the server code.
type BuildInfo struct {
Version string
Commit string
Branch string
Version string
Commit string
Branch string
Platform string
}

type Diagnostic interface {
Expand Down Expand Up @@ -184,6 +185,7 @@ func New(c *Config, buildInfo BuildInfo, diagService *diagnostic.Service) (*Serv
vars.ServerIDVar.Set(s.ServerID)
vars.HostVar.Set(s.hostname)
vars.ProductVar.Set(vars.Product)
vars.PlatformVar.Set(s.BuildInfo.Platform)
vars.VersionVar.Set(s.BuildInfo.Version)
s.Diag.Info("listing ClusterID and ServerID",
keyvalue.KV("cluster_id", s.ClusterID.String()), keyvalue.KV("server_id", s.ServerID.String()))
Expand Down
7 changes: 7 additions & 0 deletions server/vars/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
HostVarName = "host"
ProductVarName = "product"
VersionVarName = "version"
PlatformVarName = "platform"

NumTasksVarName = "num_tasks"
NumEnabledTasksVarName = "num_enabled_tasks"
Expand All @@ -37,6 +38,7 @@ var (
HostVar = &kexpvar.String{}
ProductVar = &kexpvar.String{}
VersionVar = &kexpvar.String{}
PlatformVar = &kexpvar.String{}
)

var (
Expand All @@ -55,6 +57,7 @@ func init() {
expvar.Publish(HostVarName, HostVar)
expvar.Publish(ProductVarName, ProductVar)
expvar.Publish(VersionVarName, VersionVar)
expvar.Publish(PlatformVarName, PlatformVar)
}

func uptime() time.Duration {
Expand All @@ -67,6 +70,7 @@ type Infoer interface {
Hostname() string
Version() string
Product() string
Platform() string
NumTasks() int64
NumEnabledTasks() int64
NumSubscriptions() int64
Expand All @@ -92,6 +96,9 @@ func (info) Version() string {
func (info) Product() string {
return ProductVar.StringValue()
}
func (info) Platform() string {
return PlatformVar.StringValue()
}

func (info) NumTasks() int64 {
return NumTasksVar.IntValue()
Expand Down

0 comments on commit 5ba1adb

Please sign in to comment.