Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions openwisp_monitoring/check/base/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from collections import OrderedDict

from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField

from openwisp_utils.base import TimeStampedEditableModel

Expand Down Expand Up @@ -37,13 +34,11 @@ class AbstractCheck(TimeStampedEditableModel):
db_index=True,
max_length=128,
)
params = JSONField(
params = models.JSONField(
_("parameters"),
default=dict,
blank=True,
help_text=_("parameters needed to perform the check"),
load_kwargs={"object_pairs_hook": OrderedDict},
dump_kwargs={"indent": 4},
)

class Meta:
Expand Down
23 changes: 23 additions & 0 deletions openwisp_monitoring/check/migrations/0012_alter_check_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.2.4 on 2025-07-08 16:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("check", "0011_check_active_object_checks_idx"),
]

operations = [
migrations.AlterField(
model_name="check",
name="params",
field=models.JSONField(
blank=True,
default=dict,
help_text="parameters needed to perform the check",
verbose_name="parameters",
),
),
]
9 changes: 2 additions & 7 deletions openwisp_monitoring/monitoring/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from django.db import IntegrityError, models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
from openwisp_notifications.signals import notify
from pytz import timezone as tz
from pytz import utc
Expand Down Expand Up @@ -91,20 +90,16 @@ class AbstractMetric(TimeStampedEditableModel):
)
object_id = models.CharField(max_length=36, db_index=True, blank=True, null=True)
content_object = GenericForeignKey("content_type", "object_id")
main_tags = JSONField(
main_tags = models.JSONField(
_("main tags"),
default=dict,
blank=True,
load_kwargs={"object_pairs_hook": OrderedDict},
dump_kwargs={"indent": 4},
db_index=True,
)
extra_tags = JSONField(
extra_tags = models.JSONField(
_("extra tags"),
default=dict,
blank=True,
load_kwargs={"object_pairs_hook": OrderedDict},
dump_kwargs={"indent": 4},
)
# NULL means the health has yet to be assessed
is_healthy = models.BooleanField(default=None, null=True, blank=True, db_index=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.2.4 on 2025-07-08 16:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("monitoring", "0012_migrate_signal_metrics"),
]

operations = [
migrations.AlterField(
model_name="metric",
name="extra_tags",
field=models.JSONField(blank=True, default=dict, verbose_name="extra tags"),
),
migrations.AlterField(
model_name="metric",
name="main_tags",
field=models.JSONField(
blank=True, db_index=True, default=dict, verbose_name="main tags"
),
),
]
23 changes: 23 additions & 0 deletions tests/openwisp2/sample_check/migrations/0004_alter_check_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.2.4 on 2025-07-08 17:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("sample_check", "0003_add_check_inline_permissions"),
]

operations = [
migrations.AlterField(
model_name="check",
name="params",
field=models.JSONField(
blank=True,
default=dict,
help_text="parameters needed to perform the check",
verbose_name="parameters",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.2.4 on 2025-07-08 17:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("sample_monitoring", "0004_alter_metric_field_name"),
]

operations = [
migrations.AlterField(
model_name="metric",
name="extra_tags",
field=models.JSONField(blank=True, default=dict, verbose_name="extra tags"),
),
migrations.AlterField(
model_name="metric",
name="main_tags",
field=models.JSONField(
blank=True, db_index=True, default=dict, verbose_name="main tags"
),
),
]
Loading