Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps/nsq_stat: add rate status #507

Merged
merged 1 commit into from
Nov 28, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 20 additions & 7 deletions apps/nsq_stat/nsq_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func init() {

func statLoop(interval time.Duration, topic string, channel string,
nsqdTCPAddrs []string, lookupdHTTPAddrs []string) {
i := 0
for {
var o *lookupd.ChannelStats
for i := 0; ; i++ {
var producers []string
var err error

Expand Down Expand Up @@ -64,12 +64,26 @@ func statLoop(interval time.Duration, topic string, channel string,
}

if i%25 == 0 {
fmt.Printf("---------------depth---------------+--------------metadata---------------\n")
fmt.Printf("%7s %7s %7s %5s %5s | %7s %7s %12s %7s\n", "total", "mem", "disk", "inflt", "def", "req", "t-o", "msgs", "clients")
fmt.Printf("%s+%s+%s\n",
"------rate------",
"----------------depth----------------",
"--------------metadata---------------")
fmt.Printf("%7s %7s | %7s %7s %7s %5s %5s | %7s %7s %12s %7s\n",
"ingress", "egress",
"total", "mem", "disk", "inflt",
"def", "req", "t-o", "msgs", "clients")
}

if o == nil {
o = c
time.Sleep(interval)
continue
}

// TODO: paused
fmt.Printf("%7d %7d %7d %5d %5d | %7d %7d %12d %7d\n",
fmt.Printf("%7d %7d | %7d %7d %7d %5d %5d | %7d %7d %12d %7d\n",
(c.MessageCount-o.MessageCount)/int64(interval.Seconds()),
(c.MessageCount-o.MessageCount-(c.Depth-o.Depth))/int64(interval.Seconds()),
c.Depth,
c.MemoryDepth,
c.BackendDepth,
Expand All @@ -80,9 +94,8 @@ func statLoop(interval time.Duration, topic string, channel string,
c.MessageCount,
c.ClientCount)

o = c
time.Sleep(interval)

i++
}
}

Expand Down