Created
June 12, 2013 15:50
-
-
Save jrmoserbaltimore/5766567 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import pyawk | |
pa = pyawk.Awk(fs='\w+') | |
def cpu_num(pa): | |
pa.global[numprocs] = int(pa.field[3]) | |
def cpu_end(pa): | |
print str(pa.global[numprocs] + 1) | |
pa.add_stanza(re.compile('^processor +:'), cpu_num) | |
pa.add_end(cpu_end) | |
with open('/proc/cpuinfo') as f: | |
for line in f: | |
pa.run(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment