1、直接执行命令:
$sudo apt-get install bootchart $sudo apt-get install pybootchartgui安装bootchart之后,执行命令:
$bootchart ./bootchart.tgz生成bootchart.png时,直接提示错误:
parsing 'header' parsing 'proc_stat.log' parsing 'proc_ps.log' warning: no parent for pid '2' with ppid '0' parsing 'proc_diskstats.log' parsing 'kernel_pacct' merged 0 logger processes pruned 63 process, 0 exploders, 2 threads, and 0 runs False Traceback (most recent call last): File "/usr/bin/bootchart", line 23, in <module> sys.exit(main()) File "/usr/lib/pymodules/python2.6/pybootchartgui/main.py", line 137, in main render() File "/usr/lib/pymodules/python2.6/pybootchartgui/main.py", line 128, in render batch.render(writer, res, options, filename) File "/usr/lib/pymodules/python2.6/pybootchartgui/batch.py", line 41, in render draw.render(ctx, options, *res) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 282, in render draw_chart(ctx, IO_COLOR, True, chart_rect, [(sample.time, sample.util) for sample in disk_stats], proc_tree) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 201, in draw_chart yscale = float(chart_bounds[3]) / max(y for (x,y) in data) ZeroDivisionError: float division
这个跟在python2.7下执行时是一样的。解决办法有两种:
1)、到这个链接去下载draw.py,parsing.py,samples.py三个文件,然后替换ubuntu下/usr/share/pyshared/pybootchartgui/ 目录下对应的文件
2)、考虑到1)中的下载链接保不齐啥时就掉链子了,因此给个彻底的解决,直接修改ubuntu下/usr/share/pyshared/pybootchartgui/目录的draw.py,parsing.py,samples.py三个文件,分别修改如下:
draw.py:将200,201行由: xscale = float(chart_bounds[2]) / max(x for (x,y) in data) yscale = float(chart_bounds[3]) / max(y for (x,y) in data) 改为: xscale = float(chart_bounds[2]) / max(0.00001, max(x for (x,y) in data)) yscale = float(chart_bounds[3]) / max(0.00001, max(y for (x,y) in data))parsing.py:
在156行后添加: if interval == 0: interval = 1 修改后如下: sums = [ a - b for a, b in zip(sample1.diskdata, sample2.diskdata) ] if interval == 0: interval = 1
在81行后添加: if interval == 0: interval = 1 修改后如下: def calc_load(self, userCpu, sysCpu, interval): if interval == 0: <br> interval = 1
$bootchart ./bootchart.tgz出现如下错误:
Traceback (most recent call last): File "/usr/bin/bootchart", line 23, in <module> sys.exit(main()) File "/usr/lib/pymodules/python2.6/pybootchartgui/main.py", line 137, in main render() File "/usr/lib/pymodules/python2.6/pybootchartgui/main.py", line 128, in render batch.render(writer, res, options, filename) File "/usr/lib/pymodules/python2.6/pybootchartgui/batch.py", line 41, in render draw.render(ctx, options, *res) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 299, in render draw_process_bar_chart(ctx, proc_tree, times, curr_y + bar_h, w, h) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 319, in draw_process_bar_chart draw_processes_recursively(ctx, root, proc_tree, y, proc_h, chart_rect) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 357, in draw_processes_recursively child_x, child_y = draw_processes_recursively(ctx, child, proc_tree, next_y, proc_h, rect) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 349, in draw_processes_recursively draw_process_activity_colors(ctx, proc, proc_tree, x, y, w, proc_h, rect) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 376, in draw_process_activity_colors state = get_proc_state( sample.state ) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 105, in get_proc_state return "RSDTZXW".index(flag) + 1 ValueError: substring not found解决办法是修改文件:/usr/lib/pymodules/python2.6/pybootchartgui/draw.py,改动如下:
将105行: return "RSDTZXW".index(flag) + 1 改为: return "RSDTZXW".find(flag) + 1
至此,再次执行命令:
$bootchart ./bootchart.tgz期待已久的bootchart.png就生成啦
参考文章:
http://blog.csdn.net/harry_helei/article/details/7281356
https://groups.google.com/forum/?fromgroups=#!topic/android-kernel/mdGQZzVODMQ
https://bugs.launchpad.net/ubuntu/+source/bootchart/+bug/580560