bitcycle bitcycle - 1 year ago 222
Python Question

How to expose data to zabbix

Here is my goal: I would like to be able to report various metrics to zabbix so that we can display the graphs on a web page.

These metrics include:

  • latency per soap service submission

  • various query results from one or more databases.

What things do I need to write and/or expose? Or is the zabbix server going to go and get it from an exposed service somewhere?

I've been advised that a script that returns a single value will work, but I'm wondering if that's the right way.

Answer Source

I can offer 2 suggestions to get the metrics into Zabbix:

  1. Use the zabbix_sender binary to feed the data from your script directly to the Zabbix server. This allows your script to call on it's own interval and set all the parameters needed. You really only need to know the location to the zabbix_sender binary.

    Inside the Zabbix server interface, you would create items with the type of Zabbix trapper. This is the item type which receives values send from the zabbix_sender. You make up the key name and it has to match.

  2. The second way you could do this is to specify a key name and script/binary inside the zabbix_agentd.conf file. Every time the Zabbix server requests this item the script would be called and the data from the script recorded.

    This allows you to set the intervals in the Zabbix item configuration rather than forcing you to run your script on its own intervals. However, you would need to add this extra bit of information to your zabbix_agentd.conf file for every host.

There may be other ways to do this directly from Python (zabbix_sender bindings for Python maybe?). But these are the 2 ways I have used before which work well. This isn't really Python specific. But you should be able to use zabbix_sender in your Python scripting. Hope this information helps!

Update: I also remembered that Zabbix was working on/has a API (JSON/RPC style). But the documentation site is down at the moment and I am not sure if the API is for submitting item data or not. Here is the Wiki on the API:

And a project for Python API:

There seems to be little documentation on the API as it is new as of Zabbix version 1.8

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download