Skip to content

Instantly share code, notes, and snippets.

@stelf
Last active July 19, 2021 09:38
Show Gist options
  • Save stelf/53837cff216b1815c105489045ea572e to your computer and use it in GitHub Desktop.
Save stelf/53837cff216b1815c105489045ea572e to your computer and use it in GitHub Desktop.
monitor bash processes via rxjs
// this GIST is available under the conditions of
// https://creativecommons.org/licenses/by/4.0/
const psList = require('ps-list');
const { interval, from } = require('rxjs');
const { switchMap, filter, map } = require('rxjs/operators');
interval(500)
.pipe( switchMap(() => psList()),
switchMap(e => from(e)),
filter(e => e.name === 'bash'),
)
.subscribe(console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment