NUEVA BUSQUEDA DE DATOS SRI

This commit is contained in:
2023-04-11 10:50:28 -05:00
parent d9d7eb83cb
commit 6b4b3e263c
612 changed files with 11604 additions and 36692 deletions

View File

@@ -3,15 +3,15 @@ const spawn = require('child_process').spawn;
module.exports = { tree, pidsForTree, getStat };
function getStat() {
return new Promise(resolve => {
return new Promise((resolve) => {
const command = `ls /proc | grep -E '^[0-9]+$' | xargs -I{} cat /proc/{}/stat`;
const child = spawn('sh', ['-c', command], {
const spawned = spawn('sh', ['-c', command], {
stdio: ['pipe', 'pipe', 'pipe'],
});
var res = '';
child.stdout.on('data', data => (res += data));
child.on('close', () => resolve(res));
spawned.stdout.on('data', (data) => (res += data));
spawned.on('close', () => resolve(res));
});
}
@@ -30,10 +30,7 @@ function template(s) {
}
function tree(stats) {
const processes = stats
.split('\n')
.map(template)
.filter(Boolean);
const processes = stats.split('\n').map(template).filter(Boolean);
return processes;
}
@@ -43,14 +40,14 @@ function pidsForTree(tree, pid) {
pid = pid.toString();
}
const parents = [pid];
const children = [];
const pids = [];
tree.forEach(proc => {
tree.forEach((proc) => {
if (parents.indexOf(proc.PPID) !== -1) {
parents.push(proc.PID);
children.push(proc);
pids.push(proc);
}
});
return children;
return pids;
}