From b02beb3b004cc1effe5aae1925e5301eece067dc Mon Sep 17 00:00:00 2001 From: Noe Gonzalez Date: Wed, 24 Jan 2024 20:55:33 -0800 Subject: [PATCH 1/2] fix: collect lock data when lslocks has null path values --- scripts/monitor_metrics.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/monitor_metrics.py b/scripts/monitor_metrics.py index 385b11b..43e0b3d 100755 --- a/scripts/monitor_metrics.py +++ b/scripts/monitor_metrics.py @@ -199,8 +199,11 @@ def parseTextLockInfo(self, lockdata): "type": parts[2], "size": parts[3], "mode": parts[4], "m": parts[5], "start": parts[6], "end": parts[7], - "path": parts[8], "blocker": None} + "path": None, "blocker": None} + if len(parts) == 9: + lockinfo["blocker"] = parts[8] if len(parts) == 10: + lockinfo["path"] = parts[8] lockinfo["blocker"] = parts[9] jlock['locks'].append(lockinfo) self.logger.debug("parsed TextLockInfo: %s" % str(jlock)) @@ -234,9 +237,9 @@ def findLocks(self, lockdata, mondata): return metrics blockingCommands = defaultdict(dict) for j in jlock['locks']: - if "p4d" not in j["command"] or "path" not in j or not j["path"]: + if "p4d" not in j["command"]: continue - if "clientEntity" in j["path"]: + if j["path"] is not None and "clientEntity" in j["path"]: if j["mode"] == "READ": metrics.clientEntityReadLocks += 1 elif j["mode"] == "WRITE": @@ -247,13 +250,14 @@ def findLocks(self, lockdata, mondata): path = j["path"] if j["pid"] in pids: user, cmd, _ = pids[j["pid"]] - if "server.locks/meta" in j["path"]: + if j["path"] is not None and "server.locks/meta" in j["path"]: if j["mode"] == "READ": metrics.metaReadLocks += 1 elif j["mode"] == "WRITE": metrics.metaWriteLocks += 1 - dbPath = self.dbFileInPath(j["path"]) - if dbPath: + if j["path"] is not None: + dbPath = self.dbFileInPath(j["path"]) + if j["path"] is not None and dbPath: if j["mode"] == "READ": metrics.dbReadLocks += 1 if j["mode"] == "WRITE": From 185b3b85f1de685e857212a9c599b764e88bbe39 Mon Sep 17 00:00:00 2001 From: Noe Gonzalez Date: Thu, 25 Jan 2024 11:12:40 -0800 Subject: [PATCH 2/2] fix: update monitor_metrics.py test harness --- scripts/monitor_metrics.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/monitor_metrics.py b/scripts/monitor_metrics.py index 43e0b3d..6ee1afc 100755 --- a/scripts/monitor_metrics.py +++ b/scripts/monitor_metrics.py @@ -200,8 +200,14 @@ def parseTextLockInfo(self, lockdata): "mode": parts[4], "m": parts[5], "start": parts[6], "end": parts[7], "path": None, "blocker": None} + # there's a possibility that both PATH and BLOCKER may be None + # we'll have to inspect the length of the parts array & values to determine which value(s) to set if len(parts) == 9: - lockinfo["blocker"] = parts[8] + if parts[8].isdigit(): + lockinfo["blocker"] = parts[8] + else: + lockinfo["path"] = parts[8] + # we have both PATH and BLOCKER values present if len(parts) == 10: lockinfo["path"] = parts[8] lockinfo["blocker"] = parts[9]