From: Simon J Mudd Date: Fri, 21 Nov 2014 23:21:11 +0000 (+0100) Subject: Show only short hostname to save a bit of space X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=f683c005fec63d4c8d6b4ca5f27879b416b35ce1;p=pstop.git Show only short hostname to save a bit of space --- diff --git a/state/state.go b/state/state.go index 90c3f7d..0bacb2e 100644 --- a/state/state.go +++ b/state/state.go @@ -6,6 +6,7 @@ package state import ( "database/sql" "fmt" + "strings" "time" "github.com/sjmudd/pstop/lib" @@ -65,7 +66,11 @@ func (state *State) Setup(dbh *sql.DB) { state.show = showLatency state.tiwsbt.SetWantsLatency(true) + // get short name (to save space) _, hostname := lib.SelectGlobalVariableByVariableName(state.dbh, "HOSTNAME") + if index := strings.Index(hostname, "."); index >= 0 { + hostname = hostname[0:index] + } _, mysql_version := lib.SelectGlobalVariableByVariableName(state.dbh, "VERSION") _, datadir := lib.SelectGlobalVariableByVariableName(state.dbh, "DATADIR") state.SetHostname(hostname)