sematext / spm-agent-nodejs

NodeJS Monitoring Agent
https://sematext.com/integrations/nodejs-monitoring
Apache License 2.0
60 stars 6 forks source link

Monitoring inside docker container will crash app #6

Closed janantala closed 8 years ago

janantala commented 8 years ago

I get following error when I run app inside docker container using node:0.12.7 image. However node:6 works fine.

/root/app/node_modules/spm-agent-nodejs/lib/linuxMetrics.js:126
Object.keys(data[cpuName]).forEach(function (cpuProperty) {
^
TypeError: Object.keys called on non-object
at Function.keys (native)
at /root/app/node_modules/spm-agent-nodejs/lib/linuxMetrics.js:126:14
at Array.forEach (native)
at /root/app/node_modules/spm-agent-nodejs/lib/linuxMetrics.js:125:23
at /root/app/node_modules/spm-agent-nodejs/node_modules/procfs-stats/index.js:153:5
at fs.js:334:14
at /root/app/node_modules/mocha/node_modules/glob/node_modules/graceful-fs/graceful-fs.js:104:5
at FSReqWrap.oncomplete (fs.js:95:15)
otisg commented 8 years ago

Isn't 0.12.7 ancient in Node terms?

megastef commented 8 years ago

I could reproduce the error message with the offical node:0.12 image. But it did not crash my app. Anyhow the bug is fixed in https://github.com/sematext/spm-agent-nodejs/commit/d0a3eb62d79f9d977659fce5d2401e58bf3e3b3f and npm release 1.29.12. @janantala please let me know how it works and wich base image you use. In case of Alpine Linux you might need to add RUN apk add --update procps to your docker file.

janantala commented 8 years ago

Ok thanks. I have tested one legacy app running 0.12.7 as it should be supported according to readme with official node docker image. However I don't need it, I use node 6 primary.

megastef commented 8 years ago

The reason was not fully clear, it looks after startup reading from /proc failed (fs or graceful-fs errors), so the new version ignores missing CPU info. In my test CPU usage was readable after a few function calls.