]> git.ipfire.org Git - oddments/collecty.git/commitdiff
cpu: Automatically create one instance.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Aug 2012 15:43:48 +0000 (15:43 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Aug 2012 15:43:48 +0000 (15:43 +0000)
collecty/plugins/cpu.py

index 85cd5a151fffb39d1c9dab850f2238b5e7be0fae..bd2124252728e21c2a6ed9a0a414cef8a294d6ce 100644 (file)
@@ -19,6 +19,8 @@
 #                                                                             #
 ###############################################################################
 
+from __future__ import division
+
 import base
 
 from ..i18n import _
@@ -90,9 +92,14 @@ class PluginCPU(base.Plugin):
                           "GPRINT:idlemin:%12s\:" % _("Minimum") + " %6.2lf",
                           "GPRINT:idleavg:%12s\:" % _("Average") + " %6.2lf\\n", ]
 
+       @classmethod
+       def autocreate(cls, collecty, **kwargs):
+               # Every system has got at least one CPU.
+               return cls(collecty, **kwargs)
+
        def read(self):
                """
-                       Reads the CPU usage in jiffies.
+                       Reads the CPU usage.
                """
                f = None
 
@@ -120,7 +127,7 @@ class PluginCPU(base.Plugin):
                                full = sum([int(e) for e in entry])
 
                                for i in range(len(entry)):
-                                       entry[i] = float(entry[i]) * 100
+                                       entry[i] = int(entry[i]) * 100
                                        entry[i] = "%s" % (entry[i] / full)
 
                                entry.insert(0, "%s" % self.now)