X-Git-Url: http://git.ipfire.org/?p=collecty.git;a=blobdiff_plain;f=src%2Fcollecty%2Fplugins%2Fmemory.py;h=7fcf1154b2444dd81cf7472cf178a66b2f91940e;hp=ae90968a783564b573919886d10f9752daee68eb;hb=f181246a44db1e5e80a6181bd94ca70502878cc3;hpb=2fc9f9a209c07082fb045e97cf5559641a897747 diff --git a/src/collecty/plugins/memory.py b/src/collecty/plugins/memory.py index ae90968..7fcf115 100644 --- a/src/collecty/plugins/memory.py +++ b/src/collecty/plugins/memory.py @@ -28,6 +28,9 @@ from ..i18n import _ class GraphTemplateMemory(base.GraphTemplate): name = "memory" + upper_limit = 100 + lower_limit = 0 + rrd_graph = [ "DEF:used=%(file)s:used:AVERAGE", "DEF:cached=%(file)s:cached:AVERAGE", @@ -76,23 +79,16 @@ class GraphTemplateMemory(base.GraphTemplate): "GPRINT:swapavg:%12s\:" % _("Average") + " %6.2lf\\n", ] - rrd_graph_args = [ - "--title", _("Memory Usage"), - "--vertical-label", _("Percent"), - - # Limit y axis. - "--upper-limit", "100", - "--lower-limit", "0", - "--rigid", - ] + @property + def graph_title(self): + return _("Memory Usage") + @property + def graph_vertical_label(self): + return _("Percent") -class DataSourceMemory(base.DataSource): - name = "memory" - description = "Memory Usage Data Source" - - templates = [GraphTemplateMemory,] +class MemoryObject(base.Object): rrd_schema = [ "DS:used:GAUGE:0:100", "DS:cached:GAUGE:0:100", @@ -101,12 +97,11 @@ class DataSourceMemory(base.DataSource): "DS:swap:GAUGE:0:100", ] - @classmethod - def autocreate(cls, collecty, **kwargs): - # Every system has got memory. - return cls(collecty, **kwargs) + @property + def id(self): + return "default" - def read(self): + def collect(self): f = None try: @@ -141,3 +136,14 @@ class DataSourceMemory(base.DataSource): finally: if f: f.close() + + +class MemoryPlugin(base.Plugin): + name = "memory" + description = "Memory Usage Plugin" + + templates = [GraphTemplateMemory] + + @property + def objects(self): + yield MemoryObject(self)