mirror of
https://github.com/eduardogsilva/routerfleet.git
synced 2025-07-25 21:34:33 +02:00
display router information
This commit is contained in:
parent
e40eb2fdca
commit
aef7c1eaa6
4 changed files with 277 additions and 144 deletions
|
@ -60,6 +60,7 @@ def view_router_details(request):
|
|||
router = get_object_or_404(Router, uuid=request.GET.get('uuid'))
|
||||
router_status, _ = RouterStatus.objects.get_or_create(router=router)
|
||||
router_backup_list = router.routerbackup_set.all().order_by('-created')
|
||||
router_information = RouterInformation.objects.filter(router=router).first()
|
||||
downtime_last_week = router.routerdowntime_set.filter(start_time__gte=timezone.now() - timezone.timedelta(days=7)).aggregate(total=Sum('total_down_time'))['total']
|
||||
if downtime_last_week is None:
|
||||
downtime_last_week = 0
|
||||
|
@ -76,6 +77,7 @@ def view_router_details(request):
|
|||
|
||||
context = {
|
||||
'router': router,
|
||||
'router_information': router_information,
|
||||
'router_status': router_status,
|
||||
'router_backup_list': router_backup_list,
|
||||
'page_title': 'Router Details',
|
||||
|
@ -106,6 +108,16 @@ def view_manage_router(request):
|
|||
else:
|
||||
messages.warning(request, 'Router not deleted|Invalid confirmation')
|
||||
return redirect('router_list')
|
||||
elif request.GET.get('action') == 'refresh_information':
|
||||
router_information, created = RouterInformation.objects.get_or_create(router=router)
|
||||
router_information.next_retry = timezone.now()
|
||||
router_information.retry_count = 0
|
||||
router_information.success = False
|
||||
router_information.error = False
|
||||
router_information.error_message = ''
|
||||
router_information.save()
|
||||
messages.success(request, 'Router information will be updated shortly')
|
||||
return redirect('/router/details/?uuid=' + str(router.uuid))
|
||||
else:
|
||||
router = None
|
||||
|
||||
|
@ -115,6 +127,8 @@ def view_manage_router(request):
|
|||
messages.success(request, 'Router saved successfully|It may take a few minutes until monitoring starts for this router.')
|
||||
router_status, _ = RouterStatus.objects.get_or_create(router=form.instance)
|
||||
BackupSchedule.objects.filter(router=form.instance).delete()
|
||||
if form.instance.router_type == 'monitoring':
|
||||
RouterInformation.objects.filter(router=form.instance).delete()
|
||||
webadmin_settings.router_config_last_updated = timezone.now()
|
||||
webadmin_settings.save()
|
||||
return redirect('router_list')
|
||||
|
|
|
@ -142,6 +142,6 @@ STATICFILES_DIRS = [
|
|||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
MEDIA_ROOT = '/var/lib/routerfleet/'
|
||||
ROUTERFLEET_VERSION = 7502
|
||||
ROUTERFLEET_VERSION = 7503
|
||||
|
||||
from routerfleet.production_settings import *
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
{% block content %}
|
||||
<div class='row'>
|
||||
<div class='col-xl-5'>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">{{ router.name }}
|
||||
|
@ -116,8 +118,114 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
{% if router_information %}
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Router Information
|
||||
</h3>
|
||||
<span class="float-right">
|
||||
{% if not router_information.success and not router_information.error %}
|
||||
<i class="far fa-clock" title="Fetching router information on next cron"></i>
|
||||
|
||||
{% else %}
|
||||
<a href="/router/manage/?uuid={{ router.uuid }}&action=refresh_information" ><i class="fas fa-sync"></i></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-body row">
|
||||
<div class="col-lg-12">
|
||||
<ul class="list-group list-group-unbordered mb-3">
|
||||
<li class="list-group-item">
|
||||
<b>Model Name</b>
|
||||
<span class="float-right">
|
||||
{{ router_information.model_name|default_if_none:"" }}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<b>Version</b>
|
||||
<span class="float-right">
|
||||
{{ router_information.model_version|default_if_none:"" }}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<b>Serial</b>
|
||||
<span class="float-right">
|
||||
{{ router_information.serial_number|default_if_none:"" }}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<b>OS Version</b>
|
||||
<span class="float-right">
|
||||
{{ router_information.os_version|default_if_none:"" }}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<b>Firmware Version</b>
|
||||
<span class="float-right">
|
||||
{{ router_information.firmware_version|default_if_none:"" }}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<b>Architeture</b>
|
||||
<span class="float-right">
|
||||
{{ router_information.architecture|default_if_none:"" }}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<b>CPU</b>
|
||||
<span class="float-right">
|
||||
{{ router_information.cpu|default_if_none:"" }}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<b>Last Update</b>
|
||||
<span class="float-right">
|
||||
{% if router_information.success %}
|
||||
{{ router_information.last_retrieval }}
|
||||
{% elif router_information.error %}
|
||||
<i class="far fa-times-circle text-danger" title="Last update failed: {{ router_information.error_message }}"></i>
|
||||
{% else %}
|
||||
<i class="far fa-clock" title="Fetching router information on next cron"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<div>
|
||||
<b>Source Data</b>
|
||||
<span class="float-right">
|
||||
<a href="#" onclick="$('#router_information_json').slideToggle()">
|
||||
<i class="far fa-eye"></i></a>
|
||||
</span>
|
||||
</div>
|
||||
<span id="router_information_json" style="display: none;">
|
||||
{{ router_information.json_data|default_if_none:"" }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class='col-xl-7'>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% if router_backup_list or router.router_type != 'monitoring' %}
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-header">
|
||||
|
@ -212,6 +320,11 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<th>Select</th>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Version</th>
|
||||
<th>Address</th>
|
||||
<th>Status</th>
|
||||
<th>Backup</th>
|
||||
|
@ -34,6 +35,11 @@
|
|||
<td><input type="checkbox" class="router-checkbox" data-uuid="{{ router.uuid }}"></td>
|
||||
<td><a href="/router/details/?uuid={{ router.uuid }}">{{ router.name }}</a></td>
|
||||
<td>{{ router.get_router_type_display }}</td>
|
||||
<td>
|
||||
{% if router.router_type != 'monitoring' %}
|
||||
{{ router.routerinformation.os_version|default_if_none:'' }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ router.address }}</td>
|
||||
<td id="status-{{ router.uuid }}">
|
||||
{% if router.monitoring %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue