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

pm2-zabbix only discover process_id and process_name #15

Closed
penguin02007 opened this issue Jul 17, 2017 · 11 comments
Closed

pm2-zabbix only discover process_id and process_name #15

penguin02007 opened this issue Jul 17, 2017 · 11 comments
Assignees
Labels

Comments

@penguin02007
Copy link

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
Copy link
Member

rkaw92 commented Jul 17, 2017

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.

@rkaw92 rkaw92 self-assigned this Jul 17, 2017
@penguin02007
Copy link
Author

penguin02007 commented Jul 18, 2017

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
Copy link
Member

rkaw92 commented Jul 18, 2017

Okay, there are essentially two independent errors above:

  • ENOENT - our script can't find pm2.pid for some reason - wrong path? (What is your PM2_HOME? Where should pm2-zabbix be looking for the pidfile?)
  • zabbix_sender exit code 2 - this means some values were discarded by the server. Have you checked the troubleshooting guide in the README? Usually this means that the data items are not matching any keys on the server side (for example, the hostname is wrong).

@penguin02007
Copy link
Author

penguin02007 commented Jul 20, 2017

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
Copy link
Member

rkaw92 commented Jul 20, 2017

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 rkaw92 added bug and removed need info labels Jul 20, 2017
@rkaw92
Copy link
Member

rkaw92 commented Jul 20, 2017

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
Copy link
Author

penguin02007 commented Jul 24, 2017

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
Copy link
Member

rkaw92 commented Jul 24, 2017

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
Copy link
Author

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
Copy link
Member

rkaw92 commented Jul 24, 2017 via email

@rkaw92
Copy link
Member

rkaw92 commented Jun 15, 2018

Seems like all went OK here; closing.

@rkaw92 rkaw92 closed this as completed Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants