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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: collect lock data when lslocks has null path values #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions scripts/monitor_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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":
Expand All @@ -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":
Expand Down