Telegram bot #150
@ -1,10 +1,9 @@
|
|||||||
const { execSync } = require("child_process");
|
const { execSync } = require("child_process");
|
||||||
|
|
||||||
function getProcess(){
|
function getProcess(){
|
||||||
const MountProcess = [];
|
let MountProcess = [];
|
||||||
var getList = ""
|
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
getList = execSync("wmic path win32_process get Processid,Commandline,WorkingSetSize").toString().split(/\n/gi).filter(a => a.trim()).map(Line => {
|
MountProcess = execSync("wmic path win32_process get Processid,Commandline,WorkingSetSize").toString().split(/\n/gi).filter(a => a.trim()).map(Line => {
|
||||||
try {
|
try {
|
||||||
Line = Line.split(/\r/gi).filter(a => a).join("").trim();
|
Line = Line.split(/\r/gi).filter(a => a).join("").trim();
|
||||||
const line_split = Line.split(/\s+/gi);
|
const line_split = Line.split(/\s+/gi);
|
||||||
@ -26,19 +25,23 @@ function getProcess(){
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}).filter(a => a).forEach(a => MountProcess.push(a));
|
}).filter(a => a);
|
||||||
} else {
|
} else {
|
||||||
getList = execSync("ps -aux").toString("utf8").split("\n").filter(d=>{return !(/USER\s+/.test(d) || d === "")})
|
MountProcess = execSync("ps -aux").toString("utf8").split("\n").filter(d=>{return !(/USER\s+/.test(d) || d === "")}).map(_line => _line.split(/\s+/)).map(_line =>{
|
||||||
for (let _line of getList) {
|
return {
|
||||||
_line = _line.split(/\s+/)
|
command: (function(){
|
||||||
MountProcess.push({
|
var command = _line[10];
|
||||||
command: (function(){var command = _line[10];const argvLenght = (_line.length - 11);for (let index = 0; index < argvLenght; index++) {command += ` ${_line[11 + index]}`;} return command})(),
|
const argvLenght = (_line.length - 11);
|
||||||
|
for (let index = 0; index < argvLenght; index++) {
|
||||||
|
command += ` ${_line[11 + index]}`;
|
||||||
|
}
|
||||||
|
return command;
|
||||||
|
})(),
|
||||||
pid: parseInt(_line[1]),
|
pid: parseInt(_line[1]),
|
||||||
mem: _line[3],
|
mem: _line[3],
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return MountProcess;
|
return MountProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user