summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-10-02 14:19:15 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-10-02 14:19:15 -0300
commitc122cccd08cd9d103e6eae4ebcd98337e3ec3d60 (patch)
tree5350a4245ac105751244dbbd64aa59f2a43e75e5
parent7c557369dab9802084eac4f1fa50bfe9c268a037 (diff)
downloadpython-linux-procfs-c122cccd08cd9d103e6eae4ebcd98337e3ec3d60.tar.gz
cpustat: Add __repr__ method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xprocfs/procfs.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py
index fdacba4..fc5b911 100755
--- a/procfs/procfs.py
+++ b/procfs/procfs.py
@@ -870,6 +870,15 @@ class cpustat:
if len(fields) > 8:
self.guest = int(fields[8])
+ def __repr__(self):
+ s = "< user: %s, nice: %s, system: %s, idle: %s, iowait: %s, irq: %s, softirq: %s" % \
+ (self.user, self.nice, self.system, self.idle, self.iowait, self.irq, self.softirq)
+ if hasattr(self, 'steal'):
+ s += ", steal: %d" % self.steal
+ if hasattr(self, 'guest'):
+ s += ", guest: %d" % self.guest
+ return s + ">"
+
class cpusstats:
"""
Dictionary with information about CPUs in the system. First entry in the