Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Lefranc committed Jan 24, 2015
1 parent 2b077c0 commit 985fca5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
5 changes: 3 additions & 2 deletions mariadb-report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"] {
Expand Down
14 changes: 3 additions & 11 deletions mariadb-top/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}

0 comments on commit 985fca5

Please sign in to comment.