greatcare / pm2-zabbix

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

Spaces in keys break zabbix-sender #27

Open joppino opened 6 years ago

joppino commented 6 years ago

Here is an example. I'm simulating the parsing of the input from pm2-zabbix --monitor, which produces a key-value stream which is parsed by zabbix-sender and sent. I'm fetching just one row from this stream, and sending to zabbix:

echo "xxxxx-be-preprod01 pm2.processes[xxxxx Frontend-0,cpu] 90" | zabbix_sender -vv --config /etc/zabbix/zabbix_agentd.conf -s hostname --input-file - zabbix_sender [25699]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 1; total: 1; seconds spent: 0.000028"}] info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000028"

So, if there are spaces in pm2 process, the server fails to process the monitor part. The "discover" part is working, though, because if we enclose the key with double quotes, it goes through:

echo "xxxxxx-be-preprod01 \"pm2.processes[xxxxx Frontend-0,cpu]\" 90" | zabbix_sender -vv --config /etc/zabbix/zabbix_agentd.conf -s hostname --input-file - zabbix_sender [25131]: DEBUG: answer [{"response":"success","info":"processed: 1; failed: 0; total: 1; seconds spent: 0.000083"}] info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000083"

rkaw92 commented 5 years ago

This is going to be addressed in PR #31.