Commit a725be3a by Bach Dániel

dashboard: fix graphite graphs

parent 980c92b1
...@@ -1606,16 +1606,6 @@ class TransferOwnershipConfirmView(LoginRequiredMixin, View): ...@@ -1606,16 +1606,6 @@ class TransferOwnershipConfirmView(LoginRequiredMixin, View):
class GraphViewBase(LoginRequiredMixin, View): class GraphViewBase(LoginRequiredMixin, View):
metrics = {
'cpu': ('cactiStyle(alias(derivative(%s.cpu.usage),'
'"cpu usage (%%)"))'),
'memory': ('cactiStyle(alias(%s.memory.usage,'
'"memory usage (%%)"))'),
'network': ('cactiStyle(aliasByMetric('
'derivative(%s.network.bytes_*)))'),
}
@staticmethod @staticmethod
def get_graphite_url(): def get_graphite_url():
graphite_host = getenv("GRAPHITE_HOST", None) graphite_host = getenv("GRAPHITE_HOST", None)
...@@ -1641,7 +1631,7 @@ class GraphViewBase(LoginRequiredMixin, View): ...@@ -1641,7 +1631,7 @@ class GraphViewBase(LoginRequiredMixin, View):
raise Http404() raise Http404()
prefix = self.get_prefix(instance) prefix = self.get_prefix(instance)
target = self.metrics[metric] % prefix target = self.metrics[metric] % {'prefix': prefix}
title = self.get_title(instance, metric) title = self.get_title(instance, metric)
params = {'target': target, params = {'target': target,
'from': '-%s' % time, 'from': '-%s' % time,
...@@ -1665,6 +1655,18 @@ class GraphViewBase(LoginRequiredMixin, View): ...@@ -1665,6 +1655,18 @@ class GraphViewBase(LoginRequiredMixin, View):
class VmGraphView(GraphViewBase): class VmGraphView(GraphViewBase):
metrics = {
'cpu': ('cactiStyle(alias(nonNegativeDerivative(%(prefix)s.cpu.usage),'
'"cpu usage (%%)"))'),
'memory': ('cactiStyle(alias(%(prefix)s.memory.usage,'
'"memory usage (%%)"))'),
'network': (
'group('
'aliasSub(nonNegativeDerivative(%(prefix)s.network.bytes_recv*),'
' ".*-(\d+)\\)", "out (vlan \\1)"),'
'aliasSub(nonNegativeDerivative(%(prefix)s.network.bytes_sent*),'
' ".*-(\d+)\\)", "in (vlan \\1)"))'),
}
model = Instance model = Instance
def get_prefix(self, instance): def get_prefix(self, instance):
...@@ -1676,12 +1678,12 @@ class VmGraphView(GraphViewBase): ...@@ -1676,12 +1678,12 @@ class VmGraphView(GraphViewBase):
class NodeGraphView(SuperuserRequiredMixin, GraphViewBase): class NodeGraphView(SuperuserRequiredMixin, GraphViewBase):
metrics = { metrics = {
'cpu': ('cactiStyle(alias(derivative(%s.cpu.times),' 'cpu': ('cactiStyle(alias(nonNegativeDerivative(%(prefix)s.cpu.times),'
'"cpu usage (%%)"))'), '"cpu usage (%%)"))'),
'memory': ('cactiStyle(alias(%s.memory.usage,' 'memory': ('cactiStyle(alias(%(prefix)s.memory.usage,'
'"memory usage (%%)"))'), '"memory usage (%%)"))'),
'network': ('cactiStyle(aliasByMetric(' 'network': ('cactiStyle(aliasByMetric('
'derivative(%s.network.bytes_*)))'), 'nonNegativeDerivative(%(prefix)s.network.bytes_*)))'),
} }
model = Node model = Node
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment