Add CPU,RAM sysinfo support to the REST API to help with bot system monitoring

This commit is contained in:
froggleston
2021-09-25 15:48:42 +01:00
parent 4c268847d4
commit 097da448e2
4 changed files with 15 additions and 1 deletions

View File

@@ -259,3 +259,7 @@ def list_available_pairs(timeframe: Optional[str] = None, stake_currency: Option
'pair_interval': pair_interval,
}
return result
@router.get('/sysinfo', tags=['info'])
def sysinfo(rpc: RPC = Depends(get_rpc)):
return rpc._rpc_sysinfo()

View File

@@ -1,7 +1,7 @@
"""
This module contains class to define a RPC communications
"""
import logging
import logging, psutil
from abc import abstractmethod
from datetime import date, datetime, timedelta, timezone
from math import isnan
@@ -870,3 +870,6 @@ class RPC:
'subplots' not in self._freqtrade.strategy.plot_config):
self._freqtrade.strategy.plot_config['subplots'] = {}
return self._freqtrade.strategy.plot_config
def _rpc_sysinfo(self) -> Dict[str, Any]:
return {"cpu_pct": psutil.cpu_percent(interval=1, percpu=True), "ram_pct": psutil.virtual_memory().percent}