diff options
-rw-r--r-- | .travis.yml | 9 | ||||
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | cmd/geth/monitorcmd.go | 88 |
3 files changed, 61 insertions, 43 deletions
diff --git a/.travis.yml b/.travis.yml index 11daadd41..ff3ff71f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: go go: - 1.4.2 before_install: - - sudo add-apt-repository ppa:beineri/opt-qt541 -y - sudo apt-get update -qq - sudo apt-get install -yqq libgmp3-dev install: @@ -22,14 +21,12 @@ after_success: - if [ "$COVERALLS_TOKEN" ]; then goveralls -coverprofile=profile.cov -service=travis-ci -repotoken $COVERALLS_TOKEN; fi env: global: - - PKG_CONFIG_PATH=/opt/qt54/lib/pkgconfig - - LD_LIBRARY_PATH=/opt/qt54/lib - secure: "U2U1AmkU4NJBgKR/uUAebQY87cNL0+1JHjnLOmmXwxYYyj5ralWb1aSuSH3qSXiT93qLBmtaUkuv9fberHVqrbAeVlztVdUsKAq7JMQH+M99iFkC9UiRMqHmtjWJ0ok4COD1sRYixxi21wb/JrMe3M1iL4QJVS61iltjHhVdM64=" notifications: webhooks: urls: - https://webhooks.gitter.im/e/e09ccdce1048c5e03445 - on_success: change # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: false # default: false + on_success: change + on_failure: always + on_start: false @@ -44,11 +44,10 @@ Executables Go Ethereum comes with several wrappers/executables found in [the `cmd` directory](https://github.com/ethereum/go-ethereum/tree/develop/cmd): -* `mist` Official Ethereum Browser (ethereum GUI client) * `geth` Ethereum CLI (ethereum command line interface client) * `bootnode` runs a bootstrap node for the Discovery Protocol -* `ethtest` test tool which runs with the [tests](https://github.com/ethereum/testes) suite: - `cat file | ethtest`. +* `ethtest` test tool which runs with the [tests](https://github.com/ethereum/tests) suite: + `/path/to/test.json > ethtest --test BlockTests --stdin`. * `evm` is a generic Ethereum Virtual Machine: `evm -code 60ff60ff -gas 10000 -price 0 -dump`. See `-h` for a detailed description. * `disasm` disassembles EVM code: `echo "6001" | disasm` @@ -57,7 +56,7 @@ Go Ethereum comes with several wrappers/executables found in Command line options ==================== -Both `mist` and `geth` can be configured via command line options, environment variables and config files. +`geth` can be configured via command line options, environment variables and config files. To get the options available: diff --git a/cmd/geth/monitorcmd.go b/cmd/geth/monitorcmd.go index bb9c61a00..fe771b561 100644 --- a/cmd/geth/monitorcmd.go +++ b/cmd/geth/monitorcmd.go @@ -103,33 +103,17 @@ func monitor(ctx *cli.Context) { footer.Height = 3 charts := make([]*termui.LineChart, len(monitored)) + units := make([]int, len(monitored)) data := make([][]float64, len(monitored)) - for i := 0; i < len(data); i++ { - data[i] = make([]float64, 512) - } - for i, metric := range monitored { - charts[i] = termui.NewLineChart() - if runtime.GOOS == "windows" { - charts[i].Mode = "dot" - } - charts[i].Data = make([]float64, 512) - charts[i].DataLabels = []string{""} - charts[i].Height = (termui.TermHeight() - footer.Height) / rows - charts[i].AxesColor = termui.ColorWhite - charts[i].PaddingBottom = -2 - - charts[i].Border.Label = metric - charts[i].Border.LabelFgColor = charts[i].Border.FgColor | termui.AttrBold - charts[i].Border.FgColor = charts[i].Border.BgColor - + for i := 0; i < len(monitored); i++ { + charts[i] = createChart((termui.TermHeight() - footer.Height) / rows) row := termui.Body.Rows[i%rows] row.Cols = append(row.Cols, termui.NewCol(12/cols, 0, charts[i])) } termui.Body.AddRows(termui.NewRow(termui.NewCol(12, 0, footer))) - termui.Body.Align() - termui.Render(termui.Body) - refreshCharts(xeth, monitored, data, charts, ctx, footer) + refreshCharts(xeth, monitored, data, units, charts, ctx, footer) + termui.Body.Align() termui.Render(termui.Body) // Watch for various system events, and periodically refresh the charts @@ -149,7 +133,9 @@ func monitor(ctx *cli.Context) { termui.Render(termui.Body) } case <-refresh: - refreshCharts(xeth, monitored, data, charts, ctx, footer) + if refreshCharts(xeth, monitored, data, units, charts, ctx, footer) { + termui.Body.Align() + } termui.Render(termui.Body) } } @@ -246,45 +232,63 @@ func fetchMetric(metrics map[string]interface{}, metric string) float64 { // refreshCharts retrieves a next batch of metrics, and inserts all the new // values into the active datasets and charts -func refreshCharts(xeth *rpc.Xeth, metrics []string, data [][]float64, charts []*termui.LineChart, ctx *cli.Context, footer *termui.Par) { +func refreshCharts(xeth *rpc.Xeth, metrics []string, data [][]float64, units []int, charts []*termui.LineChart, ctx *cli.Context, footer *termui.Par) (realign bool) { values, err := retrieveMetrics(xeth) for i, metric := range metrics { - data[i] = append([]float64{fetchMetric(values, metric)}, data[i][:len(data[i])-1]...) - updateChart(metric, data[i], charts[i], err) + if len(data) < 512 { + data[i] = append([]float64{fetchMetric(values, metric)}, data[i]...) + } else { + data[i] = append([]float64{fetchMetric(values, metric)}, data[i][:len(data[i])-1]...) + } + if updateChart(metric, data[i], &units[i], charts[i], err) { + realign = true + } } updateFooter(ctx, err, footer) + return } // updateChart inserts a dataset into a line chart, scaling appropriately as to // not display weird labels, also updating the chart label accordingly. -func updateChart(metric string, data []float64, chart *termui.LineChart, err error) { +func updateChart(metric string, data []float64, base *int, chart *termui.LineChart, err error) (realign bool) { dataUnits := []string{"", "K", "M", "G", "T", "E"} timeUnits := []string{"ns", "µs", "ms", "s", "ks", "ms"} colors := []termui.Attribute{termui.ColorBlue, termui.ColorCyan, termui.ColorGreen, termui.ColorYellow, termui.ColorRed, termui.ColorRed} // Extract only part of the data that's actually visible - data = data[:chart.Width*2] - + if chart.Width*2 < len(data) { + data = data[:chart.Width*2] + } // Find the maximum value and scale under 1K - high := data[0] - for _, value := range data[1:] { - high = math.Max(high, value) + high := 0.0 + if len(data) > 0 { + high = data[0] + for _, value := range data[1:] { + high = math.Max(high, value) + } } unit, scale := 0, 1.0 for high >= 1000 { high, unit, scale = high/1000, unit+1, scale*1000 } + // If the unit changes, re-create the chart (hack to set max height...) + if unit != *base { + realign, *base, *chart = true, unit, *createChart(chart.Height) + } // Update the chart's data points with the scaled values + if cap(chart.Data) < len(data) { + chart.Data = make([]float64, len(data)) + } + chart.Data = chart.Data[:len(data)] for i, value := range data { chart.Data[i] = value / scale } // Update the chart's label with the scale units - chart.Border.Label = metric - units := dataUnits if strings.Contains(metric, "/Percentiles/") || strings.Contains(metric, "/pauses/") { units = timeUnits } + chart.Border.Label = metric if len(units[unit]) > 0 { chart.Border.Label += " [" + units[unit] + "]" } @@ -292,6 +296,24 @@ func updateChart(metric string, data []float64, chart *termui.LineChart, err err if err != nil { chart.LineColor = termui.ColorRed | termui.AttrBold } + return +} + +// createChart creates an empty line chart with the default configs. +func createChart(height int) *termui.LineChart { + chart := termui.NewLineChart() + if runtime.GOOS == "windows" { + chart.Mode = "dot" + } + chart.DataLabels = []string{""} + chart.Height = height + chart.AxesColor = termui.ColorWhite + chart.PaddingBottom = -2 + + chart.Border.LabelFgColor = chart.Border.FgColor | termui.AttrBold + chart.Border.FgColor = chart.Border.BgColor + + return chart } // updateFooter updates the footer contents based on any encountered errors. |