最近新安装了iotop,yum安装、编译安装均报错:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# iotop Traceback (most recent call last): File "/sbin/iotop", line 17, in <module> main() File "/usr/lib/python2.7/site-packages/iotop/ui.py", line 620, in main main_loop() File "/usr/lib/python2.7/site-packages/iotop/ui.py", line 610, in <lambda> main_loop = lambda: run_iotop(options) File "/usr/lib/python2.7/site-packages/iotop/ui.py", line 508, in run_iotop return curses.wrapper(run_iotop_window, options) File "/usr/lib64/python2.7/curses/wrapper.py", line 43, in wrapper return func(stdscr, *args, **kwds) File "/usr/lib/python2.7/site-packages/iotop/ui.py", line 501, in run_iotop_window ui.run() File "/usr/lib/python2.7/site-packages/iotop/ui.py", line 155, in run self.process_list.duration) File "/usr/lib/python2.7/site-packages/iotop/ui.py", line 434, in refresh_display lines = self.get_data() File "/usr/lib/python2.7/site-packages/iotop/ui.py", line 415, in get_data return list(map(format, processes)) File "/usr/lib/python2.7/site-packages/iotop/ui.py", line 388, in format cmdline = p.get_cmdline() File "/usr/lib/python2.7/site-packages/iotop/data.py", line 292, in get_cmdline proc_status = parse_proc_pid_status(self.pid) File "/usr/lib/python2.7/site-packages/iotop/data.py", line 196, in parse_proc_pid_status key, value = line.split(':\t', 1) ValueError: need more than 1 value to unpack |
编译安装:
0 1 2 3 |
wget http://guichaz.free.fr/iotop/files/iotop-0.6.tar.gz tar zxf iotop-0.4.4.tar.gz python setup.py build python setup.py install |
解决方法:(/usr/lib/python2.7/site-packages/iotop/data.py 196gg)
0 1 2 3 4 5 6 7 8 |
def parse_proc_pid_status(pid): result_dict = {} try: for line in open('/proc/%d/status' % pid): key, value = line.split(':\t', 1) result_dict[key] = value.strip() except IOError: pass # No such process return result_dict |
修改为:
0 1 2 3 4 5 6 7 8 9 10 11 |
def parse_proc_pid_status(pid): result_dict = {} try: for line in open('/proc/%d/status' % pid): try: key, value = line.split(':\t', 1) except: break result_dict[key] = value.strip() except IOError: pass # No such process return result_dict |
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!