diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-03-25 10:41:44 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-03-25 10:41:44 -0300 |
commit | 71174d4a6fe9bd6705e4c4fa4868e0b69acdcd0f (patch) | |
tree | f5e5bc920859547c0e47b3cf56c659b02d0dda4b | |
parent | 6da342f4382725ace479638cede4a3d8e6c4cae4 (diff) | |
download | python-linux-procfs-71174d4a6fe9bd6705e4c4fa4868e0b69acdcd0f.tar.gz |
[PROCFS] cpustats: allow specifying a filename
So that we can experiment with files saved from different machines.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | procfs/procfs.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py index 22f11f9..50993bf 100755 --- a/procfs/procfs.py +++ b/procfs/procfs.py @@ -376,10 +376,11 @@ class cpustat: self.guest = int(fields[8]) class cpusstats: - def __init__(self): + def __init__(self, filename = "/proc/stat"): self.entries = [] self.time = None self.hertz = os.sysconf(2) + self.filename = filename self.reload() def __iter__(self): @@ -394,7 +395,7 @@ class cpusstats: def reload(self): last_entries = self.entries self.entries = [] - f = file("/proc/stat") + f = file(self.filename) for line in f.readlines(): fields = line.strip().split() if fields[0][:3].lower() != "cpu": |