Skip to content

Commit

Permalink
[monitoring] Updated files and corrected failing qa checks #274
Browse files Browse the repository at this point in the history
Fixes #274
  • Loading branch information
praptisharma28 committed Jun 11, 2024
1 parent a219447 commit 13f3044
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
13 changes: 13 additions & 0 deletions openwisp_monitoring/db/backends/influxdb2/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.urls import path
from . import views

urlpatterns = [
path('uptime/', views.display_uptime, name='display_uptime'),
path('packet_loss/', views.display_packet_loss, name='display_packet_loss'),
path('rtt/', views.display_rtt, name='display_rtt'),
path('wifi_clients/', views.display_wifi_clients, name='display_wifi_clients'),
path('traffic/', views.display_traffic, name='display_traffic'),
path('memory/', views.display_memory, name='display_memory'),
path('cpu/', views.display_cpu, name='display_cpu'),
path('disk/', views.display_disk, name='display_disk'),
]
111 changes: 111 additions & 0 deletions openwisp_monitoring/db/backends/influxdb2/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
from django.shortcuts import render
from client import DatabaseClient
from queries import chart_query

db_client = DatabaseClient()

def display_uptime(request):
query = chart_query['uptime']['influxdb2'].format(
bucket=db_client.bucket,
content_type='your_content_type',
object_id='your_object_id'
)
result = db_client.query(query)
data = []
for table in result:
for record in table.records:
data.append(record.values)
return render(request, 'display_data.html', {'data': data})

def display_packet_loss(request):
query = chart_query['packet_loss']['influxdb2'].format(
bucket=db_client.bucket,
content_type='your_content_type',
object_id='your_object_id'
)
result = db_client.query(query)
data = []
for table in result:
for record in table.records:
data.append(record.values)
return render(request, 'display_data.html', {'data': data})

def display_rtt(request):
query = chart_query['rtt']['influxdb2'].format(
bucket=db_client.bucket,
content_type='your_content_type',
object_id='your_object_id'
)
result = db_client.query(query)
data = []
for table in result:
for record in table.records:
data.append(record.values)
return render(request, 'display_data.html', {'data': data})

def display_wifi_clients(request):
query = chart_query['wifi_clients']['influxdb2'].format(
bucket=db_client.bucket,
content_type='your_content_type',
object_id='your_object_id',
ifname='your_ifname'
)
result = db_client.query(query)
data = []
for table in result:
for record in table.records:
data.append(record.values)
return render(request, 'display_data.html', {'data': data})

def display_traffic(request):
query = chart_query['traffic']['influxdb2'].format(
bucket=db_client.bucket,
content_type='your_content_type',
object_id='your_object_id',
ifname='your_ifname'
)
result = db_client.query(query)
data = []
for table in result:
for record in table.records:
data.append(record.values)
return render(request, 'display_data.html', {'data': data})

def display_memory(request):
query = chart_query['memory']['influxdb2'].format(
bucket=db_client.bucket,
content_type='your_content_type',
object_id='your_object_id'
)
result = db_client.query(query)
data = []
for table in result:
for record in table.records:
data.append(record.values)
return render(request, 'display_data.html', {'data': data})

def display_cpu(request):
query = chart_query['cpu']['influxdb2'].format(
bucket=db_client.bucket,
content_type='your_content_type',
object_id='your_object_id'
)
result = db_client.query(query)
data = []
for table in result:
for record in table.records:
data.append(record.values)
return render(request, 'display_data.html', {'data': data})

def display_disk(request):
query = chart_query['disk']['influxdb2'].format(
bucket=db_client.bucket,
content_type='your_content_type',
object_id='your_object_id'
)
result = db_client.query(query)
data = []
for table in result:
for record in table.records:
data.append(record.values)
return render(request, 'display_data.html', {'data': data})

0 comments on commit 13f3044

Please sign in to comment.