collectd-pm2 using collectd to gather statistics of Node.js applications managed by PM2.
cp collectd-pm2.js /usr/local/bin
Assume you start pm2 daemon with user "pm2" group "pm2", edit your collectd.conf file:
LoadPlugin exec
<Plugin exec>
Exec "pm2:pm2" "node" "/usr/local/bin/collectd-pm2.js"
</Plugin>
Because collectd exec plugin disallow executed with "root" user, see man 5 collectd-exec
CAVEATS
· The user, the binary is executed as, may not have root privileges, i. e. must have an UID that is non-zero. This is for your own good.
There is a optional program to bypass it.
make
make install
LoadPlugin exec
<Plugin exec>
Exec "nobody:nobody" "/usr/local/bin/collectd-pm2-root"
</Plugin>