xrmx / bootchart

merge of bootchart-collector and pybootchartgui
GNU General Public License v2.0
233 stars 88 forks source link

divide by zero because zero cpu.num are found on armel qemu machine #7

Closed xrmx closed 14 years ago

xrmx commented 14 years ago

Hello,

pybootchartgui fails with this:

Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/pybootchartgui/main.py", line 161, in sys.exit(main()) File "/usr/lib/python2.6/site-packages/pybootchartgui/main.py", line 116, in main options.crop_after, options.annotate) File "/usr/lib/python2.6/site-packages/pybootchartgui/parsing.py", line 592, in parse state = parse_paths (writer, ParserState(), paths) File "/usr/lib/python2.6/site-packages/pybootchartgui/parsing.py", line 512, in parse_paths state = _do_parse(writer, state, name, tf.extractfile(name)) File "/usr/lib/python2.6/site-packages/pybootchartgui/parsing.py", line 463, in _do_parse state.disk_stats = _parse_proc_disk_stat_log(file, get_num_cpus(state.headers)) File "/usr/lib/python2.6/site-packages/pybootchartgui/parsing.py", line 251, in _parse_proc_disk_stat_log util = float( sums[2] ) / 10 / interval / numCpu ZeroDivisionError: float division

i've checked that numCpu is zero because of this headers:

defaultdict(<type 'str'>, {'system.cpu.num': '0', 'system.kernel.options': 'root=/dev/sda1 initcall_debug printk.time=y quiet init=/sbin/bootchartd', 'title': 'Boot chart for debian-armel.(none) (Thu Jul 29 22:29:57 2010)', 'system.cpu': '0', 'version': '0.12.2', 'system.uname': 'Linux 2.6.26-1-versatile #1 Sun Mar 15 05:49:36 UTC 2009 armv5tejl', 'system.maxpid': '1929', 'system.release': ''})

any hint? maybe add a max(foo, 1) for every return of get_num_cpus() just to be sure?

this is 0.12.2.

xrmx commented 14 years ago

You fixed the collector to get the right number of cpus (8d7b6435c4bbf8bf43c2ce9529b0cba0b67e98ad) and added the hack suggested here to be safe in every case (dcaf5f2aef24fc7ecd47fecba28eab5e389d096a) so i think this is fixed. Thanks.