v0.1.3 add support for explicit --defaults-file=xx on command line
authorSimon J Mudd <sjmudd@pobox.com>
Sun, 14 Dec 2014 21:23:11 +0000 (22:23 +0100)
committerSimon J Mudd <sjmudd@pobox.com>
Sun, 14 Dec 2014 21:23:11 +0000 (22:23 +0100)
BUGS
NEW_FEATURES
README.md
main.go
version/version.go

diff --git a/BUGS b/BUGS
index 7194db2..8ef7fba 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -7,8 +7,10 @@ See also NEW_FEATURES for things which probably need adding soon.
 by looking at the pattern defined in the server. Currently I'm using
 hard-coded stuff which matches personal usage.
 
 by looking at the pattern defined in the server. Currently I'm using
 hard-coded stuff which matches personal usage.
 
-2. Latency issues over slow connections. Perhaps should use compressed
-connection to speed things up?
+2. Latency issues over slow connections. Perhaps I should use
+compressed connection to speed things up, but that is not possible
+at the moment. See https://github.com/go-sql-driver/mysql/issues/24
+for more details.
 
 3. Sometimes I see this:
 
 
 3. Sometimes I see this:
 
index 5135d27..6ca2b5a 100644 (file)
@@ -20,28 +20,30 @@ over time but providing output as stdout. It might be useful to
 have options to pstop to present the info in that sort of format
 too.
 
 have options to pstop to present the info in that sort of format
 too.
 
-4. add some replication metrics to pstop as most of my servers are
+4. Add some replication metrics to pstop as most of my servers are
 slaves and we want to know where the server is busy. I've seen a
 way to do that and need to incorporate it into pstop.
 
 slaves and we want to know where the server is busy. I've seen a
 way to do that and need to incorporate it into pstop.
 
-5. _if_ ps statistics get truncated it would be good to be able
-to remember the latest state and add those metrics back again, _if_
-looking at absolute rather than statistics. I currently truncate
-info after 15-minutes, so this might happen while watching a server
-with pstop.
+5. _if_ ps statistics get truncated it would be good to be able to
+remember the latest state and add those metrics back again, _if_
+looking at absolute rather than relative statistics. On servers I
+manage I currently truncate info as it is collected after 15-minutes,
+so this might happen while watching a server with pstop.
 
 6. Improve the options for sorting the data. Total latency is good,
 but it would be good to see the write based metrics ordered by total
 write latency. So look to improve the display and sort options here.
 
 7. Add command line options for providing access to the MySQL server.
 
 6. Improve the options for sorting the data. Total latency is good,
 but it would be good to see the write based metrics ordered by total
 write latency. So look to improve the display and sort options here.
 
 7. Add command line options for providing access to the MySQL server.
-Currently uses ~/.my.cnf and that's all.
-
-8. shift-tab to go back a screen.
-
-Issue 3 - termbox - SHIFT + TAB with go - termbox library ...
-code.google.com/p/termbox/issues/detail?id=3
-14 Sep 2010 - If I press Shift + Tab the Poll function will send
-me 3 things successively: 1: Key 27 2: Ch 91 3: Ch 90 It's the only
-Key I know that do that.
-https://github.com/peco/peco/issues/161
+--defaults-file=/path/to/.my.cnf now works, but missing an explicit
+--host=xx --port=99 --user=xx --password=xx or --socket=/path/to/mysql.sock
+options.
+
+8. I/O Latency by File shows read/write bytes and operations but
+none of these values is converted into B/s or ops/sec which might
+be better given we want to see the rate values.  MB/s or ops/s are
+easier to understand and the values don't change depending on the
+period being viewed. That said unless we have the times the metrics
+were collected we can't calculate these rates so the ABS values
+can't show the rate information but would need to show only the
+counters.
index 42e1e82..b05a69c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -17,8 +17,8 @@ Install and update this go package with `go get -u github.com/sjmudd/pstop`
 ### Configuration
 
 Access to MySQL is currently via a defaults-file which is assumed
 ### Configuration
 
 Access to MySQL is currently via a defaults-file which is assumed
