Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running on windows, p2-server-monit is calling linux commands #78

Open
ebors opened this issue Oct 28, 2018 · 12 comments
Open

Running on windows, p2-server-monit is calling linux commands #78

ebors opened this issue Oct 28, 2018 · 12 comments

Comments

@ebors
Copy link

ebors commented Oct 28, 2018

Running pm2 on windows causes many errors. The pm2 process want to call unix commands like top, who, grep etc. :

0|pm2-server-monit | Failed to retrieve TTY metrics { Error: Command failed: who | grep -v localhost | wc -l
0|pm2-server-monit | 'who' is not recognized as an internal or external command,
0|pm2-server-monit | operable program or batch file.
0|pm2-server-monit | at ChildProcess.exithandler (child_process.js:275:12)
0|pm2-server-monit | at emitTwo (events.js:126:13)
0|pm2-server-monit | at ChildProcess.emit (events.js:214:7)
0|pm2-server-monit | at maybeClose (internal/child_process.js:925:16)
0|pm2-server-monit | at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
0|pm2-server-monit | killed: false,
0|pm2-server-monit | code: 255,
0|pm2-server-monit | signal: null,
0|pm2-server-monit | cmd: 'who | grep -v localhost | wc -l' }
0|pm2-server-monit | Failed to retrieve process count { Error: Command failed: top -bn1 | awk 'NR > 7 && $8 ~ /R|S|D|T/ { print $12 }'
0|pm2-server-monit | 'top' is not recognized as an internal or external command,
0|pm2-server-monit | operable program or batch file.
0|pm2-server-monit | at ChildProcess.exithandler (child_process.js:275:12)
0|pm2-server-monit | at emitTwo (events.js:126:13)
0|pm2-server-monit | at ChildProcess.emit (events.js:214:7)
0|pm2-server-monit | at maybeClose (internal/child_process.js:925:16)
0|pm2-server-monit | at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
0|pm2-server-monit | killed: false,
0|pm2-server-monit | code: 255,
0|pm2-server-monit | signal: null,
0|pm2-server-monit | cmd: 'top -bn1 | awk 'NR > 7 && $8 ~ /R|S|D|T/ { print $12 }'' }
0|pm2-server-monit | Failed to retrieve zombie process count { Error: Command failed: top -bn1 | awk 'NR > 7 && $8 ~ /Z/ { print $12
}'
0|pm2-server-monit | 'top' is not recognized as an internal or external command,
0|pm2-server-monit | operable program or batch file.
0|pm2-server-monit | at ChildProcess.exithandler (child_process.js:275:12)
0|pm2-server-monit | at emitTwo (events.js:126:13)
0|pm2-server-monit | at ChildProcess.emit (events.js:214:7)
0|pm2-server-monit | at maybeClose (internal/child_process.js:925:16)
0|pm2-server-monit | at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
0|pm2-server-monit | killed: false,
0|pm2-server-monit | code: 255,
0|pm2-server-monit | signal: null,
0|pm2-server-monit | cmd: 'top -bn1 | awk 'NR > 7 && $8 ~ /Z/ { print $12 }'' }
0|pm2-server-monit | Failed to retrieve number of file descriptor { Error: EISDIR: illegal operation on a directory, read errno: -4068, code: 'EISDIR', syscall: 'read' }
0|pm2-server-monit | Could not retrieve disk metrics { Error: Command failed: df -kP
0|pm2-server-monit | 'df' is not recognized as an internal or external command,
0|pm2-server-monit | operable program or batch file.
0|pm2-server-monit | at ChildProcess.exithandler (child_process.js:275:12)
0|pm2-server-monit | at emitTwo (events.js:126:13)
0|pm2-server-monit | at ChildProcess.emit (events.js:214:7)
0|pm2-server-monit | at maybeClose (internal/child_process.js:925:16)
0|pm2-server-monit | at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) killed: false, code: 1, signal: null, cmd: 'df -kP' }

@carlosen14
Copy link

same here, every one minute i see on pm2 monit the message

pm2-server-monit > Failed to retrieve process count null
other logs..
other logs..
pm2-server-monit > Failed to retrieve process count null

@hannadrehman
Copy link

@carlosen14 I am facing the exact issue. any solution for it

@carlosen14
Copy link

carlosen14 commented Feb 28, 2019

