From 7d1518a15df0a9322d400b3febc9bbf67551b660 Mon Sep 17 00:00:00 2001 From: machunyu Date: Tue, 29 Nov 2022 10:17:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=BB=E9=94=81=E6=A3=80=E6=B5=8B=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=B0=83=E6=95=B4=E6=94=AF=E6=8C=81=E5=AE=B9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detect-tools/arm64/detect_deadlock | Bin 0 -> 18808 bytes detect-plugin/detect-tools/detect.sh | 9 + .../detect-tools/x86_64/detect_deadlock | Bin 18560 -> 22040 bytes detect-plugin/src/extension.ts | 201 +++++++++++------- 4 files changed, 130 insertions(+), 80 deletions(-) create mode 100755 detect-plugin/detect-tools/arm64/detect_deadlock create mode 100755 detect-plugin/detect-tools/detect.sh diff --git a/detect-plugin/detect-tools/arm64/detect_deadlock b/detect-plugin/detect-tools/arm64/detect_deadlock new file mode 100755 index 0000000000000000000000000000000000000000..2be9de73d0d7b1cb7932f1b21d73cfa636d6689a GIT binary patch literal 18808 zcmeHP4|G)3nZGj=AWDD$QE)+dNw6q?5)c&-Dl>@?t%x+ls)x3d$;^aAl1w@?sZme| zuvXV@WeQcdD>T~fE=m7rt?LroZBz8@depNAVP!eH%FZPGbM0wit(I8{Z-3u?_e<`3 zGq3iXo;_#J9^>_p)pZI%0T;~J}@vDsP8g&EW z7fZ!O_&Za~5M#j?NzBUkTLigQI;%`GEmpV>l=PN*Ex<` z3fX_c1>fp|?{UEm7yMBdyvYUsl?$G5!Kv>G)$6k^_^mE@wM%<`4Ef2poau`I3YFX9 zg0FVLpK`$ux!^x=!S8p$7r5Xzy43eF7x^PD`1f4!b{AY=yoPCfUN55Etw|A&h9Z&H zxJY!yTRW1?qB+(X?GT;Ocsv#t!C-457GAb2m`H>}9nB)#7E44)y0a^pKyD%#3U3OA zTQ&uoL#=Hh)D(*+MW?jT9F4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.sh new file mode 100755 index 00000000..0d32eec7 --- /dev/null +++ b/detect-plugin/detect-tools/detect.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +USER_DIR=$(cd $(dirname $0); cd ..; pwd) + +cat $(dirname $0)/.user.pwd | sudo -S ls /proc/$1 > /dev/null + +cat $(dirname $0)/.user.pwd | sudo -S $(dirname $0)/detect_deadlock $1 + diff --git a/detect-plugin/detect-tools/x86_64/detect_deadlock b/detect-plugin/detect-tools/x86_64/detect_deadlock index 14963d52ee773991bfb0c561b21a75b7cf7e0409..74682991d4adf1ef7d74dc1d4dff697dde7a3490 100755 GIT binary patch literal 22040 zcmeHPeRN#Kb)S_iTQNpjf^CHP@Ive&0{SriKn@s7wq>4(Y%3rWrvcV$?aES+v|{&d zEEhuTt~cd%*~Cdu>YhUy)0R^>BPrIe<$shScV{7ldzq$9$%$=|I-oBkLH@B`Y@%aR&QgNLisqtKeH0q2k8#M#c zC>q4s_*^J17BeBwkeJGER0O#yy;PD<%QapKN_JJm6rdL>STN-p5+%E0Y0FtEhpF%@ zne57l)v}j9Fkk60<$SxmdX+Ccv`g2YsoRcXBUWj<4f)jXX*b(ZxX8}0?flw~>4Xjh zQ;sLag#H?|UoQ3gNZeqV2qNoz`bcWl*~5xEcQcl-H*1_AF6;yfmy}!IaDU z4D4h)b^b>Y?&ceHdByrc=yo&J;T3f~-P=|ytLq8Z^mO+n25JTxR@AImRvVAjUL}jB zdQllPrmo+(S)kvB31fG}&($*JU;KrCf2HeMYx`Lb-&?)$vYzMWH@Do(KB!F6p+xq2 z%1D{`i||J}s{OkqP8g+Qk)QM`uJGscfInU!>pftB0{D7hh4k+%f?GxKPZz--EP|h3 z1gFLost-+%Lii7h;MHk;e94Riy>0E2Orhf z8Rcy{UlGCbOPdrxYai8*)2IvATfWR1bKw=N3_9V$FL2?fT{y3)lwGCqS>P!SoB}SK z*LupUcHy+HbE-!3!me{ zyIeRr+D`p0ywXO67;xdd*HZQ_7k-XQ{~j0aUN`o-a6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;;Xhj@gFOHM diff --git a/detect-plugin/src/extension.ts b/detect-plugin/src/extension.ts index 609dcf0e..0475cfd6 100644 --- a/detect-plugin/src/extension.ts +++ b/detect-plugin/src/extension.ts @@ -35,85 +35,126 @@ export function activate(context: vscode.ExtensionContext) { // Use the console to output diagnostic information (console.log) and errors (console.error) // This line of code will only be executed once when your extension is activated console.log('Congratulations, your extension "deadlock-detect" is now active!'); - let newFn={ - local_detect_deadlock:function (message: any ,panel: vscode.WebviewPanel){ - let form=message.form; - if(form.CmdType===1){ - testPwd(form.pwd, (ok)=>{ - if(!ok){ - vscode.window.showErrorMessage("用户密码不匹配"); - return; - } - if(fs.existsSync(`/proc/${form.pid}`)) - { - exec(`echo '${form.pwd}' | sudo -S ${__dirname}/../detect-tools/x86_64/detect_deadlock ${form.pid}`, (e: any, x: string, c: string) => { - // console.log(`echo '${form.pwd}' | sudo ${__dirname}/../detect-tools/x86_64/detect_deadlock ${form.pid}`); - if(!e){ - form.data =x; - form.success='success'; - panel.webview.postMessage({ - res: form}); - } - else{ - form.success='error'; - panel.webview.postMessage({ - res: form}); - } - }); - }else{ - vscode.window.showErrorMessage(`当前不存在${form.pid}进程`); - } - }); - } - }, + let arch = process.arch; + if (arch == 'x64'){ + arch = 'x86_64'; + } - remote_detect_deadlock:function (message: any ,panel: vscode.WebviewPanel){ - let form=message.form; - if(form.CmdType===3){ - // sudo apt install sshpass - exec(`sshpass -p '${form.pwd}' ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'echo "${form.pwd}" | sudo -S ls /proc/${form.pid}'`, (e: any, x: string, c: string) => { - if(e){ - if(c.includes('Permission denied')){ - vscode.window.showErrorMessage("远程主机用户名或密码错误"); - }else if(c.includes('ls:')){ - vscode.window.showErrorMessage(`远程主机不存在${form.pid}进程`); - }else{ - vscode.window.showErrorMessage(`远程主机无法路由,或其他未知错误`); - } - return; - } - child.exec(`sshpass -p '${form.pwd}' ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} '[ ! -d .deadlock-detect ] && mkdir .deadlock-detect || ls .deadlock-detect'`, (e: any, x: string, c: any) => { - // console.log(`echo '${form.pwd}' | sudo ${__dirname}/../detect-tools/x86_64/detect_deadlock ${form.pid}`); - if(e){ - vscode.window.showErrorMessage("远程主机无法创建目录, 请确认登录用户是否拥有权限."); - return; - } - child.exec(`sshpass -p '${form.pwd}' scp -o StrictHostKeyChecking=no ${__dirname}/../detect-tools/x86_64/detect_deadlock ${form.user}@${form.ip}:./.deadlock-detect`, (e: any, x: string, c: any) => { - // console.log(`echo '${form.pwd}' | sudo ${__dirname}/../detect-tools/x86_64/detect_deadlock ${form.pid}`); - if(e){ - vscode.window.showErrorMessage("远程主机无法拷贝文件, 请确认登录用户是否拥有权限."); - return; - } - child.exec(`sshpass -p '${form.pwd}' ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'echo "${form.pwd}" | sudo -S ./.deadlock-detect/detect_deadlock ${form.pid}'`, (e: any, x: string, c: any) => { - // console.log(`echo '${form.pwd}' | sudo ${__dirname}/../detect-tools/x86_64/detect_deadlock ${form.pid}`); - if(!e){ - form.data =x; - form.success='success'; - panel.webview.postMessage({ - res: form}); - } - else{ - form.success='error'; - panel.webview.postMessage({ - res: form}); - } - }); - }); - }); - }); - } + function testPwd1(cb: (ok: boolean)=>void): void { + try{ + execSync(`cat ${__dirname}/../detect-tools/.user.pwd | sudo -S ls /root/`); + cb(true); + }catch (error: any) { + cb(false); } - }; + return; + } + + function local_detect_deadlock (message: any ,panel: vscode.WebviewPanel){ + let form=message.form; + let cmdout = ''; + + fs.writeFileSync(`${__dirname}/../detect-tools/.user.pwd`, `${form.pwd}`, { encoding: 'utf8', flag: 'w' }); + if(form.CmdType===1){ + testPwd1((ok)=>{ + if(!ok){ + vscode.window.showErrorMessage("用户密码不匹配"); + return; + } + if(fs.existsSync(`/proc/${form.pid}`)) + { + try{ + cmdout = execSync(`cat ${__dirname}/../detect-tools/.user.pwd | sudo -S ${__dirname}/../detect-tools/${arch}/detect_deadlock ${form.pid}`).toString(); + form.data =cmdout; + form.success='success'; + panel.webview.postMessage({ + res: form}); + }catch (error: any) { + form.success='error'; + panel.webview.postMessage({ + res: form}); + } + + }else{ + vscode.window.showErrorMessage(`当前不存在${form.pid}进程`); + } + }); + } + fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`); + } + + function remote_clean(form: any){ + execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'rm -rf .user.pwd detect.sh detect_deadlock'`); + + fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`); + } + + function remote_detect_deadlock(message: any, panel: vscode.WebviewPanel){ + let form=message.form; + let cmdout = ''; + let remote_arch = ''; + + // sudo apt install sshpass + fs.writeFileSync(`${__dirname}/../detect-tools/.user.pwd`, `${form.pwd}`, { encoding: 'utf8', flag: 'w' }); + + try{ + remote_arch = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'uname -m'`).toString(); + }catch (error: any) { + vscode.window.showErrorMessage(`${error.message}`); + fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`); + return; + } + if (remote_arch.includes('aarch64')){ + remote_arch = 'arm64'; + }else if (remote_arch.includes('x64') || remote_arch.includes('x86_64')){ + remote_arch = 'x86_64'; + } + + try{ + cmdout = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd scp -o StrictHostKeyChecking=no ${__dirname}/../detect-tools/.user.pwd ${__dirname}/../detect-tools/detect.sh ${__dirname}/../detect-tools/${remote_arch}/detect_deadlock ${form.user}@${form.ip}:./`).toString(); + }catch (error: any) { + let msg = `${error.message}`; + // console.log(`sshpass -f ${__dirname}/.user.pwd scp -o StrictHostKeyChecking=no ${__dirname}/.user.pwd ${__dirname}/../detect-tools/detect.sh ${__dirname}/../detect-tools/${arch}/detect_deadlock ${form.user}@${form.ip}:/tmp`); + if(msg.includes('Permission denied, please try again')){ + vscode.window.showErrorMessage("远程主机用户名或密码错误"); + }else if(msg.includes('scp:')){ + vscode.window.showErrorMessage("远程主机无法拷贝文件, 请确认登录用户是否拥有权限."); + }else { + vscode.window.showErrorMessage(msg); + } + fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`); + return; + } + + cmdout = ''; + try{ + cmdout = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'bash detect.sh ${form.pid};'`).toString(); + }catch (error: any) { + let msg = `${error.message}`; + // console.log(`sshpass -f ${__dirname}/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} '[ ! -d .deadlock-detect ] && mkdir .deadlock-detect || ls .deadlock-detect > /dev/null; mv /tmp/detect.sh .deadlock-detect; bash .deadlock-detect/detect.sh ${form.pid}'`); + if(msg.includes('ls:')){ + vscode.window.showErrorMessage(`远程主机不存在${form.pid}进程`); + }else if(msg.includes('Permission denied, please try again')){ + vscode.window.showErrorMessage("远程主机用户名或密码错误"); + }else { + console.log(msg); + vscode.window.showErrorMessage(`远程主机无法路由,或其他未知错误`); + form.success='error'; + panel.webview.postMessage({ + res: form}); + } + remote_clean(form); + return; + } + { + form.data = cmdout; + form.success='success'; + panel.webview.postMessage({ + res: form}); + } + remote_clean(form); + } + // The command has been defined in the package.json file // Now provide the implementation of the command with registerCommand // The commandId parameter must match the command field in package.json @@ -129,14 +170,14 @@ export function activate(context: vscode.ExtensionContext) { retainContextWhenHidden: true, } ); - + panel.webview.onDidReceiveMessage(message => { switch(message.form.CmdType) { case 1://local pid dead-detect - newFn.local_detect_deadlock(message,panel); + local_detect_deadlock(message,panel); break; case 3://remote pid dead-detect - newFn.remote_detect_deadlock(message,panel); + remote_detect_deadlock(message,panel); break; } });