sdbs-infra/sdbs_infra/dashboard/views.py

18 lines
550 B
Python

import psutil
from django.views.generic import TemplateView
from sdbs_infra.dashboard.models import Service
class IndexView(TemplateView):
template_name = "index.html"
def get_context_data(self, **kwargs):
vps_stats = f"LOAD AVG: {', '.join(map(str, psutil.getloadavg()))} / " \
f"MEM: {psutil.virtual_memory().percent}% USED / " \
f"DISK: {psutil.disk_usage('/').percent}% USED"
return {
'services': Service.objects.all(),
'vps_stats': vps_stats
}