#########################################################################
#
# Copyright (C) 2018 OSGeo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################
from django.contrib import admin
# Register your models here.
from geonode.monitoring.models import (
Host,
Service,
ServiceType,
ServiceTypeMetric,
Metric,
RequestEvent,
ExceptionEvent,
MetricLabel,
MetricValue,
MonitoredResource,
NotificationCheck,
MetricNotificationCheck,
NotificationMetricDefinition,
NotificationReceiver,
EventType,
)
@admin.register(Host)
[docs]
class HostAdmin(admin.ModelAdmin):
[docs]
list_display = (
"name",
"active",
)
@admin.register(EventType)
[docs]
class EventTypeAdmin(admin.ModelAdmin):
[docs]
list_display = ("name",)
@admin.register(ServiceType)
[docs]
class ServiceTypeAdmin(admin.ModelAdmin):
[docs]
list_display = ("name",)
@admin.register(Service)
[docs]
class ServiceAdmin(admin.ModelAdmin):
[docs]
list_display = (
"name",
"active",
"host_name",
"service_type",
"last_check",
"url",
)
[docs]
def host_name(self, obj):
return obj.host.name
[docs]
def service_type(self, obj):
return obj.service_type.name
@admin.register(ServiceTypeMetric)
[docs]
class ServiceTypeMetricAdmin(admin.ModelAdmin):
[docs]
list_display = (
"service_type",
"metric",
)
[docs]
list_filter = (
"service_type",
"metric",
)
@admin.register(Metric)
[docs]
class MetricAdmin(admin.ModelAdmin):
[docs]
list_display = (
"name",
"type",
)
[docs]
list_filter = ("type",)
@admin.register(RequestEvent)
[docs]
class RequestEvent(admin.ModelAdmin):
[docs]
list_display = (
"service",
"created",
"received",
"request_method",
"response_status",
"event_type",
"response_size",
"client_country",
"request_path",
)
[docs]
list_filter = (
"host",
"service",
"request_method",
"response_status",
"event_type",
)
@admin.register(MetricLabel)
[docs]
class MetricLabelAdmin(admin.ModelAdmin):
[docs]
list_display = ("name",)
@admin.register(MetricValue)
[docs]
class MetricValueAdmin(admin.ModelAdmin):
[docs]
list_display = (
"service_metric",
"service",
"event_type",
"resource",
"label",
"value",
"value_num",
"value_raw",
"samples_count",
"data",
)
[docs]
list_filter = ("service_metric", "service", "event_type")
@admin.register(MonitoredResource)
[docs]
class MonitoredResourceAdmin(admin.ModelAdmin):
[docs]
list_display = (
"id",
"name",
"type",
)
[docs]
list_filter = ("type",)
@admin.register(ExceptionEvent)
[docs]
class ExceptionEventAdmin(admin.ModelAdmin):
[docs]
list_display = (
"created",
"service",
"error_type",
)
@admin.register(NotificationCheck)
[docs]
class NotificationCheckAdmin(admin.ModelAdmin):
[docs]
list_display = (
"name",
"active",
)
[docs]
list_filter = ("active",)
@admin.register(MetricNotificationCheck)
[docs]
class MetricNotificationCheckAdmin(admin.ModelAdmin):
[docs]
list_display = (
"id",
"notification_check",
"metric",
"min_value",
"max_value",
"max_timeout",
)
[docs]
raw_id_fields = (
"notification_check",
"resource",
"label",
)
@admin.register(NotificationMetricDefinition)
[docs]
class NotificationCheckDefinitionAdmin(admin.ModelAdmin):
[docs]
list_display = (
"notification_check",
"metric",
"field_option",
"min_value",
"max_value",
"steps",
)
[docs]
raw_id_fields = (
"notification_check",
"metric",
)
@admin.register(NotificationReceiver)
[docs]
class NotificationReceiverAdmin(admin.ModelAdmin):
[docs]
list_display = (
"notification_check",
"user",
"email",
)
[docs]
raw_id_fields = (
"notification_check",
"user",
)