Skip to content

Instantly share code, notes, and snippets.

@jrmoserbaltimore
Created June 12, 2013 15:50
Show Gist options
  • Save jrmoserbaltimore/5766567 to your computer and use it in GitHub Desktop.
Save jrmoserbaltimore/5766567 to your computer and use it in GitHub Desktop.
#!/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