greatcare / pm2-zabbix

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

Help: [ ERR ] Periodic sending of PM2 status failed #12

Closed rmsys closed 7 years ago

rmsys commented 7 years ago

CONFIGS:

1. pm2-zabbix --discover

{ "data": [ { "{#PROCESS_ID}": "API@1.0", "{#PROCESS_NAME}": "API@1.0" } ]

2. /etc/zabbix/zabbix_agentd.conf

############ GENERAL PARAMETERS ################# PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=1 DebugLevel=4 EnableRemoteCommands=1 LogRemoteCommands=1 Server=zabbix.internal.com ServerActive=zabbix.internal.com StartAgents=5 Hostname=api-test

Include=/etc/zabbix/zabbix_agentd.d/

UserParameter

UserParameter=pm2.processes,root /usr/local/nodejs/bin/pm2-zabbix --discover

3. /etc/sudoers

Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)

includedir /etc/sudoers.d

zabbix ALL=(ALL) NOPASSWD: ALL Defaults:zabbix !requiretty

4. Server

Name                            Triggers    Key             Interval    History     Trends  Type            Applications    Status

Template App PM2: PM2 Daemon Status         Triggers 1  pm2.status                  90d                 Zabbix trapper  PM2 Daemon      Enabled 
Template App PM2: PM2 Daemon PID            Triggers 1  pm2.pid                     90d         365d    Zabbix trapper  PM2 Daemon      Enabled 
Template App PM2: PM2 Daemon Memory Usage               pm2.memory                  90d         365d    Zabbix trapper  PM2 Daemon      Enabled 
Template App PM2: PM2 Daemon CPU Usage                  pm2.cpu                     90d         365d    Zabbix trapper  PM2 Daemon      Enabled 

ERRORS:

[ ERR ] Periodic sending of PM2 status failed: { [Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file - ] killed: false, code: 2, signal: null, cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -' }

TROUBLESHOOTING:

from host with zabbix-agent:

- ls /usr/bin/zabbix_sender

/usr/bin/zabbix_sender

- Has the discovery process completed successfully? Are your processes listed in the Zabbix Web UI for the host that you're sending from?

Applications from Template APP PM2

Application     Items
PM2 Daemon      Items 0
PM2 Processes        Items 4

Itens from Application PM2 Processes:

PM2 Daemon Status           Triggers 1  pm2.status      90d     Zabbix trapper  PM2 Processes   Enabled
PM2 Daemon PID              Triggers 1  pm2.pid         90d     365d    Zabbix trapper  PM2 Processes   Enabled
PM2 Daemon Memory Usage                 pm2.memory      90d     365d    Zabbix trapper  PM2 Processes   Enabled
PM2 Daemon CPU Usage                    pm2.cpu         90d     365d    Zabbix trapper  PM2 Processes   Enabled

- Does the hostname configured on the server match the hostname that the client is presenting itself as? In particular, compare the output of hostname with the Zabbix Server's notion of your monitored machine's hostname (if using the default HostnameItem setting).

yep, the hostnames match

- If the above does not explain the failure: can you send any data item manually, using zabbix_sender from the CLI?

Test01 --> OK

zabbix_sender -z zabbix.internal.com -s "api-test" -k pm2.cpu -o 43

info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000245" sent: 1; skipped: 0; total: 1

Test02 --> FAIL

zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k "pm2.processes[www-0,cpu]" -s "api-test" -o 90 -vv

zabbix_sender [11909]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 1; total: 1; seconds spent: 0.000113"}] info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000113" sent: 1; skipped: 0; total: 1

from zabbix-server

./usr/local/bin/zabbix_get -s 172.xx.xx.xxx -k pm2.processes { "data": [ { "{#PROCESS_ID}": "API@1.0", "{#PROCESS_NAME}": "API@1.0" } ] }

What/Where's wrong ?

rkaw92 commented 7 years ago

What is the actual name (as shown by pm2 l) of your app - www-0 or API@1.0? I can't see a connection between those two strings. Definitely something weird going on here.

rmsys commented 7 years ago

Hi rkaw92,

first, thank you by the fast response and congrats by the "pm2-zabbix"

Second, sorry by big mistake, but the fix don't worked anyway :(

zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k "pm2.processes[API@1.0,cpu]" -s "api-test" -o 90 -vv
zabbix_sender [19295]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 1; total: 1; seconds spent: 0.000153"}]
info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000153"
sent: 1; skipped: 0; total: 1
rkaw92 commented 7 years ago

The client (sender) is clearly sending the data items, which the server promptly refuses to process. One oddity that pops up under closer inspection is this:

"{#PROCESS_ID}": "API@1.0",
"{#PROCESS_NAME}": "API@1.0"

Usually, pm2-zabbix will construct a synthetic PROCESS_ID like this: processName-number, where number is the sequential process ID in pm2 (starts from 0). The above does not look like an actual process ID generated by pm2-zabbix. Are you retyping the IDs? Using a modified version of this package?

Anyway, could you inspect in the Zabbix GUI whether the item really was created on the server, with this exact name and the correct type?

rmsys commented 7 years ago

Hi rkaw92,

sorry by delay.

I will redoing the installation/process and return.

tks!

gohackfelipe commented 7 years ago

Hi all,

Could you help me to find a solution for this ?

`[ 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:211: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

@gohackfelipe Please start a separate issue instead of attaching to an existing thread. Before actually posting, have you tried the Troubleshooting guide? Check if the steps there yield any answers, and if not, feel free to open a new issue report.

gohackfelipe commented 7 years ago

Sorry @rkaw92 . I will do. Thanks!

rkaw92 commented 7 years ago

Hi, I am doing a run of issue-pruning today and this one looks like it has not seen any activity for a while. Closing; please re-open if the issue persists.