diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-10-02 14:19:15 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-10-02 14:19:15 -0300 |
commit | c122cccd08cd9d103e6eae4ebcd98337e3ec3d60 (patch) | |
tree | 5350a4245ac105751244dbbd64aa59f2a43e75e5 | |
parent | 7c557369dab9802084eac4f1fa50bfe9c268a037 (diff) | |
download | python-linux-procfs-c122cccd08cd9d103e6eae4ebcd98337e3ec3d60.tar.gz |
cpustat: Add __repr__ method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | procfs/procfs.py | 9 |
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 |