Example #1
0
func main() {
	flag.Parse()

	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	if *flagDebug {
		logger.Enable(lib.MyName() + ".log")
	}
	if *flagVersion {
		fmt.Println(lib.MyName() + " version " + version.Version())
		return
	}
	if *flagHelp {
		usage()
		return
	}

	conn := connector.NewConnector(flagHost, flagSocket, flagPort, flagUser, flagPassword, flagDefaultsFile)
	disp := display.NewScreenDisplay(*flagLimit, false)

	app := app.NewApp(conn, *flagInterval, *flagCount, false, *flagView, disp)
	app.Run()
	app.Cleanup()
}
Example #2
0
func main() {
	var err = errors.New("unknown")

	flag.Parse()

	// Too many arguments
	if len(flag.Args()) > 2 {
		usage()
		os.Exit(1)
	}
	// delay
	if len(flag.Args()) >= 1 {
		delay, err = strconv.Atoi(flag.Args()[0])
		if err != nil {
			log.Fatal("Unable to parse delay: ", err)
		}
	} else {
		delay = 1
	}
	// count
	if len(flag.Args()) >= 2 {
		count, err = strconv.Atoi(flag.Args()[1])
		if err != nil {
			log.Fatal("Unable to parse count: ", err)
		}
	} else {
		count = 0
	}

	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	if *flagDebug {
		logger.Enable(lib.MyName() + ".log")
	}
	if *flagVersion {
		fmt.Println(lib.MyName() + " version " + version.Version())
		return
	}
	if *flagHelp {
		usage()
		return
	}

	conn := connector.NewConnector(flagHost, flagSocket, flagPort, flagUser, flagPassword, flagDefaultsFile)
	disp := display.NewStdoutDisplay(*flagLimit, true)

	app := app.NewApp(conn, delay, count, true, *flagView, disp)
	app.Run()
	app.Cleanup()
}
Example #3
0
func main() {
	connectorFlags = connector.Flags{
		DefaultsFile:   flag.String("defaults-file", "", "Define the defaults file to read"),
		Host:           flag.String("host", "", "Provide the hostname of the MySQL to connect to"),
		Password:       flag.String("password", "", "Provide the password when connecting to the MySQL server"),
		Port:           flag.Int("port", 0, "Provide the port number of the MySQL to connect to (default: 3306)"), /* Port is deliberately 0 here, defaults to 3306 elsewhere */
		Socket:         flag.String("socket", "", "Provide the path to the local MySQL server to connect to"),
		User:           flag.String("user", "", "Provide the username to connect with to MySQL (default: $USER)"),
		UseEnvironment: flag.Bool("use-environment", false, "Use the environment variable MYSQL_DSN (go dsn) to connect with to MySQL"),
	}

	flag.Parse()

	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	if *flagDebug {
		logger.Enable()
	}
	if *flagVersion {
		fmt.Println(lib.MyName() + " version " + version.Version())
		return
	}
	if *flagHelp {
		usage()
		return
	}

	settings := app.Settings{
		Anonymise: *flagAnonymise,
		Conn:      connector.NewConnector(connectorFlags),
		Interval:  *flagInterval,
		Count:     *flagCount,
		Stdout:    false,
		View:      *flagView,
		Disp:      display.NewScreenDisplay(*flagLimit, false),
	}

	app := app.NewApp(settings)
	app.Run()
	app.Cleanup()
}
Example #4
0
// DisplayHelp displays a help page on the screen
func (s *ScreenDisplay) DisplayHelp() {
	s.screen.PrintAt(0, 0, lib.MyName()+" version "+version.Version()+" "+lib.Copyright())

	s.screen.PrintAt(0, 2, "Program to show the top I/O information by accessing information from the")
	s.screen.PrintAt(0, 3, "performance_schema schema. Ideas based on mysql-sys.")

	s.screen.PrintAt(0, 5, "Keys:")
	s.screen.PrintAt(0, 6, "- - reduce the poll interval by 1 second (minimum 1 second)")
	s.screen.PrintAt(0, 7, "+ - increase the poll interval by 1 second")
	s.screen.PrintAt(0, 8, "h/? - this help screen")
	s.screen.PrintAt(0, 9, "q - quit")
	s.screen.PrintAt(0, 10, "s - sort differently (where enabled) - sorts on a different column")
	s.screen.PrintAt(0, 11, "t - toggle between showing time since resetting statistics or since P_S data was collected")
	s.screen.PrintAt(0, 12, "z - reset statistics")
	s.screen.PrintAt(0, 13, "<tab> or <right arrow> - change display modes between: latency, ops, file I/O, lock and user modes")
	s.screen.PrintAt(0, 14, "<left arrow> - change display modes to the previous screen (see above)")
	s.screen.PrintAt(0, 16, "Press h to return to main screen")
}
Example #5
0
// Version returns the Application version
func (c Context) Version() string {
	return version.Version()
}
Example #6
0
func main() {
	connectorFlags = connector.Flags{
		Host:           flag.String("host", "", "Provide the hostname of the MySQL to connect to"),
		Password:       flag.String("password", "", "Provide the password when connecting to the MySQL server"),
		Port:           flag.Int("port", 0, "Provide the port number of the MySQL to connect to (default: 3306)"), /* Port is deliberately 0 here, defaults to 3306 elsewhere */
		Socket:         flag.String("socket", "", "Provide the path to the local MySQL server to connect to"),
		User:           flag.String("user", "", "Provide the username to connect with to MySQL (default: $USER)"),
		UseEnvironment: flag.Bool("use-environment", false, "Use the environment variable MYSQL_DSN (go dsn) to connect with to MySQL"),
	}

	var err = errors.New("unknown")

	flag.Parse()

	// Too many arguments
	if len(flag.Args()) > 2 {
		usage()
		os.Exit(1)
	}
	// delay
	if len(flag.Args()) >= 1 {
		delay, err = strconv.Atoi(flag.Args()[0])
		if err != nil {
			log.Fatal("Unable to parse delay: ", err)
		}
	} else {
		delay = 1
	}
	// count
	if len(flag.Args()) >= 2 {
		count, err = strconv.Atoi(flag.Args()[1])
		if err != nil {
			log.Fatal("Unable to parse count: ", err)
		}
	} else {
		count = 0
	}

	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	if *flagDebug {
		logger.Enable()
	}
	if *flagVersion {
		fmt.Println(lib.MyName() + " version " + version.Version())
		return
	}
	if *flagHelp {
		usage()
		return
	}

	settings := app.Settings{
		Conn:     connector.NewConnector(connectorFlags),
		Interval: delay,
		Count:    count,
		Stdout:   true,
		View:     *flagView,
		Disp:     display.NewStdoutDisplay(*flagLimit, true),
	}

	app := app.NewApp(settings)
	app.Run()
	app.Cleanup()
}