mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Add CPU,RAM sysinfo support to the REST API to help with bot system monitoring
This commit is contained in:
parent
4c268847d4
commit
097da448e2
|
@ -259,3 +259,7 @@ def list_available_pairs(timeframe: Optional[str] = None, stake_currency: Option
|
||||||
'pair_interval': pair_interval,
|
'pair_interval': pair_interval,
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@router.get('/sysinfo', tags=['info'])
|
||||||
|
def sysinfo(rpc: RPC = Depends(get_rpc)):
|
||||||
|
return rpc._rpc_sysinfo()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
This module contains class to define a RPC communications
|
This module contains class to define a RPC communications
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging, psutil
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from datetime import date, datetime, timedelta, timezone
|
from datetime import date, datetime, timedelta, timezone
|
||||||
from math import isnan
|
from math import isnan
|
||||||
|
@ -870,3 +870,6 @@ class RPC:
|
||||||
'subplots' not in self._freqtrade.strategy.plot_config):
|
'subplots' not in self._freqtrade.strategy.plot_config):
|
||||||
self._freqtrade.strategy.plot_config['subplots'] = {}
|
self._freqtrade.strategy.plot_config['subplots'] = {}
|
||||||
return self._freqtrade.strategy.plot_config
|
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}
|
||||||
|
|
|
@ -36,6 +36,7 @@ fastapi==0.68.1
|
||||||
uvicorn==0.15.0
|
uvicorn==0.15.0
|
||||||
pyjwt==2.1.0
|
pyjwt==2.1.0
|
||||||
aiofiles==0.7.0
|
aiofiles==0.7.0
|
||||||
|
psutil==5.8.0
|
||||||
|
|
||||||
# Support for colorized terminal output
|
# Support for colorized terminal output
|
||||||
colorama==0.4.4
|
colorama==0.4.4
|
||||||
|
|
|
@ -334,6 +334,12 @@ class FtRestClient():
|
||||||
"timerange": timerange if timerange else '',
|
"timerange": timerange if timerange else '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def sysinfo(self):
|
||||||
|
"""Provides system information (CPU, RAM usage)
|
||||||
|
|
||||||
|
:return: json object
|
||||||
|
"""
|
||||||
|
return self._get("sysinfo")
|
||||||
|
|
||||||
def add_arguments():
|
def add_arguments():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user