diff --git a/scripts/monitor_metrics.py b/scripts/monitor_metrics.py index 385b11b..6ee1afc 100755 --- a/scripts/monitor_metrics.py +++ b/scripts/monitor_metrics.py @@ -199,8 +199,17 @@ 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} + # 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: + 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] jlock['locks'].append(lockinfo) self.logger.debug("parsed TextLockInfo: %s" % str(jlock)) @@ -234,9 +243,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 +256,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":