Closed dinkonin closed 8 years ago
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?
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"
}
]
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?
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.
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.
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.
Glad to help! I should probably add a note on this kind of issue to the UserParameters example file.
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.
I'm having a problem sending pm2 process information to zabbix 3.0.1
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)