dashboard: show SoulSync's own RAM next to system memory %
the Memory Usage stat showed only global system memory (psutil.virtual_memory().percent). add the process's own resident set size (RSS) — the real 'how much RAM SoulSync uses' number — formatted MB under 1GB, GB above. headline stays the system %, subtitle now reads 'SoulSync · 612 MB' instead of the generic 'Current usage'. graceful fallback if psutil errors / older backend. useful context after the recent RAM-footprint discussions.
This commit is contained in:
parent
6802399805
commit
5a54ffe14a
3 changed files with 16 additions and 4 deletions
|
|
@ -2837,9 +2837,15 @@ def _build_system_stats():
|
||||||
uptime_seconds = time.time() - start_time
|
uptime_seconds = time.time() - start_time
|
||||||
uptime = str(timedelta(seconds=int(uptime_seconds)))
|
uptime = str(timedelta(seconds=int(uptime_seconds)))
|
||||||
|
|
||||||
# Get memory usage
|
# Get memory usage — global system %, plus SoulSync's own resident memory (RSS),
|
||||||
|
# so the dashboard can show "system load" and "how much RAM SoulSync itself uses".
|
||||||
memory = psutil.virtual_memory()
|
memory = psutil.virtual_memory()
|
||||||
memory_usage = f"{memory.percent}%"
|
memory_usage = f"{memory.percent}%"
|
||||||
|
try:
|
||||||
|
_proc_rss_mb = psutil.Process(os.getpid()).memory_info().rss / (1024 * 1024)
|
||||||
|
process_memory = f"{_proc_rss_mb:.0f} MB" if _proc_rss_mb < 1024 else f"{_proc_rss_mb / 1024:.1f} GB"
|
||||||
|
except Exception:
|
||||||
|
process_memory = None
|
||||||
|
|
||||||
# Count active downloads from download_batches (batches that are currently downloading)
|
# Count active downloads from download_batches (batches that are currently downloading)
|
||||||
active_downloads = len([batch_id for batch_id, batch_data in download_batches.items()
|
active_downloads = len([batch_id for batch_id, batch_data in download_batches.items()
|
||||||
|
|
@ -2917,7 +2923,8 @@ def _build_system_stats():
|
||||||
'download_speed': download_speed_str,
|
'download_speed': download_speed_str,
|
||||||
'active_syncs': active_syncs,
|
'active_syncs': active_syncs,
|
||||||
'uptime': uptime,
|
'uptime': uptime,
|
||||||
'memory_usage': memory_usage
|
'memory_usage': memory_usage,
|
||||||
|
'process_memory': process_memory
|
||||||
}
|
}
|
||||||
|
|
||||||
@app.route('/api/system/stats')
|
@app.route('/api/system/stats')
|
||||||
|
|
|
||||||
|
|
@ -893,7 +893,9 @@ async function fetchAndUpdateSystemStats() {
|
||||||
updateStatCard('download-speed-card', data.download_speed, 'Combined speed');
|
updateStatCard('download-speed-card', data.download_speed, 'Combined speed');
|
||||||
updateStatCard('active-syncs-card', data.active_syncs, 'Playlists syncing');
|
updateStatCard('active-syncs-card', data.active_syncs, 'Playlists syncing');
|
||||||
updateStatCard('uptime-card', data.uptime, 'Application runtime');
|
updateStatCard('uptime-card', data.uptime, 'Application runtime');
|
||||||
updateStatCard('memory-card', data.memory_usage, 'Current usage');
|
// system memory % headline + SoulSync's own RSS in the subtitle (#935 follow-up)
|
||||||
|
updateStatCard('memory-card', data.memory_usage,
|
||||||
|
data.process_memory ? `SoulSync · ${data.process_memory}` : 'Current usage');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Could not fetch system stats:', error);
|
console.warn('Could not fetch system stats:', error);
|
||||||
|
|
|
||||||
|
|
@ -687,7 +687,10 @@ function handleDashboardStats(data) {
|
||||||
updateStatCard('download-speed-card', data.download_speed, 'Combined speed');
|
updateStatCard('download-speed-card', data.download_speed, 'Combined speed');
|
||||||
updateStatCard('active-syncs-card', data.active_syncs, 'Playlists syncing');
|
updateStatCard('active-syncs-card', data.active_syncs, 'Playlists syncing');
|
||||||
updateStatCard('uptime-card', data.uptime, 'Application runtime');
|
updateStatCard('uptime-card', data.uptime, 'Application runtime');
|
||||||
updateStatCard('memory-card', data.memory_usage, 'Current usage');
|
// Headline is system memory %; subtitle shows SoulSync's own RSS so users can see the
|
||||||
|
// app's actual footprint (falls back to the generic label on older backends).
|
||||||
|
updateStatCard('memory-card', data.memory_usage,
|
||||||
|
data.process_memory ? `SoulSync · ${data.process_memory}` : 'Current usage');
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDashboardActivity(data) {
|
function handleDashboardActivity(data) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue