Skip to content

Commit

Permalink
Merge pull request #7 from treydock/waiters-exclude
Browse files Browse the repository at this point in the history
Support excluding waiters
  • Loading branch information
treydock authored Feb 18, 2020
2 parents 1373882 + 57c938d commit edc39df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions collectors/mmdiag.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (
)

var (
defWaiterExclude = "(EventsExporterSenderThread)"
configWaiterThreshold = kingpin.Flag("collector.mmdiag.waiter-threshold", "Threshold for collected waiters").Default("30").Int()
configWaiterExclude = kingpin.Flag("collector.mmdiag.waiter-exclude", "Pattern to exclude for waiters").Default(defWaiterExclude).String()
)

type DiagMetric struct {
Expand Down Expand Up @@ -99,9 +101,13 @@ func mmdiag(arg string) (string, error) {

func parse_mmdiag_waiters(out string, diagMetric *DiagMetric) error {
lines := strings.Split(out, "\n")
waitersPatter := regexp.MustCompile(`^Waiting ([0-9.]+) sec.*thread ([0-9]+)`)
waitersPattern := regexp.MustCompile(`^Waiting ([0-9.]+) sec.*thread ([0-9]+)`)
excludePattern := regexp.MustCompile(*configWaiterExclude)
for _, l := range lines {
match := waitersPatter.FindStringSubmatch(l)
if excludePattern.MatchString(l) {
continue
}
match := waitersPattern.FindStringSubmatch(l)
if len(match) != 3 {
continue
}
Expand Down
6 changes: 4 additions & 2 deletions collectors/mmdiag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import (
func TestParseMmdiagWaiters(t *testing.T) {
threshold := 30
configWaiterThreshold = &threshold
configWaiterExclude = &defWaiterExclude
execCommand = fakeExecCommand
mockedStdout = `
=== mmdiag: waiters ===
Waiting 64.3890 sec since 17:55:45, monitored, thread 120655 EventsExporterSenderThread: for poll on sock 1379
Waiting 44.3890 sec since 17:55:45, monitored, thread 120656 EventsExporterSenderThread: for poll on sock 1379
Waiting 40.4231 sec since 13:08:39, monitored, thread 120656 EventsExporterSenderThread: for poll on sock 1379
Waiting 64.3890 sec since 17:55:45, monitored, thread 120655 NSDThread: for I/O completion
Waiting 44.3890 sec since 17:55:45, monitored, thread 120656 NSDThread: for I/O completion
Waiting 0.0409 sec since 10:24:00, monitored, thread 23170 NSDThread: for I/O completion
Waiting 0.0259 sec since 10:24:00, monitored, thread 23241 NSDThread: for I/O completion
Waiting 0.0251 sec since 10:24:00, monitored, thread 23243 NSDThread: for I/O completion
Expand Down

0 comments on commit edc39df

Please sign in to comment.