Skip to content

Commit

Permalink
[fix] Fixed timseries structure for storing signal metric #586
Browse files Browse the repository at this point in the history
Updated timeseries migration script to also handle signal metrics.

Fixes #586

Signed-off-by: Gagan Deep <[email protected]>
  • Loading branch information
pandafy committed Jul 29, 2024
1 parent 34d0e8e commit 070ba3a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

- name: Install python system packages
run: |
pip install -U pip wheel setuptools
pip install -U pip wheel "setuptools~=71.0.0"
- name: Install npm dependencies
run: sudo npm install -g jshint stylelint
Expand Down
16 changes: 9 additions & 7 deletions openwisp_monitoring/device/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def write(self, data, time=None, current=False):
self.write_device_metrics = []
for interface in data.get('interfaces', []):
ifname = interface['name']
extra_tags = Metric._sort_dict(device_extra_tags)
if 'mobile' in interface:
self._write_mobile_signal(
interface, ifname, ct, self.device_data.pk, current, time=time
Expand All @@ -100,7 +99,7 @@ def write(self, data, time=None, current=False):
name=name,
key='traffic',
main_tags={'ifname': Metric._makekey(ifname)},
extra_tags=extra_tags,
extra_tags=device_extra_tags,
)
self._append_metric_data(
metric, field_value, current, time=time, extra_values=extra_values
Expand All @@ -121,7 +120,7 @@ def write(self, data, time=None, current=False):
name=name,
key='wifi_clients',
main_tags={'ifname': Metric._makekey(ifname)},
extra_tags=extra_tags,
extra_tags=device_extra_tags,
)
# avoid tsdb overwrite clients
client_time = time
Expand Down Expand Up @@ -174,7 +173,7 @@ def _get_extra_tags(self, device):
tags['location_id'] = str(device_location.location_id)
if device_location.floorplan_id:
tags['floorplan_id'] = str(device_location.floorplan_id)
return tags
return Metric._sort_dict(tags)

def _get_mobile_signal_type(self, signal):
if not signal:
Expand Down Expand Up @@ -214,7 +213,8 @@ def _write_mobile_signal(self, interface, ifname, ct, pk, current=False, time=No
content_type_id=ct.id,
configuration='signal_strength',
name='signal strength',
key=ifname,
key='signal',
main_tags={'ifname': Metric._makekey(ifname)},
)
self._append_metric_data(
metric, signal_strength, current, time=time, extra_values=extra_values
Expand Down Expand Up @@ -242,7 +242,8 @@ def _write_mobile_signal(self, interface, ifname, ct, pk, current=False, time=No
content_type_id=ct.id,
configuration='signal_quality',
name='signal quality',
key=ifname,
key='signal',
main_tags={'ifname': Metric._makekey(ifname)},
)
self._append_metric_data(
metric, signal_quality, current, time=time, extra_values=extra_values
Expand All @@ -255,7 +256,8 @@ def _write_mobile_signal(self, interface, ifname, ct, pk, current=False, time=No
content_type_id=ct.id,
configuration='access_tech',
name='access technology',
key=ifname,
key='signal',
main_tags={'ifname': Metric._makekey(ifname)},
)
self._append_metric_data(
metric,
Expand Down
6 changes: 3 additions & 3 deletions openwisp_monitoring/monitoring/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def _get_access_tech():
'type': 'scatter',
'fill': 'none',
'yaxis': {'zeroline': False},
'title': _('Signal Strength'),
'title': _('Signal Strength: {ifname}'),
'colors': (DEFAULT_COLORS[3], DEFAULT_COLORS[0]),
'description': _('Signal Strength and Signal Power, measured in dBm.'),
'summary_labels': [
Expand All @@ -495,7 +495,7 @@ def _get_access_tech():
'type': 'scatter',
'fill': 'none',
'yaxis': {'zeroline': False},
'title': _('Signal Quality'),
'title': _('Signal Quality: {ifname}'),
'colors': (DEFAULT_COLORS[3], DEFAULT_COLORS[0]),
'description': _(
_('Signal Quality and Signal to Noise Ratio (SNR), measured in dB.')
Expand All @@ -518,7 +518,7 @@ def _get_access_tech():
'charts': {
'access_tech': {
'type': 'bar',
'title': _('Access Technology'),
'title': _('Access Technology: {ifname}'),
'description': _(
_(
'Shows the access technology (LTE, UTMS, CDMA1x, etc.) '
Expand Down

0 comments on commit 070ba3a

Please sign in to comment.