我使用的是 Debian 不稳定版,apt-get dist-upgrade
每隔几周就会出现一次。似乎发生了一些事情,导致 dstat 中断(仅在尝试输出到 csv 时)。dstat 是基于 Python2 的,但错误不知何故出现在 Python3 的 csv 库中?有人知道这是怎么发生的吗?是不是某些包含路径被错误地链接了?
我正在运行这个:
dstat -Tcndm --nocolor --noheaders --output /var/log/dstat.csv &
错误:
Dec 28 22:36:37 localhost rc.local[879]: Traceback (most recent call last):
Dec 28 22:36:37 localhost rc.local[879]: File "/usr/bin/dstat", line 2847, in <module>
Dec 28 22:36:37 localhost rc.local[879]: main()
Dec 28 22:36:37 localhost rc.local[879]: File "/usr/bin/dstat", line 2687, in main
Dec 28 22:36:37 localhost rc.local[879]: scheduler.run()
Dec 28 22:36:37 localhost rc.local[879]: File "/usr/lib/python3.7/sched.py", line 151, in run
Dec 28 22:36:37 localhost rc.local[879]: action(*argument, **kwargs)
Dec 28 22:36:37 localhost rc.local[879]: File "/usr/bin/dstat", line 2806, in perform
Dec 28 22:36:37 localhost rc.local[879]: oline = oline + o.showcsv() + o.showcsvend(totlist, vislist)
Dec 28 22:36:37 localhost rc.local[879]: File "/usr/bin/dstat", line 547, in showcsv
Dec 28 22:36:37 localhost rc.local[879]: if isinstance(self.val[name], types.ListType) or isinstance(self.val[name], types.TupleType):
Dec 28 22:36:37 localhost rc.local[879]: NameError: name 'types' is not defined
谢谢!
答案1
好的,明白了。必须更改第 547 行和第 552 行的类型检查:
前:
if isinstance(self.val[name], types.ListType) or isinstance(self.val[name], types.TupleType):
for j, val in enumerate(self.val[name]):
line = line + printcsv(val)
if j + 1 != len(self.val[name]):
line = line + char['sep']
elif isinstance(self.val[name], types.StringType):
后:
if isinstance(self.val[name], (tuple, list)):
for j, val in enumerate(self.val[name]):
line = line + printcsv(val)
if j + 1 != len(self.val[name]):
line = line + char['sep']
elif isinstance(self.val[name], str):