Skip to content

improved sendToZabbix.sh#121

Merged
JsBergbau merged 2 commits intoJsBergbau:masterfrom
mjaepel:sendToZabbix
Mar 27, 2022
Merged

improved sendToZabbix.sh#121
JsBergbau merged 2 commits intoJsBergbau:masterfrom
mjaepel:sendToZabbix

Conversation

@mjaepel
Copy link
Contributor

@mjaepel mjaepel commented Mar 27, 2022

The old script uses only one text item for all metrics in Zabbix. So it was impossible to generate graphs or statistics with it.
Now each value has it's own Zabbix item. :)

@JsBergbau
Copy link
Owner

Hi Firewire2002,
thanks for improving the Zabbix Callback. Can you please add a short mention for the new Zabbix Callback Readme in the main Readme, like there https://github.com/JsBergbau/MiTemperature2#send-metrics-to-prometheus
Then I'll be happy to merge your pull request.

@mjaepel
Copy link
Contributor Author

mjaepel commented Mar 27, 2022

Done and fixed the typo in Prometheus link description.

@JsBergbau
Copy link
Owner

Thanks for your work.

@JsBergbau JsBergbau merged commit c3c1413 into JsBergbau:master Mar 27, 2022
@szuro
Copy link
Contributor

szuro commented Jun 28, 2022

I'm a bit late to the part, but here I go:

The old script uses only one text item for all metrics in Zabbix. So it was impossible to generate graphs or statistics with it. Now each value has it's own Zabbix item. :)

That was on purpose. The idea was to send all metrics in a single connection, and then extract data using preprocessing and dependant items.
Take a look at this crude template: https://gitlab.com/szuro/zabbix_templates/-/blob/master/Mi%20sensor%20%20LYWSD03MMC.yaml

It does exactly what I described above.
Thanks to this you can send data in one go and is the preferred in new Zabbix versions.

@mjaepel
Copy link
Contributor Author

mjaepel commented Jun 28, 2022

Yes that's also a nice way. But a single string isn't the best solution for such case. JSON would be the better way to transfer data in one shot. Much easier for parsing than a string.

Btw, my script uses also only one connection. zabbix_sender is able to send multiple items. I didn't benchmark it, but I think the difference between both variants isn't very large. If you send a master item, the Zabbix Server has to parse and split it up into dependent items. Regex is very expensive.
With separated items on single connection the server have to store only the values. A step that is also processed after the splitting of your master item.

@szuro
Copy link
Contributor

szuro commented Jun 29, 2022

Most certainly, JSON would be preferred, I just have an aversion to using it in bash scripts 😅

With one trapper item you only need to have one 'nodata' based trigger, which is always nice - preprocessing can be distributed across proxies, trigger evaluation cannot.

I like how you handled the sender configuration ans PSK. Nicely done.

Btw, my script uses also only one connection.

True that. I should never read code on a smartphone...

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

Successfully merging this pull request may close these issues.

3 participants