nope, just let it go... :(

@jordy-leung
Copy link

Hi, I'm having similar issue still...is it still outstanding issue and not fixed yet? Here is my log:

pm2-server-monit > Failed to retrieve TTY metrics { Error: Command failed: who | grep -v localhost | wc -l

@Doc999tor
Copy link

Any updates with it?

@malkico
Copy link

malkico commented Sep 19, 2020

Similar issue on September 2020 !

@acba
Copy link

acba commented Oct 9, 2020

image

Problem happens here, my problem was that my Docker container was using a Debian without the top process. I just installed the 'procps' package using apt and things are fine now.

@MSIPhil
Copy link

MSIPhil commented Sep 12, 2021

Any updates on this? It is quite annoying.

@Konders
Copy link

Konders commented Jan 31, 2023

Issue exists 5 years and reproducible on your official docker image(18-alpine)

@r01010010
Copy link

r01010010 commented Oct 31, 2023

Same here in Q4 2023

0|pm2-server-monit  | Failed to retrieve number of file descriptor [Error: ENOENT: no such file or directory, open 'C:\proc\sys\fs\file-nr'] {
0|pm2-server-monit  |   errno: -4058,
0|pm2-server-monit  |   code: 'ENOENT',
0|pm2-server-monit  |   syscall: 'open',
0|pm2-server-monit  |   path: 'C:\\proc\\sys\\fs\\file-nr'
0|pm2-server-monit  | }
0|pm2-server-monit  | Failed to retrieve zombie process count Error: Command failed: top -bn1 | awk 'NR > 7 && $8 ~ /Z/ { print $12 }'
0|pm2-server-monit  | 'top' is not recognized as an internal or external command,
0|pm2-server-monit  | operable program or batch file.
0|pm2-server-monit  |     at ChildProcess.exithandler (node:child_process:422:12)
0|pm2-server-monit  |     at ChildProcess.emit (node:events:514:28)
0|pm2-server-monit  |     at maybeClose (node:internal/child_process:1105:16)
0|pm2-server-monit  |     at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
0|pm2-server-monit  |   code: 255,
0|pm2-server-monit  |   killed: false,
0|pm2-server-monit  |   signal: null,
0|pm2-server-monit  |   cmd: "top -bn1 | awk 'NR > 7 && $8 ~ /Z/ { print $12 }'"
0|pm2-server-monit  | }
0|pm2-server-monit  | Failed to retrieve process count Error: Command failed: top -bn1 | awk 'NR > 7 && $8 ~ /R|S|D|T/ { print $12 }'
0|pm2-server-monit  | 'top' is not recognized as an internal or external command,
0|pm2-server-monit  | operable program or batch file.
0|pm2-server-monit  |     at ChildProcess.exithandler (node:child_process:422:12)
0|pm2-server-monit  |     at ChildProcess.emit (node:events:514:28)
0|pm2-server-monit  |     at maybeClose (node:internal/child_process:1105:16)
0|pm2-server-monit  |     at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
0|pm2-server-monit  |   code: 255,
0|pm2-server-monit  |   killed: false,
0|pm2-server-monit  |   signal: null,
0|pm2-server-monit  |   cmd: "top -bn1 | awk 'NR > 7 && $8 ~ /R|S|D|T/ { print $12 }'"
0|pm2-server-monit  | }
0|pm2-server-monit  | Failed to retrieve number of file descriptor [Error: ENOENT: no such file or directory, open 'C:\proc\sys\fs\file-nr'] {
0|pm2-server-monit  |   errno: -4058,
0|pm2-server-monit  |   code: 'ENOENT',
0|pm2-server-monit  |   syscall: 'open',
0|pm2-server-monit  |   path: 'C:\\proc\\sys\\fs\\file-nr'
0|pm2-server-monit  | }
0|pm2-server-monit  | Failed to retrieve process count Error: Command failed: top -bn1 | awk 'NR > 7 && $8 ~ /R|S|D|T/ { print $12 }'
0|pm2-server-monit  | 'top' is not recognized as an internal or external command,
0|pm2-server-monit  | operable program or batch file.
0|pm2-server-monit  |     at ChildProcess.exithandler (node:child_process:422:12)
0|pm2-server-monit  |     at ChildProcess.emit (node:events:514:28)
0|pm2-server-monit  |     at maybeClose (node:internal/child_process:1105:16)
0|pm2-server-monit  |     at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
0|pm2-server-monit  |   code: 255,
0|pm2-server-monit  |   killed: false,
0|pm2-server-monit  |   signal: null,
0|pm2-server-monit  |   cmd: "top -bn1 | awk 'NR > 7 && $8 ~ /R|S|D|T/ { print $12 }'"
0|pm2-server-monit  | }
0|pm2-server-monit  | Failed to retrieve zombie process count Error: Command failed: top -bn1 | awk 'NR > 7 && $8 ~ /Z/ { print $12 }'
0|pm2-server-monit  | 'top' is not recognized as an internal or external command,
0|pm2-server-monit  | operable program or batch file.
0|pm2-server-monit  |     at ChildProcess.exithandler (node:child_process:422:12)
0|pm2-server-monit  |     at ChildProcess.emit (node:events:514:28)
0|pm2-server-monit  |     at maybeClose (node:internal/child_process:1105:16)
0|pm2-server-monit  |     at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
0|pm2-server-monit  |   code: 255,
0|pm2-server-monit  |   killed: false,
0|pm2-server-monit  |   signal: null,
0|pm2-server-monit  |   cmd: "top -bn1 | awk 'NR > 7 && $8 ~ /Z/ { print $12 }'"
0|pm2-server-monit  | }
0|pm2-server-monit  | Failed to retrieve number of file descriptor [Error: ENOENT: no such file or directory, open 'C:\proc\sys\fs\file-nr'] {
0|pm2-server-monit  |   errno: -4058,
0|pm2-server-monit  |   code: 'ENOENT',
0|pm2-server-monit  |   syscall: 'open',
0|pm2-server-monit  |   path: 'C:\\proc\\sys\\fs\\file-nr'
0|pm2-server-monit  | }
0|pm2-server-monit  | Failed to retrieve process count Error: Command failed: top -bn1 | awk 'NR > 7 && $8 ~ /R|S|D|T/ { print $12 }'
0|pm2-server-monit  | 'top' is not recognized as an internal or external command,
0|pm2-server-monit  | operable program or batch file.
0|pm2-server-monit  |     at ChildProcess.exithandler (node:child_process:422:12)
0|pm2-server-monit  |     at ChildProcess.emit (node:events:514:28)
0|pm2-server-monit  |     at maybeClose (node:internal/child_process:1105:16)
0|pm2-server-monit  |     at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
0|pm2-server-monit  |   code: 255,
0|pm2-server-monit  |   killed: false,
0|pm2-server-monit  |   signal: null,
0|pm2-server-monit  |   cmd: "top -bn1 | awk 'NR > 7 && $8 ~ /R|S|D|T/ { print $12 }'"
0|pm2-server-monit  | }
0|pm2-server-monit  | Failed to retrieve zombie process count Error: Command failed: top -bn1 | awk 'NR > 7 && $8 ~ /Z/ { print $12 }'
0|pm2-server-monit  | 'top' is not recognized as an internal or external command,
0|pm2-server-monit  | operable program or batch file.
0|pm2-server-monit  |     at ChildProcess.exithandler (node:child_process:422:12)
0|pm2-server-monit  |     at ChildProcess.emit (node:events:514:28)
0|pm2-server-monit  |     at maybeClose (node:internal/child_process:1105:16)
0|pm2-server-monit  |     at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
0|pm2-server-monit  |   code: 255,
0|pm2-server-monit  |   killed: false,
0|pm2-server-monit  |   signal: null,
0|pm2-server-monit  |   cmd: "top -bn1 | awk 'NR > 7 && $8 ~ /Z/ { print $12 }'"
0|pm2-server-monit  | }

@Chuppa2
Copy link

Chuppa2 commented Jul 22, 2024

Issue still exists, I console log alot of stuff and this error is clogging up my logs which is real annoying.
Might just uninstall server-monit since I can just RDP into my server in like 5 seconds and check task manager.
Thanks PM2 for ignoring an issue since 2018!

@WindsurfAR
Copy link

So, in case someone wants to get rid of those errors:
Go to C:\Users\YOURUSER\.pm2\modules\pm2-server-monit\node_modules\pm2-server-monit\src\metrics and check every file in there for fetch() functions (those do the unix commands through an exec). Then just delete their contents or comment them.
For example in tty.js change:

fetch () {
    exec('who | grep -v localhost | wc -l', (err, stdout, stderr) => {
      if (err || stdout.length === 0) return console.error(`Failed to retrieve TTY metrics`, err)
      this.ttyCount.set(parseInt(stdout))
    })
  }

to:

fetch () {
}

Far from a clean solution, but the errors will be gone and I don't miss any feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests