mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
feat: add prometheus as a service
This commit is contained in:
parent
80a46a58ac
commit
af7232abc8
90
selfprivacy_api/services/prometheus/__init__.py
Normal file
90
selfprivacy_api/services/prometheus/__init__.py
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
"""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):
|
||||||
|
"""Class representing Pleroma service."""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_id() -> str:
|
||||||
|
return "prometheus"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_display_name() -> str:
|
||||||
|
return "Prometheus"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_description() -> str:
|
||||||
|
return "Prometheus is a free software application used for event monitoring and alerting."
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_backup_description() -> str:
|
||||||
|
return "For Prometheus backups are not available."
|
||||||
|
|
||||||
|
@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_configuration(config_items):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_configuration(config_items):
|
||||||
|
return super().set_configuration(config_items)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_logs():
|
||||||
|
return ""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_owned_folders() -> List[OwnedPath]:
|
||||||
|
return [
|
||||||
|
OwnedPath(
|
||||||
|
path="/var/lib/prometheus",
|
||||||
|
owner="prometheus",
|
||||||
|
group="prometheus",
|
||||||
|
),
|
||||||
|
]
|
5
selfprivacy_api/services/prometheus/icon.py
Normal file
5
selfprivacy_api/services/prometheus/icon.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
PROMETHEUS_ICON = """
|
||||||
|
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M64.125 0.51C99.229 0.517 128.045 29.133 128 63.951C127.955 99.293 99.258 127.515 63.392 127.49C28.325 127.466 -0.0249987 98.818 1.26289e-06 63.434C0.0230013 28.834 28.898 0.503 64.125 0.51ZM44.72 22.793C45.523 26.753 44.745 30.448 43.553 34.082C42.73 36.597 41.591 39.022 40.911 41.574C39.789 45.777 38.52 50.004 38.052 54.3C37.381 60.481 39.81 65.925 43.966 71.34L24.86 67.318C24.893 67.92 24.86 68.148 24.925 68.342C26.736 73.662 29.923 78.144 33.495 82.372C33.872 82.818 34.732 83.046 35.372 83.046C54.422 83.084 73.473 83.08 92.524 83.055C93.114 83.055 93.905 82.945 94.265 82.565C98.349 78.271 101.47 73.38 103.425 67.223L83.197 71.185C84.533 68.567 86.052 66.269 86.93 63.742C89.924 55.099 88.682 46.744 84.385 38.862C80.936 32.538 77.754 26.242 79.475 18.619C75.833 22.219 74.432 26.798 73.543 31.517C72.671 36.167 72.154 40.881 71.478 45.6C71.38 45.457 71.258 45.35 71.236 45.227C71.1507 44.7338 71.0919 44.2365 71.06 43.737C70.647 36.011 69.14 28.567 65.954 21.457C64.081 17.275 62.013 12.995 63.946 8.001C62.639 8.694 61.456 9.378 60.608 10.357C58.081 13.277 57.035 16.785 56.766 20.626C56.535 23.908 56.22 27.205 55.61 30.432C54.97 33.824 53.96 37.146 51.678 40.263C50.76 33.607 50.658 27.019 44.722 22.793H44.72ZM93.842 88.88H34.088V99.26H93.842V88.88ZM45.938 104.626C45.889 113.268 54.691 119.707 65.571 119.24C74.591 118.851 82.57 111.756 81.886 104.626H45.938Z" fill="black"/>
|
||||||
|
</svg>
|
||||||
|
"""
|
10
selfprivacy_api/services/prometheus/prometheus.svg
Normal file
10
selfprivacy_api/services/prometheus/prometheus.svg
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_51106_4998)">
|
||||||
|
<path d="M6.35999 1.07076e-06C6.11451 -0.000261753 5.87139 0.0478616 5.64452 0.14162C5.41766 0.235378 5.21149 0.372932 5.03782 0.546418C4.86415 0.719904 4.72638 0.925919 4.63237 1.15269C4.53837 1.37945 4.48999 1.62252 4.48999 1.868V24H10.454V1.07076e-06H6.35999ZM13.473 1.07076e-06V12H17.641C18.1364 12 18.6115 11.8032 18.9619 11.4529C19.3122 11.1026 19.509 10.6274 19.509 10.132V1.07076e-06H13.473ZM13.473 18.036V24H17.641C18.1364 24 18.6115 23.8032 18.9619 23.4529C19.3122 23.1026 19.509 22.6274 19.509 22.132V18.036H13.473Z" fill="black"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_51106_4998">
|
||||||
|
<rect width="24" height="24" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 794 B |
Loading…
Reference in a new issue