sysgraph 0.0.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sysgraph/__init__.py +1 -0
- sysgraph/__main__.py +3 -0
- sysgraph/app.py +134 -0
- sysgraph/discovery.py +530 -0
- sysgraph/dist/assets/index-DFF8eDbX.js +735 -0
- sysgraph/dist/index.html +181 -0
- sysgraph/graph.py +104 -0
- sysgraph/main.py +47 -0
- sysgraph/model.py +114 -0
- sysgraph-0.0.11.dist-info/METADATA +111 -0
- sysgraph-0.0.11.dist-info/RECORD +15 -0
- sysgraph-0.0.11.dist-info/WHEEL +5 -0
- sysgraph-0.0.11.dist-info/entry_points.txt +2 -0
- sysgraph-0.0.11.dist-info/licenses/LICENSE +21 -0
- sysgraph-0.0.11.dist-info/top_level.txt +1 -0
sysgraph/dist/index.html
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
+
<title>sysgraph | Process graph</title>
|
|
7
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap" />
|
|
8
|
+
<style>
|
|
9
|
+
html, body { height: 100%; margin: 0; overflow: hidden; font-family: 'Ubuntu', 'Segoe UI', 'Arial'; }
|
|
10
|
+
#toolbar { position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 100; background: rgba(255,255,255,0.95); border-bottom: 1px solid rgba(0,0,0,0.1); display: flex; align-items: center; padding: 0 16px; gap: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
|
|
11
|
+
#toolbar md-outlined-button {
|
|
12
|
+
--md-outlined-button-container-height: 28px;
|
|
13
|
+
--md-outlined-button-label-text-size: 12px;
|
|
14
|
+
--md-outlined-button-label-text-weight: 500;
|
|
15
|
+
--md-outlined-button-icon-size: 16px;
|
|
16
|
+
--md-outlined-button-leading-space: 10px;
|
|
17
|
+
--md-outlined-button-trailing-space: 12px;
|
|
18
|
+
--md-outlined-button-icon-offset: -2px;
|
|
19
|
+
--md-outlined-button-container-shape: 4px;
|
|
20
|
+
}
|
|
21
|
+
md-outlined-button.active {
|
|
22
|
+
--md-outlined-button-container-color: #d0e1ff;
|
|
23
|
+
--md-outlined-button-label-text-color: #1a56db;
|
|
24
|
+
--md-outlined-button-outline-color: #1a56db;
|
|
25
|
+
--md-outlined-button-icon-color: #1a56db;
|
|
26
|
+
}
|
|
27
|
+
md-outlined-button.danger {
|
|
28
|
+
--md-outlined-button-label-text-color: #dc2626;
|
|
29
|
+
--md-outlined-button-outline-color: #dc2626;
|
|
30
|
+
--md-outlined-button-icon-color: #dc2626;
|
|
31
|
+
}
|
|
32
|
+
#searchInput {
|
|
33
|
+
width: 240px;
|
|
34
|
+
--md-outlined-text-field-container-shape: 4px;
|
|
35
|
+
--md-outlined-text-field-top-space: 4px;
|
|
36
|
+
--md-outlined-text-field-bottom-space: 4px;
|
|
37
|
+
--md-outlined-text-field-input-text-size: 12px;
|
|
38
|
+
--md-outlined-text-field-label-text-size: 12px;
|
|
39
|
+
height: 28px;
|
|
40
|
+
}
|
|
41
|
+
#searchHelpTrigger {
|
|
42
|
+
--md-icon-button-icon-size: 18px;
|
|
43
|
+
--md-icon-button-state-layer-height: 28px;
|
|
44
|
+
--md-icon-button-state-layer-width: 28px;
|
|
45
|
+
height: 28px; width: 28px;
|
|
46
|
+
}
|
|
47
|
+
.search-help-anchor { position: relative; display: inline-flex; }
|
|
48
|
+
#searchHelp { display: none; position: absolute; top: 100%; left: 0; margin-top: 4px; z-index: 150; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); font-size: 12px; line-height: 1.5; background: #1e293b; color: #fff; }
|
|
49
|
+
#searchHelp.open { display: block; }
|
|
50
|
+
#searchHelp code { background: rgba(255,255,255,0.12); padding: 1px 4px; border-radius: 3px; }
|
|
51
|
+
#content { position: fixed; top: 48px; left: 0; right: 0; bottom: 0; }
|
|
52
|
+
#graph { width: 100%; height: 100%; position: relative; }
|
|
53
|
+
.details-panel { position: absolute; top: 8px; left: 8px; width: 420px; height: 350px; min-width: 200px; min-height: 120px; max-height: calc(100% - 16px); z-index: 50; background: rgba(255,255,255,0.97); box-shadow: 0 2px 12px rgba(0,0,0,0.14); border: 1px solid rgba(0,0,0,0.08); border-radius: 12px; display: none; flex-direction: column; overflow: hidden; resize: both; }
|
|
54
|
+
.details-panel.open { display: flex; }
|
|
55
|
+
.details-panel .panel-header { display: flex; align-items: center; height: 28px; padding: 0 2px 0 10px; border-bottom: 1px solid rgba(0,0,0,0.08); flex-shrink: 0; cursor: grab; user-select: none; }
|
|
56
|
+
.details-panel .panel-header:active { cursor: grabbing; }
|
|
57
|
+
.details-panel .panel-title { font-size: 12px; font-weight: 500; color: #333; flex: 1; }
|
|
58
|
+
.details-panel md-icon-button { --md-icon-button-icon-size: 16px; --md-icon-button-state-layer-height: 24px; --md-icon-button-state-layer-width: 24px; height: 24px; width: 24px; }
|
|
59
|
+
.details-panel .panel-body { flex: 1; overflow-y: auto; padding: 8px; font-family: 'Ubuntu', 'Segoe UI', 'Arial'; }
|
|
60
|
+
#detailsPanel { border-left: 3px solid #1a73e8; }
|
|
61
|
+
#detailsPanel .panel-header { background: rgba(26, 115, 232, 0.06); }
|
|
62
|
+
#version-badge { position: fixed; bottom: 6px; left: 8px; font-size: 11px; color: rgba(0,0,0,0.3); pointer-events: none; z-index: 10; font-family: 'Ubuntu', 'Segoe UI', 'Arial', sans-serif; }
|
|
63
|
+
.muted { color: #666; }
|
|
64
|
+
.toolbar-separator { width: 1px; height: 24px; background: rgba(0,0,0,0.1); }
|
|
65
|
+
hr { border: none; border-top: 1px solid rgba(0,0,0,0.08); margin: 6px 0; }
|
|
66
|
+
#contextMenu { display: none; position: fixed; z-index: 200; background: rgba(255,255,255,0.97); border: 1px solid rgba(0,0,0,0.12); border-radius: 6px; padding: 4px 0; box-shadow: 0 4px 12px rgba(0,0,0,0.15); min-width: 160px; font-size: 13px; }
|
|
67
|
+
.context-menu-item { padding: 6px 14px; cursor: pointer; user-select: none; }
|
|
68
|
+
.context-menu-item:hover { background: rgba(0,0,0,0.06); }
|
|
69
|
+
</style>
|
|
70
|
+
|
|
71
|
+
<!-- style tweakpane light theme -->
|
|
72
|
+
<style>
|
|
73
|
+
:root {
|
|
74
|
+
--tp-base-background-color: hsla(230, 5%, 90%, 1.00);
|
|
75
|
+
--tp-base-shadow-color: hsla(0, 0%, 0%, 0.10);
|
|
76
|
+
--tp-button-background-color: hsla(230, 7%, 75%, 1.00);
|
|
77
|
+
--tp-button-background-color-active: hsla(230, 7%, 60%, 1.00);
|
|
78
|
+
--tp-button-background-color-focus: hsla(230, 7%, 65%, 1.00);
|
|
79
|
+
--tp-button-background-color-hover: hsla(230, 7%, 70%, 1.00);
|
|
80
|
+
--tp-button-foreground-color: hsla(230, 10%, 30%, 1.00);
|
|
81
|
+
--tp-container-background-color: hsla(230, 15%, 30%, 0.20);
|
|
82
|
+
--tp-container-background-color-active: hsla(230, 15%, 30%, 0.32);
|
|
83
|
+
--tp-container-background-color-focus: hsla(230, 15%, 30%, 0.28);
|
|
84
|
+
--tp-container-background-color-hover: hsla(230, 15%, 30%, 0.24);
|
|
85
|
+
--tp-container-foreground-color: hsla(230, 10%, 30%, 1.00);
|
|
86
|
+
--tp-groove-foreground-color: hsla(230, 15%, 30%, 0.10);
|
|
87
|
+
--tp-input-background-color: hsla(230, 15%, 30%, 0.10);
|
|
88
|
+
--tp-input-background-color-active: hsla(230, 15%, 30%, 0.22);
|
|
89
|
+
--tp-input-background-color-focus: hsla(230, 15%, 30%, 0.18);
|
|
90
|
+
--tp-input-background-color-hover: hsla(230, 15%, 30%, 0.14);
|
|
91
|
+
--tp-input-foreground-color: hsla(230, 10%, 30%, 1.00);
|
|
92
|
+
--tp-label-foreground-color: hsla(230, 10%, 30%, 0.70);
|
|
93
|
+
--tp-monitor-background-color: hsla(230, 15%, 30%, 0.10);
|
|
94
|
+
--tp-monitor-foreground-color: hsla(230, 10%, 30%, 0.50);
|
|
95
|
+
}
|
|
96
|
+
.tp-rotv {
|
|
97
|
+
font-family: 'Ubuntu', 'Segoe UI', 'Arial', sans-serif !important;
|
|
98
|
+
opacity: 0.9;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#settingsPane {
|
|
102
|
+
max-height: calc(100% - 20px);
|
|
103
|
+
position: absolute;
|
|
104
|
+
overflow-y: auto;
|
|
105
|
+
right: 10px;
|
|
106
|
+
top: 10px;
|
|
107
|
+
}
|
|
108
|
+
</style>
|
|
109
|
+
<script type="module" crossorigin src="/assets/index-DFF8eDbX.js"></script>
|
|
110
|
+
</head>
|
|
111
|
+
<body>
|
|
112
|
+
<div id="toolbar">
|
|
113
|
+
<md-outlined-button id="toolPointer" class="active" title="Pointer Tool (P)">
|
|
114
|
+
<md-icon slot="icon">near_me</md-icon> Pointer
|
|
115
|
+
</md-outlined-button>
|
|
116
|
+
<md-outlined-button id="toolRectSelect" title="Rectangular Selection (R)">
|
|
117
|
+
<md-icon slot="icon">select_all</md-icon> Select
|
|
118
|
+
</md-outlined-button>
|
|
119
|
+
<md-outlined-button id="toolSearch" title="Search">
|
|
120
|
+
<md-icon slot="icon">search</md-icon> Search
|
|
121
|
+
</md-outlined-button>
|
|
122
|
+
<div class="toolbar-separator"></div>
|
|
123
|
+
<md-outlined-button id="deleteSelected" class="danger" title="Delete Selected Nodes (Del)" style="display: none;">
|
|
124
|
+
<md-icon slot="icon">delete</md-icon> Delete
|
|
125
|
+
</md-outlined-button>
|
|
126
|
+
<md-outlined-button id="unselectAll" title="Clear Selection" style="display: none;">
|
|
127
|
+
<md-icon slot="icon">deselect</md-icon> Unselect
|
|
128
|
+
</md-outlined-button>
|
|
129
|
+
<div class="toolbar-separator"></div>
|
|
130
|
+
<md-outlined-text-field id="searchInput" placeholder="Search nodes..." type="search" style="display: none;"></md-outlined-text-field>
|
|
131
|
+
<span class="search-help-anchor" id="searchHelpAnchor" style="display: none;">
|
|
132
|
+
<md-icon-button id="searchHelpTrigger">
|
|
133
|
+
<md-icon>help</md-icon>
|
|
134
|
+
</md-icon-button>
|
|
135
|
+
<div id="searchHelp" style="white-space: nowrap;">
|
|
136
|
+
<strong>Fuse.js Extended Search</strong><br>
|
|
137
|
+
<code>term</code> — fuzzy match<br>
|
|
138
|
+
<code>=exact</code> — exact match<br>
|
|
139
|
+
<code>'include</code> — include match<br>
|
|
140
|
+
<code>!exclude</code> — inverse (not include)<br>
|
|
141
|
+
<code>^prefix</code> — starts with<br>
|
|
142
|
+
<code>.suffix$</code> — ends with<br>
|
|
143
|
+
<code>!^notprefix</code> — does not start with<br>
|
|
144
|
+
<code>!.suffix$</code> — does not end with<br>
|
|
145
|
+
<strong>Space</strong> = AND, <strong>|</strong> = OR<br>
|
|
146
|
+
<a href="https://www.fusejs.io/extended-search.html" target="_blank" rel="noopener" style="color: #58a6ff;">Fuse.js docs →</a>
|
|
147
|
+
</div>
|
|
148
|
+
</span>
|
|
149
|
+
<span id="searchMatchCount" style="display: none; font-size: 12px; color: #666; margin-left: 4px;"></span>
|
|
150
|
+
<md-outlined-button id="addToSelection" title="Add matches to selection" style="display: none;" disabled>
|
|
151
|
+
<md-icon slot="icon">add_circle</md-icon> Add to Selection
|
|
152
|
+
</md-outlined-button>
|
|
153
|
+
<span id="selectionInfo" style="font-size: 12px; color: #666; margin-left: auto;"></span>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div id="content">
|
|
157
|
+
|
|
158
|
+
<div id="graph"></div>
|
|
159
|
+
|
|
160
|
+
<div id="detailsPanel" class="details-panel">
|
|
161
|
+
<div class="panel-header">
|
|
162
|
+
<span class="panel-title">Details</span>
|
|
163
|
+
<md-icon-button id="detailsPanelClose">
|
|
164
|
+
<md-icon>close</md-icon>
|
|
165
|
+
</md-icon-button>
|
|
166
|
+
</div>
|
|
167
|
+
<div class="panel-body" id="detailsPanelBody"></div>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<div id="settingsPane">
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div id="version-badge">0.0.11</div>
|
|
175
|
+
|
|
176
|
+
<input type="file" id="importFile" accept=".json" style="display:none">
|
|
177
|
+
|
|
178
|
+
<div id="contextMenu"></div>
|
|
179
|
+
|
|
180
|
+
</body>
|
|
181
|
+
</html>
|
sysgraph/graph.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
NodeId = str
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Node:
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
id: NodeId,
|
|
11
|
+
type: str,
|
|
12
|
+
properties: dict[str, Any] | None = None,
|
|
13
|
+
) -> None:
|
|
14
|
+
self.id: NodeId = id
|
|
15
|
+
self.type: str = type
|
|
16
|
+
self.properties: dict[str, Any] = properties or {}
|
|
17
|
+
|
|
18
|
+
def as_dict(self) -> dict:
|
|
19
|
+
return {
|
|
20
|
+
"id": self.id,
|
|
21
|
+
"type": self.type,
|
|
22
|
+
"properties": self.properties,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Relationship:
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
source_id: NodeId,
|
|
30
|
+
target_id: NodeId,
|
|
31
|
+
type: str,
|
|
32
|
+
properties: dict[str, Any] | None = None,
|
|
33
|
+
id: str | None = None,
|
|
34
|
+
) -> None:
|
|
35
|
+
self.source_id: NodeId = source_id
|
|
36
|
+
self.target_id: NodeId = target_id
|
|
37
|
+
self.type = type
|
|
38
|
+
self.properties: dict[str, Any] = properties or {}
|
|
39
|
+
self.id: str = id or generate_id()
|
|
40
|
+
|
|
41
|
+
def as_dict(self) -> dict:
|
|
42
|
+
return {
|
|
43
|
+
"id": self.id,
|
|
44
|
+
"source_id": self.source_id,
|
|
45
|
+
"target_id": self.target_id,
|
|
46
|
+
"type": self.type,
|
|
47
|
+
"properties": self.properties,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def generate_id() -> str:
|
|
52
|
+
return str(uuid.uuid4())
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Graph:
|
|
56
|
+
def __init__(self):
|
|
57
|
+
self.nodes: dict[NodeId, Node] = {}
|
|
58
|
+
self.edges: dict[NodeId, dict[NodeId, list[Relationship]]] = {}
|
|
59
|
+
|
|
60
|
+
def add_node(
|
|
61
|
+
self,
|
|
62
|
+
node_id: NodeId,
|
|
63
|
+
node_type: str,
|
|
64
|
+
properties: dict[str, Any] | None = None,
|
|
65
|
+
) -> Node:
|
|
66
|
+
node = Node(node_id, node_type, properties)
|
|
67
|
+
self.nodes[node_id] = node
|
|
68
|
+
return node
|
|
69
|
+
|
|
70
|
+
def add_edge(
|
|
71
|
+
self,
|
|
72
|
+
source_id: NodeId,
|
|
73
|
+
target_id: NodeId,
|
|
74
|
+
rel_type: str,
|
|
75
|
+
properties: dict[str, Any] | None = None,
|
|
76
|
+
id: str | None = None,
|
|
77
|
+
) -> Relationship:
|
|
78
|
+
if source_id not in self.edges:
|
|
79
|
+
self.edges[source_id] = {}
|
|
80
|
+
|
|
81
|
+
by_source_map = self.edges[source_id]
|
|
82
|
+
|
|
83
|
+
if target_id not in by_source_map:
|
|
84
|
+
by_source_map[target_id] = []
|
|
85
|
+
|
|
86
|
+
edge_list = by_source_map[target_id]
|
|
87
|
+
|
|
88
|
+
rel = Relationship(source_id, target_id, rel_type, properties, id)
|
|
89
|
+
edge_list.append(rel)
|
|
90
|
+
|
|
91
|
+
return rel
|
|
92
|
+
|
|
93
|
+
def as_dict(self) -> dict:
|
|
94
|
+
edges = []
|
|
95
|
+
|
|
96
|
+
for source_id in self.edges:
|
|
97
|
+
for edge_list in self.edges[source_id].values():
|
|
98
|
+
for edge in edge_list:
|
|
99
|
+
edges.append(edge.as_dict())
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
"nodes": [node.as_dict() for node in self.nodes.values()],
|
|
103
|
+
"edges": edges,
|
|
104
|
+
}
|
sysgraph/main.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
import coloredlogs
|
|
6
|
+
|
|
7
|
+
from sysgraph import discovery
|
|
8
|
+
|
|
9
|
+
LOGGER = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
coloredlogs.install(level="DEBUG")
|
|
14
|
+
|
|
15
|
+
processes = discovery.discover_processes()
|
|
16
|
+
for proc in processes:
|
|
17
|
+
LOGGER.info(proc)
|
|
18
|
+
|
|
19
|
+
uds_connections = discovery.discover_unix_sockets()
|
|
20
|
+
for con in uds_connections:
|
|
21
|
+
LOGGER.info(con)
|
|
22
|
+
|
|
23
|
+
open_files = discovery.get_processes_open_files()
|
|
24
|
+
for pid, files in open_files.items():
|
|
25
|
+
LOGGER.info(f"PID {pid} has {len(files)} open files")
|
|
26
|
+
for f in files:
|
|
27
|
+
LOGGER.info(f" {f}")
|
|
28
|
+
|
|
29
|
+
# pipe_connections = discovery.discover_pipe_connections()
|
|
30
|
+
# for pipe in pipe_connections:
|
|
31
|
+
# LOGGER.info(pipe)
|
|
32
|
+
|
|
33
|
+
for proc in processes:
|
|
34
|
+
try:
|
|
35
|
+
net_conns = discovery.get_net_connections(proc.pid)
|
|
36
|
+
for conn in net_conns:
|
|
37
|
+
LOGGER.info(conn)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
LOGGER.warning(
|
|
40
|
+
f"Could not get net connections for PID {proc.pid}: {e}"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
LOGGER.info("done")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
main()
|
sysgraph/model.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
class Process:
|
|
2
|
+
def __init__(self, pid: int):
|
|
3
|
+
self.pid = pid
|
|
4
|
+
self.parent_pid: int | None = None
|
|
5
|
+
self.user: str | None = None
|
|
6
|
+
self.command: str | None = None
|
|
7
|
+
self.name: str | None = None
|
|
8
|
+
self.cpu_user: float | None = None
|
|
9
|
+
self.cpu_system: float | None = None
|
|
10
|
+
self.environment: dict[str, str] | None = None
|
|
11
|
+
|
|
12
|
+
def __repr__(self) -> str:
|
|
13
|
+
return f"Process(pid={self.pid}, user={self.user}, name={self.name})"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# sample
|
|
17
|
+
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
|
|
18
|
+
# python 26688 eugene 6w FIFO 0,14 0t0 81903 pipe
|
|
19
|
+
class ProcessOpenFile:
|
|
20
|
+
def __init__(self, fd: int, file_type: str, name: str):
|
|
21
|
+
self.fd: int = fd
|
|
22
|
+
self.file_type: str = file_type
|
|
23
|
+
self.name: str = name
|
|
24
|
+
self.node: str | None = None
|
|
25
|
+
self.mode: str | None = None
|
|
26
|
+
|
|
27
|
+
def __repr__(self) -> str:
|
|
28
|
+
return (
|
|
29
|
+
f"ProcessOpenFile(fd={self.fd}, type={self.file_type}, "
|
|
30
|
+
f"node={self.node}, name={self.name}, mode={self.mode})"
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class UnixDomainSocketProcRef:
|
|
35
|
+
def __init__(self, pid: int):
|
|
36
|
+
self.pid = pid
|
|
37
|
+
self.name: str | None = None
|
|
38
|
+
self.fd: int | None = None
|
|
39
|
+
|
|
40
|
+
def __repr__(self):
|
|
41
|
+
return f"ProcRef(pid={self.pid}, name={self.name}, fd={self.fd})"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class UnixDomainSocket:
|
|
45
|
+
def __init__(self, local_inode: int, peer_inode: int):
|
|
46
|
+
self.local_inode: int = local_inode
|
|
47
|
+
self.peer_inode: int = peer_inode
|
|
48
|
+
self.local_path: str | None = None
|
|
49
|
+
self.peer_path: str | None = None
|
|
50
|
+
self.processes: list[UnixDomainSocketProcRef] = []
|
|
51
|
+
self.state: str | None = None
|
|
52
|
+
self.uds_type: str | None = None
|
|
53
|
+
|
|
54
|
+
def __repr__(self):
|
|
55
|
+
return (
|
|
56
|
+
f"UnixDomainSocket(local={self.local_inode}, peer={self.peer_inode}, "
|
|
57
|
+
f"state={self.state}, uds_type={self.uds_type}, "
|
|
58
|
+
f"local_path={self.local_path}, peer_path={self.peer_path}, "
|
|
59
|
+
f"processes={self.processes})"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class UnixDomainSocketConnection:
|
|
64
|
+
def __init__(self, socket1: UnixDomainSocket, socket2: UnixDomainSocket):
|
|
65
|
+
self.socket1 = socket1
|
|
66
|
+
self.socket2 = socket2
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class LocalInterface:
|
|
70
|
+
def __init__(self, name: str, address: str):
|
|
71
|
+
self.name = name
|
|
72
|
+
self.address = address
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class SocketAddress:
|
|
76
|
+
def __init__(self, ip: str, port: int):
|
|
77
|
+
self.ip = ip
|
|
78
|
+
self.port = port
|
|
79
|
+
|
|
80
|
+
def __hash__(self):
|
|
81
|
+
return hash(self.ip) ^ hash(self.port)
|
|
82
|
+
|
|
83
|
+
def __eq__(self, value: object) -> bool:
|
|
84
|
+
if not isinstance(value, SocketAddress):
|
|
85
|
+
raise NotImplementedError
|
|
86
|
+
return self.ip == value.ip and self.port == value.port
|
|
87
|
+
|
|
88
|
+
def __repr__(self):
|
|
89
|
+
return f"SocketAddress({self.ip}, {self.port})"
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# NOTE: models LISTEN sockets as well
|
|
93
|
+
class NetConnection:
|
|
94
|
+
def __init__(
|
|
95
|
+
self,
|
|
96
|
+
pid: int,
|
|
97
|
+
local_address: SocketAddress,
|
|
98
|
+
remote_address: SocketAddress | None,
|
|
99
|
+
socket_type: str,
|
|
100
|
+
state: str,
|
|
101
|
+
) -> None:
|
|
102
|
+
self.pid: int = pid
|
|
103
|
+
self.local_address: SocketAddress = local_address
|
|
104
|
+
self.remote_address: SocketAddress | None = remote_address
|
|
105
|
+
self.socket_type: str = socket_type
|
|
106
|
+
self.state: str = state
|
|
107
|
+
|
|
108
|
+
def connection_id(self) -> str:
|
|
109
|
+
if not self.remote_address:
|
|
110
|
+
return f"{self.socket_type}::{self.local_address.ip}:{self.local_address.port}"
|
|
111
|
+
return f"{self.socket_type}::{self.local_address.ip}:{self.local_address.port}::{self.remote_address.ip}:{self.remote_address.port}"
|
|
112
|
+
|
|
113
|
+
def __repr__(self) -> str:
|
|
114
|
+
return f"NetConnection({self.pid}, {self.local_address}, {self.remote_address}, {self.socket_type}, {self.state})"
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sysgraph
|
|
3
|
+
Version: 0.0.11
|
|
4
|
+
Summary: Visualizer for processes and their interconnections
|
|
5
|
+
Home-page: https://github.com/gubenkoved/sysgraph
|
|
6
|
+
Author: Eugene Gubenkov
|
|
7
|
+
Author-email: gubenkoved@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Source, https://github.com/gubenkoved/sysgraph
|
|
10
|
+
Project-URL: Issues, https://github.com/gubenkoved/sysgraph/issues
|
|
11
|
+
Keywords: process,visualization,graph,ipc,system,monitoring,linux,procfs
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Topic :: System :: Monitoring
|
|
18
|
+
Classifier: Topic :: System :: Systems Administration
|
|
19
|
+
Classifier: Environment :: Web Environment
|
|
20
|
+
Classifier: Framework :: FastAPI
|
|
21
|
+
Classifier: Intended Audience :: Developers
|
|
22
|
+
Classifier: Intended Audience :: System Administrators
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: psutil
|
|
27
|
+
Requires-Dist: coloredlogs
|
|
28
|
+
Requires-Dist: fastapi>=0.95
|
|
29
|
+
Requires-Dist: uvicorn[standard]>=0.20
|
|
30
|
+
Dynamic: author
|
|
31
|
+
Dynamic: author-email
|
|
32
|
+
Dynamic: classifier
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: description-content-type
|
|
35
|
+
Dynamic: home-page
|
|
36
|
+
Dynamic: keywords
|
|
37
|
+
Dynamic: license
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
Dynamic: project-url
|
|
40
|
+
Dynamic: requires-dist
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
Dynamic: summary
|
|
43
|
+
|
|
44
|
+
# sysgraph
|
|
45
|
+
|
|
46
|
+
Real-time process-graph visualizer that discovers running OS processes, their inter-process communication channels (pipes, Unix domain sockets, TCP/UDP network connections), and renders them as an interactive force-directed graph in the browser.
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- **Process discovery** — enumerates all running OS processes and their parent-child relationships
|
|
54
|
+
- **IPC visualization** — discovers pipes, Unix domain sockets, and TCP/UDP connections between processes
|
|
55
|
+
- **Interactive graph** — force-directed graph rendered in the browser with zoom, pan, drag, and search
|
|
56
|
+
- **Real-time** — fetch the latest process graph on demand via the web UI
|
|
57
|
+
- **Fuzzy search** — find processes by name, PID, command line, or any property
|
|
58
|
+
- **Adjacency filtering** — right-click a node to show only its neighbors
|
|
59
|
+
- **Configurable** — tune d3 force parameters, colors, and filters via the settings panel
|
|
60
|
+
- **Export/Import** — save and load graph snapshots as JSON
|
|
61
|
+
|
|
62
|
+
## Requirements
|
|
63
|
+
|
|
64
|
+
- **Linux** (relies on `/proc` filesystem and the `ss` command)
|
|
65
|
+
- **Python ≥ 3.12**
|
|
66
|
+
- Root/sudo recommended for full visibility into all processes
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install sysgraph
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Start the web server (default: http://localhost:8000)
|
|
78
|
+
sysgraph
|
|
79
|
+
|
|
80
|
+
# Specify a custom port
|
|
81
|
+
sysgraph --port 9000
|
|
82
|
+
|
|
83
|
+
# Or run as a module
|
|
84
|
+
python -m sysgraph
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Open your browser to the displayed URL to see the interactive process graph.
|
|
88
|
+
|
|
89
|
+
For full visibility into all processes and their connections, run with elevated privileges:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
sudo sysgraph
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Docker
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
docker run --rm -it --pid=host --net=host gubenkoved/sysgraph
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The `--pid=host` and `--net=host` flags allow the container to see host processes and network connections.
|
|
102
|
+
|
|
103
|
+
## How It Works
|
|
104
|
+
|
|
105
|
+
1. The **FastAPI backend** uses `psutil` and Linux-specific APIs (`/proc`, `ss`) to discover processes, pipes, Unix domain sockets, and network connections.
|
|
106
|
+
2. It builds a graph of processes (nodes) and their IPC channels (edges).
|
|
107
|
+
3. The **browser frontend** fetches the graph via `GET /api/graph` and renders it using [force-graph](https://github.com/vasturiano/force-graph) with d3 physics simulation.
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
sysgraph/__init__.py,sha256=OaIl7v-6zEWEY90Jlh6yoBjO3zWX1oX7RsvqrK3o1TU,23
|
|
2
|
+
sysgraph/__main__.py,sha256=4xkbknF34pNFhuzOQCbpbRk86wFf-6CwRGwHt8lMm_w,38
|
|
3
|
+
sysgraph/app.py,sha256=9AR2dUIgA_-Hh99XugVQ30iwI1wzmIXORli_ezf-uWM,3238
|
|
4
|
+
sysgraph/discovery.py,sha256=ze7NUGmhKH660SnW_ltzzlfpiiCCaBM9msBvvrftGwk,16821
|
|
5
|
+
sysgraph/graph.py,sha256=87LDJeol_Ul5v-poQQEAzogYUsh5-GZkfnHde0oE6vk,2584
|
|
6
|
+
sysgraph/main.py,sha256=cv0R-F-44Yqssd5BKhJwH6jo5TxWcPcNcBBe1xhscxU,1128
|
|
7
|
+
sysgraph/model.py,sha256=MzORWt40hE9JIBp2xAC8GuFCOXhd1F97N4aWEuMVdiY,3753
|
|
8
|
+
sysgraph/dist/index.html,sha256=QdcG2tV8hTLmUMe1CmynStdujBk8j4-7GZD55RKxu3k,9889
|
|
9
|
+
sysgraph/dist/assets/index-DFF8eDbX.js,sha256=XbMsKdzYK8pMVD-AOVZojOTUg4UPXQX4pjBl1huSSsA,540740
|
|
10
|
+
sysgraph-0.0.11.dist-info/licenses/LICENSE,sha256=hMIqrlRpa9gquZetc6_CZWEA38Im4Qpajy4bKXfue-U,1072
|
|
11
|
+
sysgraph-0.0.11.dist-info/METADATA,sha256=dQS8Fj02k-47GnzdFeQIb24tzHv1ZF-66fD8HU79q4M,3767
|
|
12
|
+
sysgraph-0.0.11.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
13
|
+
sysgraph-0.0.11.dist-info/entry_points.txt,sha256=xH4l6dzc31IibOuHOeoWu4imzO9ioEAhCFvgbdLy7-s,47
|
|
14
|
+
sysgraph-0.0.11.dist-info/top_level.txt,sha256=KEBllgJxmmGxhZxtSI1IxbuC9RVzTlY8qHIErfPVOuI,9
|
|
15
|
+
sysgraph-0.0.11.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Eugene Gubenkov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sysgraph
|