Giter Site home page Giter Site logo

reklatsmasters / node-process-list Goto Github PK

View Code? Open in Web Editor NEW
66.0 4.0 18.0 490 KB

Cross-platform native method to receive the list of the launched processes

License: MIT License

Python 3.26% JavaScript 8.07% C++ 85.28% C 1.06% Makefile 1.13% Batchfile 0.72% Dockerfile 0.48%
node js cpp process task-list c-plus-plus cross-platform-native process-monitor process-tree process-list

node-process-list's Introduction

logo

Cross-platform native method to receive the list of the launched processes

Build Status Build status npm license downloads Greenkeeper badge

Install

npm i process-list
# or
yarn add process-list

It's that easy! npm will download one of the prebuilt binaries for your OS. If you need to build process-list, see node-gyp for more details.

Supported OS

  • Windows Windows 7+, Windows Server 2008 R2+
  • Linux any Linux-based distributives
  • OS X Soon...

Usage

const { snapshot } = require("process-list");

const tasks = await snapshot('pid', 'name');
console.log(tasks);

// output
// [{
//    name: "1.exe",
//    pid: 1234,
// }, ... ]

API

snapshot(...field: String): Promise<[]Object>

Returns the list of the launched processes.

allowedFields: []String

List of allowed fields.

  • pid: Number - process pid
  • ppid: Number - parent process pid
  • name: String - process name (title)
  • path: String - full path to the process binary file
  • threads: Number - threads per process
  • owner: String - the owner of the process
  • priority: Number - an os-specific process priority
  • cmdline: String - full command line of the process
  • starttime: Date - the process start date / time
  • vmem: String - virtual memory size in bytes used by process
  • pmem: String - physical memory size in bytes used by process
  • cpu: Number - cpu usage by process in percent
  • utime: String - amount of time in ms that this process has been scheduled in user mode
  • stime: String - amount of time that in ms this process has been scheduled in kernel mode

License

MIT, Copyright © 2014 - 2019 Dmitry Tsvettsikh

node-process-list's People

Contributors

greenkeeper[bot] avatar reklatsmasters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-process-list's Issues

No prebuilt binaries for electron/node

Trying to use this module with electron . The electron-builder cannot find the correct binaries.

  • electron-builder  version=22.8.0
  • rebuilding native dependencies  [email protected] platform=linux arch=x64
  • install prebuilt binary  name=process-list version=2.0.0 platform=linux arch=x64
  • build native dependency from sources  name=process-list
                                          version=2.0.0
                                          platform=linux
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.5
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for cached prebuild @ /home/itapai/.npm/_prebuilds/312b34-process-list-v2.0.0-electron-v80-linux-x64.tar.gz
    prebuild-install http request GET https://github.com/reklatsmasters/node-process-list/releases/download/v2.0.0/process-list-v2.0.0-electron-v80-linux-x64.tar.gz
    prebuild-install http 404 https://github.com/reklatsmasters/node-process-list/releases/download/v2.0.0/process-list-v2.0.0-electron-v80-linux-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=9.2.0 runtime=electron arch=x64 libc= platform=linux)

It tried to build them itself, but it's failing on my machine.
error_log.txt

Electron version: 9.2.0
Node version: 14.7.0

Could you build and release them?
Thanks

CPU Usage is incorrect

CPU usage for multithreaded processes which use more than 1 cpu, shows CPU usage as 100% which does not reflect the real usage.

install error at mac

➜  tmp npm i process-list

> [email protected] install /Users/tz/Workspaces/tmp/node_modules/process-list
> prebuild-install || node-gyp rebuild

prebuild-install info begin Prebuild-install version 2.2.1
prebuild-install info looking for local prebuild @ prebuilds/process-list-v1.2.1-node-v57-darwin-x64.tar.gz
prebuild-install info looking for cached prebuild @ /Users/tz/.npm/_prebuilds/https-github.com-reklatsmasters-node-process-list-releases-download-v1.2.1-process-list-v1.2.1-node-v57-darwin-x64.tar.gz
prebuild-install http request GET https://github.com/reklatsmasters/node-process-list/releases/download/v1.2.1/process-list-v1.2.1-node-v57-darwin-x64.tar.gz
prebuild-install http 404 https://github.com/reklatsmasters/node-process-list/releases/download/v1.2.1/process-list-v1.2.1-node-v57-darwin-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=8.1.4 runtime=node arch=x64 platform=darwin)
  CXX(target) Release/obj.target/processlist/src/main.o
  CXX(target) Release/obj.target/processlist/src/snapshot.o
