stumbleupon/tcollector — pull request #38 by donjohnson (2012-04-25 21:07:10+00:00)
Title: Updating procstats.py to use per-cpu breakdowns

...Instead of the aggregated "cpu" line. This works even in the case of single-core boxes, which have identical cpu and cpu0 lines.

Also, I corrected the tag names for columns 8 and 9 to steal and guest as per proc(5).

Output difference:

[root@ip ~]# python procstats.py|grep cpu
proc.stat.cpu 1335387940 100432039 cpu=cpu0 type=user
proc.stat.cpu 1335387940 186466 cpu=cpu0 type=nice
proc.stat.cpu 1335387940 40000695 cpu=cpu0 type=system
proc.stat.cpu 1335387940 795129191 cpu=cpu0 type=idle
proc.stat.cpu 1335387940 186613885 cpu=cpu0 type=iowait
proc.stat.cpu 1335387940 0 cpu=cpu0 type=irq
proc.stat.cpu 1335387940 4989755 cpu=cpu0 type=softirq
proc.stat.cpu 1335387940 9350148 cpu=cpu0 type=steal
proc.stat.cpu 1335387940 34197075 cpu=cpu1 type=user
proc.stat.cpu 1335387940 205380 cpu=cpu1 type=nice
proc.stat.cpu 1335387940 27119372 cpu=cpu1 type=system
proc.stat.cpu 1335387940 1056442263 cpu=cpu1 type=idle
proc.stat.cpu 1335387940 11829759 cpu=cpu1 type=iowait
proc.stat.cpu 1335387940 0 cpu=cpu1 type=irq
proc.stat.cpu 1335387940 988071 cpu=cpu1 type=softirq
proc.stat.cpu 1335387940 5920258 cpu=cpu1 type=steal

[root@ip ~]# python /opt/tcollector/collectors/0/procstats.py |grep cpu
proc.stat.cpu 1335387959 134629939 type=user
proc.stat.cpu 1335387959 391847 type=nice
proc.stat.cpu 1335387959 67120733 type=system
proc.stat.cpu 1335387959 1851573093 type=idle
proc.stat.cpu 1335387959 198443645 type=iowait
proc.stat.cpu 1335387959 0 type=irq
proc.stat.cpu 1335387959 5978215 type=softirq
proc.stat.cpu 1335387959 15270804 type=guest