巡检服务器发现swap占用率100%
for i in $(cd /proc;ls | grep “1” | awk ‘$0>100’); do awk ‘/Swap:/{a=a+KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲END{print '"i"’,a/1024"M"}’ /proc/$i/smaps;done| sort -k2nr | head
root 130589 0.0 0.0 100556 6788 ? S Mar14 0:01 Xvfb -br -nolisten tcp -screen 0 800x800x24 :3741
root 130724 0.0 0.0 100556 168 ? S 2019 0:03 Xvfb -br -nolisten tcp -screen 0 800x800x24 :2513
root 130880 0.0 0.0 100556 284 ? S 2019 0:03 Xvfb -br -nolisten tcp -screen 0 800x800x24 :2517
…
发现很多screen占用资源。
ps -ef | grep screen | grep -v grep | cut -c 9-15 | xargs kill -s 9
杀掉进程,释放资源。
0-9 ↩︎