../src/snapshot.cpp:41:5: error: cannot use 'try' with exceptions disabled
    try {
    ^
1 error generated.
make: *** [Release/obj.target/processlist/src/snapshot.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/tz/git/nvs/node/8.1.4/x64/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/Users/tz/git/nvs/node/8.1.4/x64/bin/node" "/Users/tz/git/nvs/node/8.1.4/x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/tz/Workspaces/tmp/node_modules/process-list
gyp ERR! node -v v8.1.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/Users/tz/Workspaces/tmp/package.json'
npm WARN tmp No description
npm WARN tmp No repository field.
npm WARN tmp No README data
npm WARN tmp No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tz/.npm/_logs/2017-08-02T01_50_28_790Z-debug.log

The specified module could not be found

cmd:
"cd .../node_modules/process-list"
"node example.js"
Error:
The specified module could not be found.
\?\D:....\node_modules\process-list\build\Release\processlist.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:731:18)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at bindings (D:...\node_modules\bindings\bindings.js:81:44)
at Object. (D:...\node_modules\process-list\index.js:3:31)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)

Exe throws error after adding process-list library

I am using the Process-List library to get the process in my node code.
It works fine when I call the js file directly.
But it throws the below error when I try to run when it is packaged with the pkg command.

Error:
pkg/prelude/bootstrap.js:1614
throw error;
^
Error: EISDIR: illegal operation on a directory, read
at error_EISDIR (pkg/prelude/bootstrap.js:553:17)
at readFileFromSnapshot (pkg/prelude/bootstrap.js:894:33)
at Object.readFileSync (pkg/prelude/bootstrap.js:938:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:786:20)
at Module.load (internal/modules/cjs/loader.js:651:32)
at tryModuleLoad (internal/modules/cjs/loader.js:591:12)
at Function.Module._load (internal/modules/cjs/loader.js:583:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at Module.require (pkg/prelude/bootstrap.js:1593:31)
at require (internal/modules/cjs/helpers.js:25:18)

Command used to package is :
pkg -t node10-win-x64 --compress GZip -o ".\ProcessList.exe" ".\app2.js"

pkg version is latest:
npm install pkg -g

Attaching sample code to reproduce the issue:
app2.txt
Package.txt

How can I fix it generally? Or any changes required from my side.

An in-range update of nan is breaking the build 🚨

The dependency nan was updated from 2.11.0 to 2.11.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

nan is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/appveyor/branch: Waiting for AppVeyor build to complete (Details).
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

OSX

Hello, anyone plan in milestone future for OSX?

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

no built in library for typescript

npm install @types/process-list
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fprocess-list - Not found
npm ERR! 404 
npm ERR! 404  '@types/process-list@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/leonardo/.npm/_logs/2020-08-18T13_51_07_663Z-debug.log

Doesn't build on windows 10

Build fails with

..\src\win\tasklist.cpp(17): fatal error C1083: Cannot open include file: 'atlbase.h': No such file or directory [C:\Users\I\Documents\habitinstaller\leaf\node_modules\process-list\build\processlist.vcxproj]
  win_delay_load_hook.cc

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Usage on Docker

When the package is used inside a Docker container, often it fails with the following error:
can't open stat
As far as I can see it is because it could not access /proc/<pid>/stat.
Have you encountered this issue with Docker and managed to resolve it? Or what would you suggest?

can't install in linux

npm ERR! code 1
npm ERR! path /root/processlisttest/node_modules/process-list
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild
npm ERR! make: Entering directory '/root/processlisttest/node_modules/process-list/build'
npm ERR! CXX(target) Release/obj.target/processlist/src/main.o
npm ERR! processlist.target.mk:119: recipe for target 'Release/obj.target/processlist/src/main.o' failed
npm ERR! make: Leaving directory '/root/processlisttest/node_modules/process-list/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.6.9 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v16.3.0/node-v16.3.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.3.0/node-v16.3.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v16.3.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.3.0/SHASUMS256.txt
npm ERR! (node:13578) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use node --trace-deprecation ... to show where the warning was created)
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/processlisttest/node_modules/process-list/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.cache/node-gyp/16.3.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/16.3.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/16.3.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/root/processlisttest/node_modules/process-list',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from /root/.cache/node-gyp/16.3.0/include/node/v8.h:30:0,
npm ERR! from /root/.cache/node-gyp/16.3.0/include/node/node.h:63,
npm ERR! from ../../nan/nan.h:58,
npm ERR! from ../src/main.cpp:7:
npm ERR! /root/.cache/node-gyp/16.3.0/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
npm ERR! /root/.cache/node-gyp/16.3.0/include/node/v8-internal.h:452:38: error: ‘remove_cv_t’ is not a member of ‘std’
npm ERR! !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
npm ERR! ^~~~~~~~~~~
npm ERR! /root/.cache/node-gyp/16.3.0/include/node/v8-internal.h:452:38: note: suggested alternative: ‘remove_cv’
npm ERR! !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
npm ERR! ^~~~~~~~~~~
npm ERR! remove_cv
npm ERR! /root/.cache/node-gyp/16.3.0/include/node/v8-internal.h:452:38: error: ‘remove_cv_t’ is not a member of ‘std’
npm ERR! /root/.cache/node-gyp/16.3.0/include/node/v8-internal.h:452:38: note: suggested alternative: ‘remove_cv’
npm ERR! !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
npm ERR! ^~~~~~~~~~~
npm ERR! remove_cv
npm ERR! /root/.cache/node-gyp/16.3.0/include/node/v8-internal.h:452:50: error: template argument 2 is invalid
npm ERR! !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
npm ERR! ^
npm ERR! /root/.cache/node-gyp/16.3.0/include/node/v8-internal.h:452:63: error: ‘::Perform’ has not been declared
npm ERR! !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
npm ERR! ^~~~~~~
npm ERR! /root/.cache/node-gyp/16.3.0/include/node/v8-internal.h:452:63: note: suggested alternative: ‘herror’
npm ERR! !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
npm ERR! ^~~~~~~
npm ERR! herror
npm ERR! make: *** [Release/obj.target/processlist/src/main.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 4.15.0-147-generic
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /root/processlisttest/node_modules/process-list
npm ERR! gyp ERR! node -v v16.3.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

thought first it was only on my raspberry pi but also my server vm doesn't like it. What can I do to fix?

Snapshot take more than 7000ms when "owner" field is setup

Hi,

After few tests on my Windows. When i setup the field "owner" it take more than 7,000ms for the snapshot method to be achieved. I have not tested the UNIX version yet to look if this a problem only related to the Windows platform.

Code example

const { snapshot } = require("process-list");

const fieldsToRetrieve = new Set([
    "name",
    "owner"
]);

async function main() {
    console.time("exec");
    const tasks = await snapshot(...fieldsToRetrieve);
    console.timeEnd("exec");
}
main().catch(console.error);

stdout

λ node index
exec: 7939.677ms

All others fields are well retrieved !

Best Regards,
Thomas

Process handle

Hi,

First, very nice job ! We use the package for a little Node.JS monitoring tool and it work quite well !

Your package answer the most common cases of our specification except the process count of handles. Do you think it is possible to implement this field without too much refactoring?

Thanks for your time.

Best Regards,
Thomas

An in-range update of standard is breaking the build 🚨

Version 12.0.0 of standard was just published.

Branch Build failing 🚨
Dependency standard
Current Version 11.0.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

standard is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).
  • continuous-integration/appveyor/branch: AppVeyor build failed (Details).

Commits

The new version differs by 91 commits.

  • ff1a156 authors
  • 17727fc 12.0.0
  • bdbd248 changelog
  • 3db3a62 https
  • cf1802c eslint-plugin-standard ~4.0.0
  • 7d779b8 eslint-plugin-import ~2.14.0
  • 66f676b eslint ~5.4.0
  • 3933c6b Use npm versions of eslint shared configs
  • c00dc66 Use ~ for eslint dep
  • 588d5ab Add links to French README translation!
  • aee57b4 ESLint 5
  • c89d5c7 Merge pull request #1145 from theo4u/patch-1
  • 6477dbf Merge pull request #1184 from standard/greenkeeper/babel-eslint-9.0.0
  • 8792b9b Merge pull request #1180 from standard/greenkeeper/eslint-plugin-promise-4.0.0
  • ff070b8 Merge branch 'master' into greenkeeper/eslint-plugin-promise-4.0.0

There are 91 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.