sdbs-infra/sdbs_infra/dashboard/views.py

19 lines
550 B
Python
Raw Normal View History

import psutil
2020-06-14 12:08:11 +02:00
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"
2020-06-14 12:08:11 +02:00
return {
'services': Service.objects.all(),
'vps_stats': vps_stats
2020-06-14 12:08:11 +02:00
}