在Python2和Python并存的环境下,有一些使用Python2的命令稍不注意就会出现问题,例如-iotop,我也是排查es占用io过高时才发现的问题。
[root@elk-server bin]# iotop
No module named 'iotop'
To run an uninstalled copy of iotop,
launch iotop.py in the top directory
通过排查发现是Python环境导致的问题,开头是-----#!/usr/bin/python,我的Python指向已经不是Python2版本了。
#!/usr/bin/python
# iotop: Display I/O usage of processes in a top like UI
# Copyright (c) 2007, 2008 Guillaume Chazarain <guichaz@gmail.com>, GPLv2
# See iotop --help for some help
from __future__ import print_function
import sys
try:
from iotop.ui import main
except ImportError as e:
print(e)
print('To run an uninstalled copy of iotop,')
print('launch iotop.py in the top directory')
else:
try:
main()
except KeyboardInterrupt:
pass
sys.exit(0)
解决:指定之前的python版本即可
vim /usr/sbin/iotop
#!/usr/bin/python2