# theeye-ps-node

> A process lookup utility

Latest version **0.1.1** (published 2016-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install theeye-ps-node
pnpm add theeye-ps-node
yarn add theeye-ps-node
bun add theeye-ps-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2016-11-29 |
| First published | 2016-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | facugon |
| Keywords | ps, process, lookup, pid |

## Links

- npm: https://www.npmjs.com/package/theeye-ps-node
- Repository: https://github.com/theeye-io-team/ps-node
- Homepage: https://github.com/theeye-io-team/ps-node#readme
- Issues: https://github.com/theeye-io-team/ps-node/issues
- npm.io page: https://npm.io/package/theeye-ps-node

## Dependencies (1)

- [table-parser](https://npm.io/package/table-parser.md) *

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2016-11-29

## README

# ps

A Node.js module for looking up running processes.

NOTE: This version do not use command and command arguments. Use a single long string with the command and all its arguments joined with a white space. This way it is easier to search the PS CMD column (command and arguments) with a complex RegExp - equals `ps aux | grep `.

## Install

```bash
$ npm install ps-node
```

## Usage

Lookup process with spicified `pid`:

```javascript
var ps = require('ps-node');

// A simple pid lookup
ps.lookup({ pid: 12345 }, function(err, resultList ) {
    if (err) {
        throw new Error( err );
    }

    var process = resultList[ 0 ];

    if( process ){

        console.log( 'PID: %s, COMMAND: %s', process.pid, process.command );
    }
    else {
        console.log( 'No such process found!' );
    }
});

```

Or use RegExp to filter `command`:

```javascript
var ps = require('ps-node');

// A simple pid lookup
ps.lookup({
    command: 'node',
    }, function(err, resultList ) {
    if (err) {
        throw new Error( err );
    }

    resultList.forEach(function( process ){
        if( process ){

            console.log( 'PID: %s, COMMAND: %s', process.pid, process.command );
        }
    });
});

```

Also, you can use `kill` to kill process by `pid`:

```javascript
var ps = require('ps-node');

// A simple pid lookup
ps.kill( '12345', function( err ) {
    if (err) {
        throw new Error( err );
    }
    else {
        console.log( 'Process %s has been killed!', pid );
    }
});
```

You can also pass arguments to `lookup` with `psargs` as arguments for `ps` command（Note that `psargs` is not available in windows):

```javascript
var ps = require('ps-node');

// A simple pid lookup
ps.lookup({
    command: 'node',
    psargs: 'ux'
    }, function(err, resultList ) {
    if (err) {
        throw new Error( err );
    }

    resultList.forEach(function( process ){
        if( process ){
            console.log( 'PID: %s, COMMAND: %s', process.pid, process.command );
        }
    });
});

```

Lastly, you can filter a list of items by their PPID by passing a PPID to filter on. You will need to pass in a `psarg` that provides the PPID in the results (`-l` or `-j` for instance).

```javascript
var ps = require('ps-node');

// A simple pid lookup
ps.lookup({
    command: 'mongod',
    psargs: '-l',
    ppid: 82292
    }, function(err, resultList ) {
    if (err) {
        throw new Error( err );
    }

    resultList.forEach(function( process ){
        if( process ){
            console.log( 'PID: %s, COMMAND: %s', process.pid, process.command );
        }
    });
});

```

---
_Source: https://npm.io/package/theeye-ps-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
