info update and add store stat

This commit is contained in:
siddontang 2014-10-15 10:41:43 +08:00
parent f05398cdf9
commit 028b9fbd55
3 changed files with 25 additions and 25 deletions

View File

@ -2566,15 +2566,7 @@ Very dangerous to use!!!
Return information and statistic about the server in a format that is simple to parse by computers and easy to read by humans.
The optional parameter can be used to select a specific section of information:
+ server: General information about the Redis server
+ client: Client connections section
+ mem: Memory consumption related information
+ goroutine: Goroutine num
+ persistence: Strorage related information
When no parameter is provided, all will return.
The optional parameter can be used to select a specific section of information. When no parameter is provided, all will return.
### TIME

View File

@ -198,3 +198,7 @@ func (l *Ledis) onDataExpired() {
}
}
func (l *Ledis) StoreStat() *store.Stat {
return l.ldb.Stat()
}

View File

@ -55,6 +55,7 @@ func newInfo(app *App) (i *info, err error) {
func (i *info) addClients(delta int64) {
atomic.AddInt64(&i.Clients.ConnectedClients, delta)
}
func (i *info) Close() {
}
@ -82,10 +83,8 @@ func (i *info) Dump(section string) []byte {
i.dumpClients(buf)
case "mem":
i.dumpMem(buf)
case "persistence":
i.dumpPersistence(buf)
case "goroutine":
i.dumpGoroutine(buf)
case "store":
i.dumpStore(buf)
case "replication":
i.dumpReplication(buf)
default:
@ -103,14 +102,12 @@ type infoPair struct {
func (i *info) dumpAll(buf *bytes.Buffer) {
i.dumpServer(buf)
buf.Write(Delims)
i.dumpPersistence(buf)
i.dumpStore(buf)
buf.Write(Delims)
i.dumpClients(buf)
buf.Write(Delims)
i.dumpMem(buf)
buf.Write(Delims)
i.dumpGoroutine(buf)
buf.Write(Delims)
i.dumpReplication(buf)
}
@ -121,7 +118,9 @@ func (i *info) dumpServer(buf *bytes.Buffer) {
infoPair{"process_id", i.Server.ProceessId},
infoPair{"addr", i.app.cfg.Addr},
infoPair{"http_addr", i.app.cfg.HttpAddr},
infoPair{"readonly", i.app.cfg.Readonly})
infoPair{"readonly", i.app.cfg.Readonly},
infoPair{"goroutine_num", runtime.NumGoroutine()},
)
}
func (i *info) dumpClients(buf *bytes.Buffer) {
@ -140,16 +139,21 @@ func (i *info) dumpMem(buf *bytes.Buffer) {
infoPair{"mem_alloc_human", getMemoryHuman(mem.Alloc)})
}
func (i *info) dumpGoroutine(buf *bytes.Buffer) {
buf.WriteString("# Goroutine\r\n")
func (i *info) dumpStore(buf *bytes.Buffer) {
buf.WriteString("# Store\r\n")
i.dumpPairs(buf, infoPair{"goroutine_num", runtime.NumGoroutine()})
}
s := i.app.ldb.StoreStat()
func (i *info) dumpPersistence(buf *bytes.Buffer) {
buf.WriteString("# Persistence\r\n")
i.dumpPairs(buf, infoPair{"db_name", i.Persistence.DBName})
i.dumpPairs(buf, infoPair{"name", i.Persistence.DBName},
infoPair{"get", s.GetNum},
infoPair{"get_missing", s.GetMissingNum},
infoPair{"put", s.PutNum},
infoPair{"delete", s.DeleteNum},
infoPair{"iter", s.IterNum},
infoPair{"iter_seek", s.IterSeekNum},
infoPair{"iter_close", s.IterCloseNum},
infoPair{"batch_commit", s.BatchCommitNum},
)
}
func (i *info) dumpReplication(buf *bytes.Buffer) {