diff --git a/app/router.go b/app/router.go
index 3d142f588..ab8b6f260 100644
--- a/app/router.go
+++ b/app/router.go
@@ -11,6 +11,7 @@ import (
"github.com/PuerkitoBio/ghost/handlers"
"github.com/gorilla/mux"
+ "github.com/weaveworks/scope/common/hostname"
"github.com/weaveworks/scope/report"
"github.com/weaveworks/scope/xfer"
)
@@ -105,5 +106,9 @@ func makeReportPostHandler(a Adder) http.HandlerFunc {
}
func apiHandler(w http.ResponseWriter, r *http.Request) {
- respondWith(w, http.StatusOK, xfer.Details{ID: uniqueID, Version: version})
+ respondWith(w, http.StatusOK, xfer.Details{
+ ID: uniqueID,
+ Version: version,
+ Hostname: hostname.Get(),
+ })
}
diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js
index 6dc3c3250..491f33a71 100644
--- a/client/app/scripts/actions/app-actions.js
+++ b/client/app/scripts/actions/app-actions.js
@@ -167,6 +167,7 @@ export function receiveTopologies(topologies) {
export function receiveApiDetails(apiDetails) {
AppDispatcher.dispatch({
type: ActionTypes.RECEIVE_API_DETAILS,
+ hostname: apiDetails.hostname,
version: apiDetails.version
});
}
diff --git a/client/app/scripts/components/app.js b/client/app/scripts/components/app.js
index 6f6e7af3c..de024c07f 100644
--- a/client/app/scripts/components/app.js
+++ b/client/app/scripts/components/app.js
@@ -25,6 +25,7 @@ function getStateFromStores() {
errorUrl: AppStore.getErrorUrl(),
highlightedEdgeIds: AppStore.getHighlightedEdgeIds(),
highlightedNodeIds: AppStore.getHighlightedNodeIds(),
+ hostname: AppStore.getHostname(),
selectedNodeId: AppStore.getSelectedNodeId(),
nodeDetails: AppStore.getNodeDetails(),
nodes: AppStore.getNodes(),
@@ -68,7 +69,7 @@ export default class App extends React.Component {
render() {
const showingDetails = this.state.selectedNodeId;
- const versionString = this.state.version ? 'Version ' + this.state.version : '';
+ const footer = `Version ${this.state.version} on ${this.state.hostname}`;
// width of details panel blocking a view
const detailsWidth = showingDetails ? 450 : 0;
const topMargin = 100;
@@ -101,7 +102,7 @@ export default class App extends React.Component {
diff --git a/client/app/scripts/stores/app-store.js b/client/app/scripts/stores/app-store.js
index 1a2a956f7..d01d158b3 100644
--- a/client/app/scripts/stores/app-store.js
+++ b/client/app/scripts/stores/app-store.js
@@ -51,7 +51,8 @@ let controlPending = false;
let currentTopology = null;
let currentTopologyId = 'containers';
let errorUrl = null;
-let version = '';
+let hostname = '...';
+let version = '...';
let mouseOverEdgeId = null;
let mouseOverNodeId = null;
let nodes = makeOrderedMap();
@@ -198,6 +199,10 @@ export class AppStore extends Store {
return null;
}
+ getHostname() {
+ return hostname;
+ }
+
getNodeDetails() {
return nodeDetails;
}
@@ -403,6 +408,7 @@ export class AppStore extends Store {
case ActionTypes.RECEIVE_API_DETAILS:
errorUrl = null;
+ hostname = payload.hostname;
version = payload.version;
this.__emitChange();
break;
diff --git a/probe/hostname.go b/common/hostname/hostname.go
similarity index 68%
rename from probe/hostname.go
rename to common/hostname/hostname.go
index 305e6beea..799dcea90 100644
--- a/probe/hostname.go
+++ b/common/hostname/hostname.go
@@ -1,9 +1,9 @@
-package probe
+package hostname
import "os"
-// Hostname returns the hostname of this host.
-func Hostname() string {
+// Get returns the hostname of this host.
+func Get() string {
if hostname := os.Getenv("SCOPE_HOSTNAME"); hostname != "" {
return hostname
}
diff --git a/prog/probe/main.go b/prog/probe/main.go
index 33d4c6636..553d58d04 100644
--- a/prog/probe/main.go
+++ b/prog/probe/main.go
@@ -16,6 +16,7 @@ import (
"github.com/armon/go-metrics"
"github.com/weaveworks/weave/common"
+ "github.com/weaveworks/scope/common/hostname"
"github.com/weaveworks/scope/probe"
"github.com/weaveworks/scope/probe/controls"
"github.com/weaveworks/scope/probe/docker"
@@ -78,7 +79,7 @@ func main() {
rand.Seed(time.Now().UnixNano())
probeID := strconv.FormatInt(rand.Int63(), 16)
var (
- hostName = probe.Hostname()
+ hostName = hostname.Get()
hostID = hostName // TODO(pb): we should sanitize the hostname
)
log.Printf("probe starting, version %s, ID %s", version, probeID)
diff --git a/xfer/app_client.go b/xfer/app_client.go
index 1b1fd579d..da6998683 100644
--- a/xfer/app_client.go
+++ b/xfer/app_client.go
@@ -15,8 +15,9 @@ import (
// Details are some generic details that can be fetched from /api
type Details struct {
- ID string `json:"id"`
- Version string `json:"version"`
+ ID string `json:"id"`
+ Version string `json:"version"`
+ Hostname string `json:"hostname"`
}
// AppClient is a client to an app for dealing with controls.