greatcare / pm2-zabbix

A Node.js PM2 monitoring tool for Zabbix.
MIT License
87 stars 60 forks source link

pm2-zabbix only discover process_id and process_name #15

Closed penguin02007 closed 6 years ago

penguin02007 commented 7 years ago

Version: 0.2.1

When running in discover mode, only process_id and process_name are showed up. (with a status code of 0)

/home/foo └─┬ pm2-zabbix@0.2.1 ├── minimist@1.2.0 ├── pidusage@1.1.5

I have ran --monitor --debug but it has the same result, I think the data is not picking up the data between the module and node.js and unrelated to zabbix_sender.

Any suggestion?

$ sudo PM2_HOME=/etc/data/hypernova/pm2 pm2-zabbix --discover
{
        "data": [
                {
                        "{#PROCESS_ID}": "hypernova_service-0",
                        "{#PROCESS_NAME}": "hypernova_service"
                },
                {
                        "{#PROCESS_ID}": "hypernova_service-1",
                        "{#PROCESS_NAME}": "hypernova_service"
                },
                {
                        "{#PROCESS_ID}": "hypernova_service-2",
                        "{#PROCESS_NAME}": "hypernova_service"
                }
        ]
$ sudo PM2_HOME=/etc/data/hypernova/pm2 pm2 status
┌───────────────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────┬────────────┬──────────┐
│ App name          │ id │ mode    │ pid   │ status │ restart │ uptime │ cpu │ mem        │ watching │
├───────────────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────┼────────────┼──────────┤
│ hypernova_service │ 0  │ cluster │ 17209 │ online │ 39      │ 4h     │ 0%  │ 296.7 MB   │ disabled │
│ hypernova_service │ 1  │ cluster │ 16607 │ online │ 39      │ 2h     │ 0%  │ 194.2 MB   │ disabled │
│ hypernova_service │ 2  │ cluster │ 18864 │ online │ 39      │ 3h     │ 0%  │ 264.4 MB   │ disabled │
└───────────────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────┴────────────┴──────────┘
rkaw92 commented 7 years ago

Hi. The discover mode output should look like the one you posted - process discovery is only for finding out what processes you have defined/available in pm2, not what their momentary state is.

Regarding monitor mode - are you seeing any errors? Are you getting something resembling the following?

[ OK ] Periodic sending of process list succeeded
[ OK ] Periodic sending of PM2 status succeeded

I'll add some debugging options in a moment and make a branch that should shed some light on the issue. Going to implement much-needed logging, finally.

penguin02007 commented 7 years ago

Correct. Sincediscover didn't see it, I assume it won't matter if I test it with monitor. There are errors but I think it is related to sending the items to zabbix server and unrelated to the problem I am having.

* Client running (monitor mode: on)
[ ERR ] Periodic sending of PM2 status failed: { Error: ENOENT: no such file or directory, open '/home/foo/etc/data/hypernova/pm2/pm2.pid'
    at Error (native)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/etc/data/hypernova/pm2/pm2.pid' }
[ ERR ] Periodic sending of process list error: { Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -

    at ChildProcess.exithandler (child_process.js:206:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
  killed: false,
  code: 2,
  signal: null,
  cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -' }
rkaw92 commented 7 years ago

Okay, there are essentially two independent errors above:

penguin02007 commented 7 years ago

Sorry I was away yesterday. PM2_HOME is under a different directory. pm2.pid lives under /etc/data/hypernova/pm2/pm2.pid' instead of my home directory, is there anyway to change it?

We have a different zabbix directory for zabbix_agentd.conf,I think that's complaining on the zabbix side and should not have affected on the pm2.

sudo PM2_HOME=/etc/data/hypernova/pm2 pm2-zabbix --monitor --debug

[ ERR ] Periodic sending of PM2 status failed: { Error: ENOENT: no such file or directory, open '/home/foo/etc/data/hypernova/pm2/pm2.pid'

rkaw92 commented 7 years ago

There is currently an issue open (#16) that deals with home directory / PM2_HOME handling - right now it appears to be problematic. Just to confirm - you changed where pm2 stores its pidfile / logs by launching it with a changed PM2_HOME, too? I may need to gather some information about how pm2 paths are configured and how it handles relative-looking paths such as PM2_HOME=.pm2.

rkaw92 commented 7 years ago

The version on master now uses logic compatible with pm2 for determining the pidfile path. You can check if that rectifies the pidfile ENOENT issue.

penguin02007 commented 7 years ago

The ENOENT /pid issue has been rectified. Please let me know if you need more information.

Correct, I always change the PM2_HOME directory.

Is it possible to print the command line and data to standard out for troubleshooting purpose?


[ ERR ] Periodic sending of process list error: { Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -

    at ChildProcess.exithandler (child_process.js:206:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Socket.<anonymous> (internal/child_process.js:334:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:498:12)
  killed: false,
  code: 2,
  signal: null,
  cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -' }
rkaw92 commented 7 years ago

Yes. Just launch pm2-zabbix with an elevated log level, like this (requires 0.3.x):

LOG_LEVEL=trace pm2-zabbix --monitor

(This is now included in the README)

penguin02007 commented 7 years ago

I am running 0.3 but I don't see anything writing on standard output. Am i missing something?

└─┬ pm2-zabbix@0.3.2
 sudo PM2_HOME=/etc/data/hypernova/pm2 LOG_LEVEL=trace pm2-zabbix --discover
{
        "data": [
                {
                        "{#PROCESS_ID}": "hypernova_service-0",
                        "{#PROCESS_NAME}": "hypernova_service"
                },
                {
                        "{#PROCESS_ID}": "hypernova_service-1",
                        "{#PROCESS_NAME}": "hypernova_service"
                },
                {
                        "{#PROCESS_ID}": "hypernova_service-2",
                        "{#PROCESS_NAME}": "hypernova_service"
                }
        ]
}
rkaw92 commented 7 years ago

In discover mode, to avoid merging logs and output, logs go to stderr.

Dnia 24 lipca 2017 20:56:43 CEST, Leo Chan notifications@github.com napisał(a):

I am running 0.3 but I don't see anything writing on standard output. Am i missing something?

└─┬ pm2-zabbix@0.3.2
sudo PM2_HOME=/etc/data/hypernova/pm2 LOG_LEVEL=trace pm2-zabbix
--discover
{
       "data": [
               {
                       "{#PROCESS_ID}": "hypernova_service-0",
                       "{#PROCESS_NAME}": "hypernova_service"
               },
               {
                       "{#PROCESS_ID}": "hypernova_service-1",
                       "{#PROCESS_NAME}": "hypernova_service"
               },
               {
                       "{#PROCESS_ID}": "hypernova_service-2",
                       "{#PROCESS_NAME}": "hypernova_service"
               }
       ]
}

-- You are receiving this because you were assigned. Reply to this email directly or view it on GitHub: https://github.com/greatcare/pm2-zabbix/issues/15#issuecomment-317520811

-- Wysłane za pomocą K-9 Mail.

rkaw92 commented 6 years ago

Seems like all went OK here; closing.