Skip to content

Commit

Permalink
Verbiage changes + daemon mode config example
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-001 committed Nov 30, 2024
1 parent ff88ed7 commit 720629b
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ If you need Dolphie running incognito while always recording data to capture tho

To activate Daemon mode, specify the `--daemon` option, which will automatically enable `--record`. This will transform Dolphie into a resource-efficient, passive, always-on monitoring process that continuously records data. It removes Textual's TUI and creates a log file for messages while also printing them to the console.

To run Dolphie in the background using daemon mode, I recommend `systemctl` for its flexibility and management capabilities (see the [service configuration example](https://github.com/charles-001/dolphie/blob/main/dolphie.service)). While alternatives like `nohup` or `tmux` can be used, they are not advisable due to their limited management features.
To run Dolphie in the background using daemon mode, I recommend `systemctl` for its flexibility and management capabilities (see the [service configuration example](https://github.com/charles-001/dolphie/blob/main/examples/dolphie.service)). While alternatives like `nohup` or `tmux` can be used, they are not advisable due to their limited management features. Additionally, check out the [config example](https://github.com/charles-001/dolphie/blob/main/examples/dolphie-daemon.cnf) as a helpful starting point for setting up this mode.

In Daemon mode, metrics are retained for the last 10 minutes to support graphing, with performance schema metric deltas automatically reset at 10-minute intervals. This approach keeps data fresh and relevant, providing an accurate view of recent activity.

Expand Down
10 changes: 6 additions & 4 deletions dolphie/Modules/CommandManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def __init__(self):
"description": "Toggle display of threads that only have an active transaction",
},
"p": {"human_key": "p", "description": "Toggle pause for refreshing of panels"},
"P": {
"human_key": "P",
"description": (
"Toggle between Information Schema and Performance Schema for the Processlist panel"
),
},
"s": {"human_key": "s", "description": "Toggle sorting for Age in Processlist panel"},
"placeholder_3": {"human_key": "", "description": ""},
"l": {"human_key": "l", "description": "Display the most recent deadlock"},
Expand Down Expand Up @@ -62,10 +68,6 @@ def __init__(self):
"E": {"human_key": "E", "description": "Export the processlist to a CSV file"},
"k": {"human_key": "k", "description": "Kill thread by its ID"},
"K": {"human_key": "K", "description": "Kill threads by parameter(s)"},
"P": {
"human_key": "P",
"description": "Switch between using Info/Perf Schema for Processlist panel",
},
"q": {"human_key": "q", "description": "Quit"},
"r": {"human_key": "r", "description": "Set the refresh interval"},
"R": {"human_key": "R", "description": "Reset all metrics"},
Expand Down
2 changes: 1 addition & 1 deletion dolphie/Modules/TabManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def toggle_metric_graph_tabs_display(self):
self.dashboard_replay_container.display = False

# Loop the metrics and update the graph switch values based on the tab's metric data so each tab can have
# its own set of visible graphs
# its own set of visible metrics
for metric_instance_name, metric_instance in self.dolphie.metric_manager.metrics.__dict__.items():
for metric, metric_data in metric_instance.__dict__.items():
if (
Expand Down
15 changes: 8 additions & 7 deletions dolphie/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def __init__(self, *args, **kwargs):
self.dolphie_app: DolphieApp = self.app

def async_command(self, key: str):
"""Helper function to call the capture_key command asynchronously."""
self.app.call_later(self.dolphie_app.capture_key, key)
"""Helper function to call the process_key_event command asynchronously."""
self.app.call_later(self.dolphie_app.process_key_event, key)

def get_command_hits(self):
"""Helper function to get all commands and format them for discovery or search."""
Expand Down Expand Up @@ -1130,9 +1130,9 @@ async def on_key(self, event: events.Key):
if len(self.screen_stack) > 1:
return

await self.capture_key(event.key)
await self.process_key_event(event.key)

async def capture_key(self, key):
async def process_key_event(self, key):
tab = self.tab_manager.active_tab
if not tab:
return
Expand Down Expand Up @@ -1511,15 +1511,16 @@ def command_get_input(data):
if key == "P":
if dolphie.use_performance_schema_for_processlist:
dolphie.use_performance_schema_for_processlist = False
self.notify("Switched to using [b highlight]Information Schema[/b highlight] for processlist")
self.notify("Switched to using [b highlight]Information Schema[/b highlight] for Processlist panel")
else:
if dolphie.performance_schema_enabled:
dolphie.use_performance_schema_for_processlist = True
self.notify("Switched to using [b highlight]Performance Schema[/b highlight] for processlist")
self.notify("Switched to using [b highlight]Performance Schema[/b highlight] for Processlist panel")
else:
self.notify(
"You can't switch to [b highlight]Performance Schema[/b highlight] for "
"processlist because it isn't enabled"
"Processlist panel because it isn't enabled",
severity="warning",
)

elif key == "q":
Expand Down
11 changes: 11 additions & 0 deletions examples/dolphie-daemon.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[dolphie]
user = dolphie
password = super_secret_password
socket = /var/run/mysqld/mysqld.sock

refresh_interval = 2
replay_retention_hours = 48

daemon_mode = true
daemon_mode_log_file = /var/log/dolphie/daemon.log
replay_dir = /var/lib/dolphie/replays
14 changes: 14 additions & 0 deletions examples/dolphie.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Dolphie Daemon Service
After=mysql.service

[Service]
User=dolphie
ExecStart=/usr/local/bin/dolphie --config-file /etc/dolphie/dolphie-daemon.cnf
StandardOutput=journal
StandardError=journal
Environment=PYTHONUNBUFFERED=1
Restart=on-failure

[Install]
WantedBy=multi-user.target
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ myloginpath = "^0.0.4"
packaging = "^24.2"
requests = "^2.32.3"
sqlparse = "^0.5.2"
textual = {extras = ["syntax"], version = "^0.88.0"}
textual = {extras = ["syntax"], version = "^0.88.1"}
charset-normalizer = "^3.4.0"
plotext = "^5.3.2"
zstandard = "^0.23.0"
Expand Down

0 comments on commit 720629b

Please sign in to comment.