服务器异常进程导致CUP满状态 【/usr/local/bin/agetty】

1、查询CUP占用量比较的的进程

ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     12176  410  0.0 2441556 3004 ?        Ssl  00:59   2:07 /usr/local/bin/agetty
www      12618  5.0  0.0 218820 14220 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeItemQueue --delay=0 --memory=128 --sleep=3 --tries=0
www      12616  5.0  0.0 218820 14216 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=lzdloadQueue --delay=0 --memory=128 --sleep=3 --tries=0
www      12631  4.0  0.0 218820 14220 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeLoadQueue --delay=0 --memory=128 --sleep=3 --tries=0
www      12630  4.0  0.0 218820 14220 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeItemQueue --delay=0 --memory=128 --sleep=3 --tries=0
www      12629  4.0  0.0 218820 14220 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeItemQueue --delay=0 --memory=128 --sleep=3 --tries=0
www      12628  4.0  0.0 218820 14220 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=shipQueue --delay=0 --memory=128 --sleep=3 --tries=0
www      12627  4.0  0.0 218820 14220 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeLoadQueue --delay=0 --memory=128 --sleep=3 --tries=0
www      12626  4.0  0.0 218820 14216 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeLoadQueue --delay=0 --memory=128 --sleep=3 --tries=0
www      12625  4.0  0.0 218820 14220 ?        S    00:59   0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeItemQueue --delay=0 --memory=128 --sleep=3 --tries=0

看到 /usr/local/bin/agetty CPU占用量高达410%,这个就是异常进程。

2、kill -9 12176 杀死进程,会发现过一会这个进程又出现了,尝试多次发现杀不死,阿里云提交工单,回复中毒了,让我杀毒做好备份,建议我重装系统。

 

3、临时解决方案,做个定时任务,间隔一段时间去查杀该进程

#!/bin/bash

if [ -e '/usr/bin/agetty' ];then
    rm -rf /usr/bin/aggesb
    ps -aux |grep agetty | awk '/usr\/bin\/agetty/ {print $2}' | kill -9 
fi

if [ -e '/usr/local/bin/agetty' ];then
rm -rf /usr/local/bin/agetty
ps -aux |grep agetty | awk '/usr\/local\/bin\/agetty/ {print $2}' | kill -9 
fi

4、补充更新,如果异常进程名是随机的,那么可以直接杀死cup过高的进程,慎用,可能自己的进程也会被杀。使用前要确认自己的进程cup消耗不会高于某个值,一下是杀死cup消耗高于75%的进程

#!/bin/bash
/bin/ps axf -o "pid %cpu" | awk '{if($2>=75.0) print $1}' | while read procid
do
kill -9 $procid
sleep 30
done

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值