Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion 2 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ sudo lsof -n -F | python lsofgraph.py | dot -Tjpg > /tmp/a.jpg
OR
sudo lsof -n -F | python lsofgraph.py | dot -T svg > /tmp/a.svg
````

or add `unflatten` to the chain for a better layout:

````shell
sudo lsof -n -F | python lsofgraph.py | unflatten -l 1 -c 6 | dot -T jpg > /tmp/a.jpg
OR
sudo lsof -n -F | python lsofgraph.py | unflatten -l 1 -c 6 | dot -T svg > /tmp/a.svg
````
Note: In cases of handling large datasets, you might encounter a "maximum recursion depth exceeded" error. To work around this, you can increase the recursion limit in your Python environment by adding `sys.setrecursionlimit(15000)` in the `lsofgraph.py` script.

![example output](/example.jpg)

Expand Down
10 changes: 7 additions & 3 deletions 10 lsofgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def print_graph(procs, conns):


if __name__ == '__main__':
procs = parse_lsof()
conns = find_connections(procs)
print_graph(procs, conns)
sys.setrecursionlimit(15000) # Increase the recursion limit before processing starts
try:
procs = parse_lsof()
conns = find_connections(procs)
print_graph(procs, conns)
except RuntimeError as e:
print("Error: Recursion depth exceeded. Consider increasing the recursion limit.")
Morty Proxy This is a proxified and sanitized view of the page, visit original site.