keymetrics / pm2-server-monit

Monitor server CPU / Memory / Process / Zombie Process / Disk size / Security Packages / Network Input / Network Output
https://keymetrics.io/
MIT License
264 stars 39 forks source link

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

Open ebors opened 6 years ago

ebors commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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

carlosen14 commented 5 years ago

nope, just let it go... :(

jordy-leung commented 5 years ago

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 commented 4 years ago

Any updates with it?

malkico commented 4 years ago

Similar issue on September 2020 !

acba commented 4 years ago

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 commented 3 years ago

Any updates on this? It is quite annoying.

Konders commented 1 year ago

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

r01010010 commented 1 year ago

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 commented 4 months ago

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 commented 1 month ago

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.