selfprivacy-rest-api/selfprivacy_api/services/prometheus/__init__.py

87 lines
2.1 KiB
Python
Raw Normal View History

2024-07-17 17:02:58 +00:00
"""Class representing Nextcloud service."""
import base64
import subprocess
from typing import Optional, List
from selfprivacy_api.services.owned_path import OwnedPath
from selfprivacy_api.utils.systemd import get_service_status
from selfprivacy_api.services.service import Service, ServiceStatus
from selfprivacy_api.services.prometheus.icon import PROMETHEUS_ICON
class Prometheus(Service):
2024-07-25 13:48:34 +00:00
"""Class representing Prometheus service."""
2024-07-17 17:02:58 +00:00
@staticmethod
def get_id() -> str:
return "monitoring"
2024-07-17 17:02:58 +00:00
@staticmethod
def get_display_name() -> str:
return "Prometheus"
@staticmethod
def get_description() -> str:
2024-07-25 13:48:34 +00:00
return "Prometheus is used for resource monitoring and alerts."
2024-07-17 17:02:58 +00:00
@staticmethod
def get_svg_icon() -> str:
return base64.b64encode(PROMETHEUS_ICON.encode("utf-8")).decode("utf-8")
@staticmethod
def get_url() -> Optional[str]:
"""Return service url."""
return None
@staticmethod
def get_subdomain() -> Optional[str]:
return None
@staticmethod
def is_movable() -> bool:
return False
@staticmethod
def is_required() -> bool:
return True
2024-07-26 15:56:17 +00:00
@staticmethod
def can_be_backed_up() -> bool:
return False
2024-07-17 17:02:58 +00:00
@staticmethod
def get_backup_description() -> str:
2024-07-25 13:48:34 +00:00
return "Backups are not available for Prometheus."
2024-07-17 17:02:58 +00:00
@staticmethod
def get_status() -> ServiceStatus:
return get_service_status("prometheus.service")
@staticmethod
def stop():
subprocess.run(["systemctl", "stop", "prometheus.service"])
@staticmethod
def start():
subprocess.run(["systemctl", "start", "prometheus.service"])
@staticmethod
def restart():
subprocess.run(["systemctl", "restart", "prometheus.service"])
@staticmethod
def get_logs():
return ""
@staticmethod
def get_owned_folders() -> List[OwnedPath]:
return [
OwnedPath(
path="/var/lib/prometheus",
owner="prometheus",
group="prometheus",
),
]