Commit e1a7998f authored by Andrey Vertiprahov's avatar Andrey Vertiprahov Committed by Dmitry Volodin
Browse files

Add Interface packets dashboard in MO dash.

parent 8efa8e5e
......@@ -21,8 +21,9 @@ class BaseDashboard(object):
class NotFound(Exception):
pass
def __init__(self, object):
def __init__(self, object, extra_template=None):
self.object = self.resolve_object(object)
self.extra_template = extra_template
self.logger = logging.getLogger("dashboard.%s" % self.name)
self.object_data = self.resolve_object_data(object)
self.templates_path = ""
......
......@@ -7,17 +7,17 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import absolute_import
# Third-Party modules
import demjson
from jinja2 import Environment, FileSystemLoader
# NOC modules
from .base import BaseDashboard
from noc.config import config
from noc.sa.models.managedobject import ManagedObject
from noc.inv.models.object import Object
# NOC modules
from base import BaseDashboard
class ContainerDashboard(BaseDashboard):
name = "container"
......
# -*- coding: utf-8 -*-
"""
# ---------------------------------------------------------------------
# IPSLA's dynamic dashboard
# ---------------------------------------------------------------------
# Copyright (C) 2007-2016 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
# Python modules
from __future__ import absolute_import
# Third-Party modules
import demjson
from django.db.models import Q
from jinja2 import Environment, FileSystemLoader
from noc.config import config
from noc.sa.models.managedobject import ManagedObject
# NOC modules
from base import BaseDashboard
from .base import BaseDashboard
from sla.models.slaprobe import SLAProbe
from noc.config import config
from noc.sa.models.managedobject import ManagedObject
class IPSLADashboard(BaseDashboard):
......
# -*- coding: utf-8 -*-
"""
# ---------------------------------------------------------------------
# Link's dynamic dashboard
# ---------------------------------------------------------------------
# Copyright (C) 2007-2016 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
# Python modules
from __future__ import absolute_import
# Third-Party modules
import demjson
from jinja2 import Environment, FileSystemLoader
# NOC modules
from .base import BaseDashboard
from noc.config import config
from noc.inv.models.link import Link
# NOC modules
from base import BaseDashboard
class LinkDashboard(BaseDashboard):
name = "link"
......
......@@ -6,19 +6,22 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import absolute_import
# Third-Party modules
import demjson
from django.db.models import Q
from jinja2 import Environment, FileSystemLoader
# NOC modules
from .base import BaseDashboard
from noc.config import config
from noc.inv.models.interface import Interface
from noc.inv.models.subinterface import SubInterface
# NOC modules
from noc.lib.text import split_alnum
from noc.pm.models.metrictype import MetricType
from noc.sa.models.managedobject import ManagedObject
from base import BaseDashboard
class MODashboard(BaseDashboard):
name = "mo"
......@@ -109,6 +112,7 @@ class MODashboard(BaseDashboard):
"subifaces": self.object_data["subifaces"],
"bi_id": self.object.bi_id,
"pool": self.object.pool.name,
"extra_template": self.extra_template,
"ping_interval": self.object.object_profile.ping_interval,
"discovery_interval": self.object.object_profile.periodic_discovery_interval
}
......
......@@ -6,13 +6,16 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import absolute_import
# NOC modules
from noc.lib.app.extapplication import ExtApplication, view
from dashboards.base import BaseDashboard
from dashboards.mo import MODashboard
from dashboards.link import LinkDashboard
from dashboards.ipsla import IPSLADashboard
from dashboards.container import ContainerDashboard
from .dashboards.base import BaseDashboard
from .dashboards.mo import MODashboard
from .dashboards.link import LinkDashboard
from .dashboards.ipsla import IPSLADashboard
from .dashboards.container import ContainerDashboard
from noc.core.translation import ugettext as _
......@@ -37,8 +40,9 @@ class DynamicDashboardApplication(ExtApplication):
if not dt:
return self.response_not_found("Dashboard not found")
oid = request.GET.get("id")
extra_template = request.GET.get("extra_template")
try:
dashboard = dt(oid)
dashboard = dt(oid, extra_template)
except BaseDashboard.NotFound:
return self.response_not_found("Object not found")
return dashboard.render()
......@@ -68,6 +68,17 @@
"tooltip": "png",
"url": "/ui/grafana/render/dashboard/script/noc.js?width=1800&dashboard=mo&id={{device_id}}"
},
{
"icon": "doc",
"includeVars": true,
"keepTime": true,
"tags": [],
"targetBlank": true,
"type": "link",
"title": {%if extra_template == "iface" %}"Standart View"{% else %}"PacketsView"{% endif %},
"tooltip": {%if extra_template == "iface"%}"Interface by Load"{% else %}"Interface by Packets"{% endif %},
"url": "/ui/grafana/dashboard/script/noc.js?width=1800&dashboard=mo{%if extra_template %}{% else %}&extra_template=iface{% endif %}&id={{device_id}}"
},
{
"icon": "external link",
"includeVars": true,
......@@ -120,7 +131,7 @@
"title": "{{port.name}}",
"internal_comment": "port_row",
"panels": [
{% from "graph_interface_load.j2" import interface -%}
{%if extra_template == "iface" %}{% from "graph_interface_multi.j2" import interface -%}{% else %}{% from "graph_interface_load.j2" import interface -%}{% endif %}
{{interface(port, loop.index)}}
]
}
......
{% macro interface(interface, lindex) -%}
{
"title": "${{interface.type}}",
"aliasColors": {},
"bars": false,
"internal_comment":"graph_interface_multi.j2",
"datasource": null,
"fill": 1,
"grid": {
"threshold1": null,
"threshold1Color": "rgba(216, 200, 27, 0.27)",
"threshold2": null,
"threshold2Color": "rgba(234, 112, 112, 0.22)"
},
"id": {{lindex + 100}},
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"show": true,
"sortDesc": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 2,
"links": [],
"minSpan": 6,
"nullPointMode": "connected",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeat": "{{interface.type}}",
"scopedVars": {
"{{interface.type}}": {
"selected": true,
"text": "{{interface.ports[0].name}}({{interface.ports[0].descr}})",
"value": "{{interface.ports[0].name}}"
}
},
"seriesOverrides": [
{
"alias": "/.*Input/i",
"transform": "negative-Y"
}
],
"span": 12,
"stack": true,
"steppedLine": false,
"targets": [
{
"intervalFactor": 1,
"query": "SELECT $timeSeries as t, avg(packets_in) as Input, avg(broadcast_in) as `Broadcast Input`, avg(multicast_in) as `Multicast Input`, avg(packets_out) as Output, avg(broadcast_out) as `Broadcast Output`, avg(multicast_out) as `Multicast Output` FROM $table WHERE managed_object = $bi_id and path[4]=toString(${{interface.type}}) and $timeFilter GROUP BY t ORDER BY t",
"refId": "A",
"resultFormat": "time_series",
"database": "noc",
"tableLoading": false,
"table": "interface",
"dateLoading": false,
"datetimeLoading": false,
"dateColDataType": "date",
"dateTimeColDataType": "ts"
}
],
"timeFrom": null,
"timeShift": null,
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"show": true
},
"y-axis": true,
"yaxes": [
{
"format": "pps",
"label": "packets/s",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"logBase": 1,
"show": true,
"max": null,
"format": "short",
"min": null,
"label": null
}
]
}
{%- endmacro %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment