Esempio n. 1
0
func printHosts(lastApiResponse *healthd.ApiResponseHosts, status *healthdStatus) {
	goterm.Clear() // Clear current screen
	goterm.MoveCursor(1, 1)
	defer goterm.Flush()
	goterm.Println("Current Time:", status.FmtNow(), "   Status:", status.FmtStatus())

	//
	if lastApiResponse == nil {
		goterm.Println("no data yet")
		return
	}

	columns := []string{
		"Host:Port",
		"Status",
		"Last Checked",
		"Last Response Time",
	}

	for i, s := range columns {
		columns[i] = goterm.Bold(goterm.Color(s, goterm.BLACK))
	}

	table := goterm.NewTable(0, goterm.Width()-1, 5, ' ', 0)
	fmt.Fprintf(table, "%s\n", strings.Join(columns, "\t"))

	for _, host := range lastApiResponse.Hosts {
		printHost(table, host)
	}

	goterm.Println(table)
}
Esempio n. 2
0
func (cmd *Command) overviewAction(backendId string, watch int, limit int) {
	var bk *engine.BackendKey
	if backendId != "" {
		bk = &engine.BackendKey{Id: backendId}
	}
	for {
		frontends, err := cmd.client.TopFrontends(bk, limit)
		if err != nil {
			cmd.printError(err)
			frontends = []engine.Frontend{}
		}

		servers, err := cmd.client.TopServers(bk, limit)
		if err != nil {
			cmd.printError(err)
			servers = []engine.Server{}
		}
		t := time.Now()
		if watch != 0 {
			goterm.Clear()
			goterm.MoveCursor(1, 1)
			goterm.Flush()
			fmt.Fprintf(cmd.out, "%s Every %d seconds. Top %d entries\n\n", t.Format("2006-01-02 15:04:05"), watch, limit)
		}
		cmd.printOverview(frontends, servers)
		if watch != 0 {
			goterm.Flush()
		} else {
			return
		}
		time.Sleep(time.Second * time.Duration(watch))
	}
}
Esempio n. 3
0
func main() {
	tm.Clear()
	tm.MoveCursor(0, 0)

	chart := tm.NewLineChart(100, 20)
	data := new(tm.DataTable)
	data.AddColumn("Time")
	data.AddColumn("Sin(x)")
	data.AddColumn("Cos(x+1)")

	for i := 0.1; i < 10; i += 0.1 {
		data.AddRow(i, math.Sin(i), math.Cos(i+1))
	}

	tm.Println(chart.Draw(data))
	tm.Flush()
}
Esempio n. 4
0
func printJobs(lastApiResponse *healthd.ApiResponseJobs, status *healthdStatus) {
	goterm.Clear() // Clear current screen
	goterm.MoveCursor(1, 1)
	defer goterm.Flush()
	goterm.Println("Current Time:", status.FmtNow(), "   Status:", status.FmtStatus())

	if lastApiResponse == nil {
		goterm.Println("no data yet")
		return
	}

	columns := []string{
		"Job",
		//		"Jobs/Second", //minute? flag?
		"Total Count",
		"Success",
		"ValidationError",
		"Panic",
		"Error",
		"Junk",
		"Avg Response Time",
		"Stddev",
		"Min",
		"Max",
		"Total",
	}

	for i, s := range columns {
		columns[i] = goterm.Bold(goterm.Color(s, goterm.BLACK))
	}

	table := goterm.NewTable(0, goterm.Width()-1, 5, ' ', 0)
	fmt.Fprintf(table, "%s\n", strings.Join(columns, "\t"))

	for _, job := range lastApiResponse.Jobs {
		printJob(table, job)
	}

	goterm.Println(table)
}
Esempio n. 5
0
func Run(done chan bool) {

	if !verbose {
		tm.Clear() // Clear current screen
	}

	failed := false
	var failedUpdate builder.Update

	for {
		time.Sleep(time.Millisecond)
		if !verbose {
			tm.MoveCursor(1, 1)
			header := fmt.Sprintf("Building (%s)",
				nstime.NsReadable(time.Since(stated).Nanoseconds()),
			)
			termPrintln(header)
		}

		for worker, update := range statuses {
			if !verbose {
				tm.MoveCursor(worker+2, 1)
			}

			switch update.Status {
			case builder.Pending:
				termPrintln("[ IDLE ]")
			case builder.Started:
				ts := time.Since(update.TimeStamp)
				pbr := ">"

				s := fmt.Sprintf("%s %s (%s)",
					pbr,
					update.Target,
					nstime.NsReadable(ts.Nanoseconds()),
				)
				termPrintln(s)
			case builder.Fail:

				termPrintln("[ IDLE ]")
				exit = true
				failed = true
				failedUpdate = update
			case builder.Success:
				termPrintln("[ IDLE ]")
				break
			}

		}
		if !verbose {
			tm.Flush() // Call it every time at the end of rendering
		}
		if exit {
			if failed {
				if !verbose {
					tm.MoveCursor(worderCount+2, 1)
					failMessage(failedUpdate.Target)
					tm.Flush()
				} else {
					failMessage(failedUpdate.Target)
				}
			}
			done <- true
		}
	}
}