mirror of
https://github.com/eduardogsilva/routerfleet.git
synced 2025-08-31 15:31:29 +02:00
Monitoring improved to update earlier when any router configuration changes
This commit is contained in:
parent
d7c44adc87
commit
23c4090ec1
6 changed files with 109 additions and 11 deletions
|
@ -1,10 +1,28 @@
|
|||
from django.shortcuts import render
|
||||
from router_manager.models import Router
|
||||
from django.http import JsonResponse
|
||||
from django.utils import timezone
|
||||
|
||||
from routerfleet_tools.models import WebadminSettings
|
||||
|
||||
|
||||
def view_router_config_timestamp(request):
|
||||
webadmin_settings, _ = WebadminSettings.objects.get_or_create(name='webadmin_settings')
|
||||
if not webadmin_settings.router_config_last_updated:
|
||||
webadmin_settings.router_config_last_updated = timezone.now()
|
||||
webadmin_settings.monitoring_last_run = timezone.now()
|
||||
webadmin_settings.save()
|
||||
return JsonResponse({'router_config': webadmin_settings.router_config_last_updated.isoformat()})
|
||||
|
||||
|
||||
def view_export_router_list(request):
|
||||
router_list = {}
|
||||
webadmin_settings, _ = WebadminSettings.objects.get_or_create(name='webadmin_settings')
|
||||
webadmin_settings.monitoring_last_run = timezone.now()
|
||||
if not webadmin_settings.router_config_last_updated:
|
||||
webadmin_settings.router_config_last_updated = timezone.now()
|
||||
webadmin_settings.save()
|
||||
|
||||
for router in Router.objects.filter(enabled=True, monitoring=True):
|
||||
router_list[str(router.uuid)] = {
|
||||
'address': router.address,
|
||||
|
@ -13,7 +31,8 @@ def view_export_router_list(request):
|
|||
'uuid': str(router.uuid),
|
||||
}
|
||||
data = {
|
||||
'router_list': router_list
|
||||
'router_list': router_list,
|
||||
'router_config': webadmin_settings.router_config_last_updated.isoformat()
|
||||
}
|
||||
return JsonResponse(data)
|
||||
|
||||
|
@ -28,4 +47,7 @@ def view_update_router_status(request):
|
|||
else:
|
||||
router.routerstatus.status_online = False
|
||||
router.routerstatus.save()
|
||||
return JsonResponse({'status': 'success'})
|
||||
webadmin_settings, _ = WebadminSettings.objects.get_or_create(name='webadmin_settings')
|
||||
webadmin_settings.monitoring_last_run = timezone.now()
|
||||
webadmin_settings.save()
|
||||
return JsonResponse({'status': 'success', 'router_config': webadmin_settings.router_config_last_updated.isoformat()})
|
Loading…
Add table
Add a link
Reference in a new issue