diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2013-05-18 10:57:02 -0400 |
---|---|---|
committer | Johannes Weiner <hannes@cmpxchg.org> | 2013-05-18 10:59:26 -0400 |
commit | 2e7ae097cc10611a620869a0ea6313ad20469654 (patch) | |
tree | 123d449a7527d118f9d6194f385bc09f3ace49d7 | |
parent | ea97ff997c659fa5d19a222ba3352c2e97931d1a (diff) |
zoneinfodict: read blocks from stdin, not one-off /proc/zoneinfo
This used to be a collection utility, make it a processing utility
instead.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
-rwxr-xr-x | zoneinfodict | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/zoneinfodict b/zoneinfodict index 60ebe41..ef29273 100755 --- a/zoneinfodict +++ b/zoneinfodict @@ -1,9 +1,12 @@ #!/usr/bin/python2 +import sys + def dump(): + global lastline node = None zone = None - for line in open('/proc/zoneinfo'): + for line in sys.stdin: if line.startswith('Node '): # Node N, zone Z parts = line.split() @@ -15,5 +18,6 @@ def dump(): key = parts[0] val = int(parts[1]) print('%d_%s_%s %d' % (node, zone, key, val)) - + elif not line.strip(): + print('') dump() |