From 985fca50dac8641ce53b3819592d86e70f8e1d88 Mon Sep 17 00:00:00 2001 From: Guillaume Lefranc Date: Sat, 24 Jan 2015 12:14:34 +0100 Subject: [PATCH] Small changes --- mariadb-report/report.go | 5 +++-- mariadb-top/top.go | 14 +++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/mariadb-report/report.go b/mariadb-report/report.go index c4e31eb..3d9c851 100644 --- a/mariadb-report/report.go +++ b/mariadb-report/report.go @@ -79,13 +79,13 @@ func main() { db.Get(&count, "SELECT COUNT(*) FROM information_schema.schemata") pPrintInt("Databases", count) db.Get(&count, "SELECT COUNT(*) FROM information_schema.tables") - pPrintInt("Tables", count) + pPrintInt("Tables", count) /* Potentially unsafe for large systems */ pPrintStr("Datadir", variable["DATADIR"]) pPrintStr("Binary Log", variable["LOG_BIN"]) if variable["LOG_BIN"] == "ON" { pPrintStr("Binlog writes per hour", humanize.IBytes(uint64(status["BINLOG_BYTES_WRITTEN"]/status["UPTIME"])*3600)) } - + // Add stuff for slow logs slaveStatus := dbhelper.GetSlaveStatus(db) if slaveStatus["Slave_IO_Running"] != nil { slaveIO := string(slaveStatus["Slave_IO_Running"].([]uint8)) @@ -113,6 +113,7 @@ func main() { ibpsDirtyPct := common.DecimaltoPct(ibpsDirty, ibpsPages) pPrintStr("InnoDB Buffer Dirty", strconv.Itoa(ibpsDirtyPct)+"%") pPrintStr("InnoDB Log Files", string(variable["INNODB_LOG_FILES_IN_GROUP"])+" files of "+humanize.IBytes(common.StrtoUint(variable["INNODB_LOG_FILE_SIZE"]))) + pPrintStr("InnoDB log writes per hour", humanize.IBytes(uint64(status["INNODB_OS_LOG_WRITTEN"]/status["UPTIME"])*3600) pPrintStr("InnoDB Log Buffer", humanize.IBytes(common.StrtoUint(variable["INNODB_LOG_BUFFER_SIZE"]))) var iftc string switch variable["INNODB_FLUSH_LOG_AT_TRX_COMMIT"] { diff --git a/mariadb-top/top.go b/mariadb-top/top.go index 054a524..c1d9e2b 100644 --- a/mariadb-top/top.go +++ b/mariadb-top/top.go @@ -39,15 +39,8 @@ func main() { if *version == true { common.Version() } - var address string - if *socket != "" { - address = "unix(" + *socket + ")" - } - if *host != "" { - address = "tcp(" + *host + ":" + *port + ")" - } - db = dbhelper.Connect(*user, *host, address) + db = dbhelper.Connect(*user, *password, GetAddress(*host, *port, *socket)) defer db.Close() err := termbox.Init() @@ -79,7 +72,6 @@ func displayPl() { termbox.Clear(termbox.ColorWhite, termbox.ColorBlack) print_tb(0, 0, termbox.ColorWhite, termbox.ColorBlack, "MariaDB Processlist Monitor") plist := dbhelper.GetProcesslist(db) - printf_tb(0, 1, termbox.ColorWhite, termbox.ColorBlack, "Plist.size: %d", len(plist)) printf_tb(0, 2, termbox.ColorWhite|termbox.AttrBold, termbox.ColorBlack, "%8s %8s %10s %10s %20s %8s %20s", "Id", "User", "Host", "Database", "Command", "Time", "State") vy := 3 for _, v := range plist { @@ -89,9 +81,9 @@ func displayPl() { } else { database = "NULL" } - printf_tb(0, vy, termbox.ColorWhite, termbox.ColorBlack, "%8.8d %8.8s %10.10s %10.10v %20.20s %8.4f %20.20s", v.Id, v.User, v.Host, database, v.Command, v.Time, v.State) + printf_tb(0, vy, termbox.ColorWhite, termbox.ColorBlack, "%8.8d %8.8s %10.10s %10.10v %20.20s %8.2f %20.20s", v.Id, v.User, v.Host, database, v.Command, v.Time*1000, v.State) vy++ } termbox.Flush() - time.Sleep(time.Duration(1) * time.Second) + time.Sleep(time.Duration(3) * time.Second) }