diff --git a/zk/flw.go b/zk/flw.go index 1fb8b2ae..bda0fa48 100644 --- a/zk/flw.go +++ b/zk/flw.go @@ -153,8 +153,8 @@ func FLWRuok(servers []string, timeout time.Duration) []bool { func FLWCons(servers []string, timeout time.Duration) ([]*ServerClients, bool) { const ( zrAddr = `^ /((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(?:\d+))\[\d+\]` - zrPac = `\(queued=(\d+),recved=(\d+),sent=(\d+),sid=(0x[A-Za-z0-9]+),lop=(\w+),est=(\d+),to=(\d+),` - zrSesh = `lcxid=(0x[A-Za-z0-9]+),lzxid=(0x[A-Za-z0-9]+),lresp=(\d+),llat=(\d+),minlat=(\d+),avglat=(\d+),maxlat=(\d+)\)` + zrPac = `\(queued=(-?\d+),recved=(\d+),sent=(\d+)(,sid=(0x[A-Za-z0-9]+),lop=(\w+),est=(\d+),to=(\d+),` + zrSesh = `lcxid=(0x[A-Za-z0-9]+),lzxid=(0x[A-Za-z0-9]+),lresp=(\d+),llat=(\d+),minlat=(\d+),avglat=(\d+),maxlat=(\d+))?\)` ) re, err := regexp.Compile(fmt.Sprintf("%v%v%v", zrAddr, zrPac, zrSesh)) @@ -197,19 +197,24 @@ func FLWCons(servers []string, timeout time.Duration) ([]*ServerClients, bool) { match := m[0][1:] + var sid, est, timeout, lcxid, lzxid, lresp, llat, minlat, avglat, maxlat int64 + queued, _ := strconv.ParseInt(match[1], 0, 64) recvd, _ := strconv.ParseInt(match[2], 0, 64) sent, _ := strconv.ParseInt(match[3], 0, 64) - sid, _ := strconv.ParseInt(match[4], 0, 64) - est, _ := strconv.ParseInt(match[6], 0, 64) - timeout, _ := strconv.ParseInt(match[7], 0, 32) - lcxid, _ := parseInt64(match[8]) - lzxid, _ := parseInt64(match[9]) - lresp, _ := strconv.ParseInt(match[10], 0, 64) - llat, _ := strconv.ParseInt(match[11], 0, 32) - minlat, _ := strconv.ParseInt(match[12], 0, 32) - avglat, _ := strconv.ParseInt(match[13], 0, 32) - maxlat, _ := strconv.ParseInt(match[14], 0, 32) + + if len(match) > 4 { + sid, _ = strconv.ParseInt(match[5], 0, 64) + est, _ = strconv.ParseInt(match[7], 0, 64) + timeout, _ = strconv.ParseInt(match[8], 0, 32) + lcxid, _ = parseInt64(match[9]) + lzxid, _ = parseInt64(match[10]) + lresp, _ = strconv.ParseInt(match[11], 0, 64) + llat, _ = strconv.ParseInt(match[12], 0, 32) + minlat, _ = strconv.ParseInt(match[13], 0, 32) + avglat, _ = strconv.ParseInt(match[14], 0, 32) + maxlat, _ = strconv.ParseInt(match[15], 0, 32) + } clients = append(clients, &ServerClient{ Queued: queued, @@ -223,10 +228,10 @@ func FLWCons(servers []string, timeout time.Duration) ([]*ServerClients, bool) { MinLatency: int32(minlat), AvgLatency: int32(avglat), MaxLatency: int32(maxlat), - Established: time.Unix(est, 0), - LastResponse: time.Unix(lresp, 0), + Established: time.Unix(est/1000, (est%1000)*1e6), + LastResponse: time.Unix(lresp/1000, (lresp%1000)*1e6), Addr: match[0], - LastOperation: match[5], + LastOperation: match[6], }) } diff --git a/zk/flw_test.go b/zk/flw_test.go index 5bbabb9b..dd65f0d9 100644 --- a/zk/flw_test.go +++ b/zk/flw_test.go @@ -20,6 +20,8 @@ Node count: 306 zkConsOut = ` /10.42.45.231:45361[1](queued=0,recved=9435,sent=9457,sid=0x94c2989e04716b5,lop=PING,est=1427238717217,to=20001,lcxid=0x55120915,lzxid=0xffffffffffffffff,lresp=1427259255908,llat=0,minlat=0,avglat=1,maxlat=17) /10.55.33.98:34342[1](queued=0,recved=9338,sent=9350,sid=0x94c2989e0471731,lop=PING,est=1427238849319,to=20001,lcxid=0x55120944,lzxid=0xffffffffffffffff,lresp=1427259252294,llat=0,minlat=0,avglat=1,maxlat=18) /10.44.145.114:46556[1](queued=0,recved=109253,sent=109617,sid=0x94c2989e0471709,lop=DELE,est=1427238791305,to=20001,lcxid=0x55139618,lzxid=0x110a7b187d,lresp=1427259257423,llat=2,minlat=0,avglat=1,maxlat=23) + /10.100.12.2:56765[1](queued=-1,recved=314041,sent=314041,sid=0x1708cc31f4a0001,lop=SETA,est=1582909574451,to=10000,lcxid=0x12916e,lzxid=0xdc000a0c1d,lresp=1583583401593,llat=0,minlat=0,avglat=0,maxlat=214) + /10.100.23.2:50677[0](queued=0,recved=1,sent=0) ` ) @@ -160,11 +162,11 @@ func TestFLWCons(t *testing.T) { Sent: 9457, SessionID: 669956116721374901, LastOperation: "PING", - Established: time.Unix(1427238717217, 0), + Established: time.Unix(1427238717, 217*1e6), Timeout: 20001, Lcxid: 1427245333, Lzxid: -1, - LastResponse: time.Unix(1427259255908, 0), + LastResponse: time.Unix(1427259255, 908*1e6), LastLatency: 0, MinLatency: 0, AvgLatency: 1, @@ -177,11 +179,11 @@ func TestFLWCons(t *testing.T) { Sent: 9350, SessionID: 669956116721375025, LastOperation: "PING", - Established: time.Unix(1427238849319, 0), + Established: time.Unix(1427238849, 319*1e6), Timeout: 20001, Lcxid: 1427245380, Lzxid: -1, - LastResponse: time.Unix(1427259252294, 0), + LastResponse: time.Unix(1427259252, 294*1e6), LastLatency: 0, MinLatency: 0, AvgLatency: 1, @@ -194,17 +196,51 @@ func TestFLWCons(t *testing.T) { Sent: 109617, SessionID: 669956116721374985, LastOperation: "DELE", - Established: time.Unix(1427238791305, 0), + Established: time.Unix(1427238791, 305*1e6), Timeout: 20001, Lcxid: 1427346968, Lzxid: 73190283389, - LastResponse: time.Unix(1427259257423, 0), + LastResponse: time.Unix(1427259257, 423*1e6), LastLatency: 2, MinLatency: 0, AvgLatency: 1, MaxLatency: 23, Addr: "10.44.145.114:46556", }, + { + Queued: -1, + Received: 314041, + Sent: 314041, + SessionID: 103737561100976129, + LastOperation: "SETA", + Established: time.Unix(1582909574, 451*1e6), + Timeout: 10000, + Lcxid: 1216878, + Lzxid: 944893463581, + LastResponse: time.Unix(1583583401, 593*1e6), + LastLatency: 0, + MinLatency: 0, + AvgLatency: 0, + MaxLatency: 214, + Addr: "10.100.12.2:56765", + }, + { + Queued: 0, + Received: 1, + Sent: 0, + SessionID: 0, + LastOperation: "", + Established: time.Unix(0, 0), + Timeout: 0, + Lcxid: 0, + Lzxid: 0, + LastResponse: time.Unix(0, 0), + LastLatency: 0, + MinLatency: 0, + AvgLatency: 0, + MaxLatency: 0, + Addr: "10.100.23.2:50677", + }, } for _, z := range clients {