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

Error sending process list #1

Closed
dinkonin opened this issue Apr 13, 2016 · 8 comments
Closed

Error sending process list #1

dinkonin opened this issue Apr 13, 2016 · 8 comments

Comments

@dinkonin
Copy link

I'm having a problem sending pm2 process information to zabbix 3.0.1

pm2-zabbix --monitor --debug
* Client running (monitor mode: on)
[ OK ] Periodic sending of PM2 status succeeded
[ ERR ] Periodic sending of process list error: { [Error: Command failed: ] killed: false, code: 2, signal: null }

PM2 Status is OK in zabbix but PM2 Processes discovery rule does not trigger stating "Value should be a JSON object"

Running on CentOS 7.2.1511 (Core)

@rkaw92
Copy link
Member

rkaw92 commented Apr 13, 2016

Do you mean you are getting that in agent logs? The process that you run in the CLI above is not the one responsible for discovery. Could you please paste what pm2-zabbix --discover is printing to the console?

@dinkonin
Copy link
Author

No its in the console , agent logs are not saying anything out of the ordinary here's thepm2-zabbix --discover result

{
        "data": [
                {
                        "{#PROCESS_ID}": "app1-7",
                        "{#PROCESS_NAME}": "app1"
                },
                {
                        "{#PROCESS_ID}": "app2-8",
                        "{#PROCESS_NAME}": "app2"
                },
                {
                        "{#PROCESS_ID}": "app4-9",
                        "{#PROCESS_NAME}": "app4"
                }
        ]

@rkaw92
Copy link
Member

rkaw92 commented Apr 13, 2016

Can you confirm there is no ending } character in the output? If you run the output through json_pp, can it parse the produced string?
pm2-zabbix --discover | json_pp
Or, if you have no json_pp installed:
pm2-zabbix --discover | python -m json.tool

If it works, then the JSON is okay (it looks good on your paste, except for the missing trailing curly bracket), and the problem is elsewhere.

Also, can you paste your UserParameters from the agent that you are using for discovery?

@dinkonin
Copy link
Author

I'm sorry there is an ending } , I've just missed it while copying, pm2-zabbix --discover | python -m json.tool produces the same output as above with the ending } .
Here's the contents of /etc/zabbix/zabbix_agentd.d/pm2-zabbix.conf

# Put this file in /etc/zabbix/zabbix_agentd.d/ and remember to change the sudo -u <user> to use your user name
UserParameter=pm2.processes,sudo -u root pm2-zabbix --discover

Running sudo -u root pm2-zabbix --discover works.

@rkaw92
Copy link
Member

rkaw92 commented Apr 13, 2016

Running sudo -u root pm2-zabbix --discover works.

From the zabbix user? If the zabbix user has no permissions for sudo, then sudo would just print an error message, which looks nothing like JSON.

Clearly, the output produced is correct, so it must be something at a different layer.

@dinkonin
Copy link
Author

That fixed IT ! Running sudo -u root pm2-zabbix --discover was working fine from the console. But i raised the debug level of the zabbix to 4 agent it said

Sorry, you must have a tty to run sudo

Then commented Defaults requiretty in my sudoers file and now everything is working.
Thank you so much.

@rkaw92
Copy link
Member

rkaw92 commented Apr 13, 2016

Glad to help! I should probably add a note on this kind of issue to the UserParameters example file.

rkaw92 added a commit that referenced this issue Apr 13, 2016
…the example sudoers file, and a notice that should help debug problems similar to issue #1 to the sample agent config.
@rkaw92
Copy link
Member

rkaw92 commented Apr 13, 2016

Okay. I have modified the example sudoers file to include this:

Defaults:zabbix !requiretty

Users of RHEL and CentOS should no longer encounter problems such as yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants