greatcare / pm2-zabbix

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

[ ERR ] Periodic sending of PM2 status failed: { Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zab #14

Closed samanahavemail closed 7 years ago

samanahavemail commented 7 years ago

Dear greatcare

i got problem like someone in issue section found and i try to reading trubleshooting guide but cannot solve

the problem is i got code 2 from zabbix_sender but it work when i try to use manually cli i check in zabbix_agentd.conf Hostname and Hostnameitem and /etc/hosts file are same with config with Zabbixserver (ADVWSNodeAPI)

pls help me to solve this

==== CLI ==== [root@nodeapi bin]# zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k "pm2.processes[bot3bb-94,cpu]" -s 'ADVWSNodeAPI' -o 98 -vv zabbix_sender [84361]: DEBUG: answer [{"response":"success","info":"processed: 1; failed: 0; total: 1; seconds spent: 0.000045"}] info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000045"

screenshot 2017-06-05 16 06 29 screenshot 2017-06-05 16 10 33 screenshot 2017-06-05 16 11 58

rkaw92 commented 7 years ago

Hi, your issue has been acknowledged. For now, I would recommend tracing the command that gets called under the hood by modifying monitor.js:

var sender = new ZabbixSender({
    hostname: argv.hostname || hostname,
    server: argv.server || undefined,
    log: true
});

We should probably expose this as a feature in the nearest future. Sounds like a good candidate for a general logging overhaul, too.

samanahavemail commented 7 years ago

something error like attachment screenshot 2017-06-07 17 15 01

rkaw92 commented 7 years ago

You probably forgot the comma (,) after monitor.js:30 - this is the same error that I get if I paste "log: true" into the next line without adding a comma to the previous one.

samanahavemail commented 7 years ago

i already fill comma at with previous line and i got sth like this

the log file attack with dropbox

https://www.dropbox.com/s/diox0bf67ceucqh/pm2_zabbix.log?dl=0

rkaw92 commented 7 years ago

Okay. Looking at your log, one thing is noticeable. In your example, you posted this command which worked:

zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k "pm2.processes[bot3bb-94,cpu]" -s 'ADVWSNodeAPI' -o 98 -vv

However, this is the data sent by zabbix_sender when launched from our monitor.js (you can see this in the log that you've shared):

nodeapi.advws.local pm2.status online

Looks like it's using the hostname nodeapi.advws.local - it ignores the hostname set in zabbix_agentd.conf and instead takes os.hostname(). This is due to how we pass the "hostname" parameter to the zabbix-sender library (monitor.js:29). In your case, and I imagine many others, setting a custom hostname in the agent config is a useful feature.

Right now, if you want, you can pass a custom --hostname ADVWSNodeAPI parameter to monitor.js - this should solve the issue at hand. We are going to improve this by no longer defaulting the --hostname to os.hostname(), but rather allowing zabbix_agentd.conf to be used for hostname.

samanahavemail commented 7 years ago

thank you for your help

this case was solve for add param --hostname XXXXX in init.d script