-to be `~/.my.cnf`. This should probably be made more configurable.
-If you see a need for this please let me know.
+to be `~/.my.cnf`.  Alternatively you can now provide
+-defaults-file=/path/to/.my.cnf if needed.
 
 ### Grants
 
 
 ### Grants
 
diff --git a/main.go b/main.go
index ddefcf0..53960f2 100644 (file)
--- a/main.go
+++ b/main.go
@@ -31,20 +31,22 @@ const (
 )
 
 var (
 )
 
 var (
-       flag_version = flag.Bool("version", false, "Show the version of "+lib.MyName())
-       flag_debug   = flag.Bool("debug", false, "Enabling debug logging")
-       flag_help    = flag.Bool("help", false, "Provide some help for "+lib.MyName())
-       cpuprofile   = flag.String("cpuprofile", "", "write cpu profile to file")
+       flag_debug         = flag.Bool("debug", false, "Enabling debug logging")
+       flag_defaults_file = flag.String("defaults-file", "", "Provide a defaults-file to use to connect to MySQL")
+       flag_help          = flag.Bool("help", false, "Provide some help for "+lib.MyName())
+       flag_version       = flag.Bool("version", false, "Show the version of "+lib.MyName())
+       cpuprofile         = flag.String("cpuprofile", "", "write cpu profile to file")
 
        re_valid_version = regexp.MustCompile(`^(5\.[67]\.|10\.[01])`)
 )
 
 
        re_valid_version = regexp.MustCompile(`^(5\.[67]\.|10\.[01])`)
 )
 
-func get_db_handle() *sql.DB {
+// Connect to the database with the given defaults-file, or ~/.my.cnf if not provided.
+func get_db_handle( defaults_file string ) *sql.DB {
        var err error
        var dbh *sql.DB
        lib.Logger.Println("get_db_handle() connecting to database")
 
        var err error
        var dbh *sql.DB
        lib.Logger.Println("get_db_handle() connecting to database")
 
-       dbh, err = mysql_defaults_file.OpenUsingDefaultsFile(sql_driver, "", "performance_schema")
+       dbh, err = mysql_defaults_file.OpenUsingDefaultsFile(sql_driver, defaults_file, "performance_schema")
        if err != nil {
                log.Fatal(err)
        }
        if err != nil {
                log.Fatal(err)
        }
@@ -76,8 +78,9 @@ func usage() {
        fmt.Println("Usage: " + lib.MyName() + " <options>")
        fmt.Println("")
        fmt.Println("Options:")
        fmt.Println("Usage: " + lib.MyName() + " <options>")
        fmt.Println("")
        fmt.Println("Options:")
-       fmt.Println("-help      show this help message")
-       fmt.Println("-version   show the version")
+       fmt.Println("-defaults-file=/path/to/defaults.file   Connect to MySQL using given defaults-file" )
+       fmt.Println("-help                                   show this help message")
+       fmt.Println("-version                                show the version")
 }
 
 // pstop requires MySQL 5.6+ or MariaDB 10.0+. Check the version
 }
 
 // pstop requires MySQL 5.6+ or MariaDB 10.0+. Check the version
@@ -119,6 +122,7 @@ func validate_mysql_version(dbh *sql.DB) error {
 }
 
 func main() {
 }
 
 func main() {
+       var defaults_file string = ""
        flag.Parse()
 
        // clean me up
        flag.Parse()
 
        // clean me up
@@ -145,7 +149,11 @@ func main() {
 
        lib.Logger.Println("Starting " + lib.MyName())
 
 
        lib.Logger.Println("Starting " + lib.MyName())
 
-       dbh := get_db_handle()
+       if flag_defaults_file != nil && *flag_defaults_file != "" {
+               defaults_file = *flag_defaults_file
+       }
+
+       dbh := get_db_handle( defaults_file )
        if err := validate_mysql_version(dbh); err != nil {
                log.Fatal(err)
        }
        if err := validate_mysql_version(dbh); err != nil {
                log.Fatal(err)
        }
index 2259527..be253eb 100644 (file)
@@ -2,7 +2,7 @@
 package version
 
 const (
 package version
 
 const (
-       version = "0.1.2"
+       version = "0.1.3"
 )
 
 // return the current application version
 )
 
 // return the current application version