mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
feat: add start and params
This commit is contained in:
parent
165ef260b5
commit
c9e73c17f9
|
@ -33,22 +33,27 @@ class PrometheusQueries:
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def cpu_usage() -> PrometheusInfo:
|
def cpu_usage(
|
||||||
|
start: int = int((datetime.now() - timedelta(minutes=20)).timestamp()),
|
||||||
|
end: int = int(datetime.now().timestamp()),
|
||||||
|
step: int = 60,
|
||||||
|
) -> PrometheusInfo:
|
||||||
"""Get CPU information"""
|
"""Get CPU information"""
|
||||||
start = int((datetime.now() - timedelta(minutes=20)).timestamp())
|
|
||||||
end = int(datetime.now().timestamp())
|
|
||||||
query = '100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)'
|
query = '100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)'
|
||||||
|
|
||||||
params = {"query": query, "start": start, "end": end, "step": 60}
|
params = {"query": query, "start": start, "end": end, "step": step}
|
||||||
|
|
||||||
return self._send_request(params=params)
|
return self._send_request(params=params)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def disk_usage() -> PrometheusInfo:
|
def disk_usage(
|
||||||
|
start: int = int((datetime.now() - timedelta(minutes=20)).timestamp()),
|
||||||
|
end: int = int(datetime.now().timestamp()),
|
||||||
|
step: int = 60,
|
||||||
|
) -> PrometheusInfo:
|
||||||
"""Get disk usage information"""
|
"""Get disk usage information"""
|
||||||
start = int((datetime.now() - timedelta(minutes=20)).timestamp())
|
|
||||||
end = int(datetime.now().timestamp())
|
|
||||||
query = '100 - (100 * ((node_filesystem_avail_bytes{mountpoint="/",fstype!="rootfs"} ) / (node_filesystem_size_bytes{mountpoint="/",fstype!="rootfs"}) ))'
|
query = '100 - (100 * ((node_filesystem_avail_bytes{mountpoint="/",fstype!="rootfs"} ) / (node_filesystem_size_bytes{mountpoint="/",fstype!="rootfs"}) ))'
|
||||||
|
|
||||||
params = {"query": query, "start": start, "end": end, "step": 60}
|
params = {"query": query, "start": start, "end": end, "step": step}
|
||||||
return self._send_request(params=params)
|
return self._send_request(params=params)
|
||||||
|
|
Loading…
Reference in a new issue