14

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
bitcycle
  • 7,632
  • 16
  • 70
  • 121

2 Answers2

15

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: http://www.zabbix.com/wiki/doc/api

And a project for Python API: https://github.com/gescheit/scripts/tree/master/zabbix/

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

Andy Shinn
  • 26,561
  • 8
  • 75
  • 93
  • There are no zabbix_sender bindings for Python. I've a bunch of Python scripts sending data to zabbix_sender, when you're dealing with a large quantity of metrics it's way more efficient to populate a zabbix_sender compliant file in a loop: print >>metrics_file_descriptor, '%s %s %s %s' % (hostname, item_key1, zbx_timestamp, metric1) and calling it so it sends to your Zabbix Server command = "%s -z %s -p %s --with-timestamps --input-file %s > /dev/null 2> /dev/null" % (zbx_sender, zbx_server_ip, zbx_port, metrics_file) args = shlex.split(command) – Joao Figueiredo Jun 15 '11 at 11:14
  • Also, the zabbix API python wrapper is quite useful for mass Items & Triggers creation and update, considering most of the more frequent functions are working, some of them however, still need extra coding to work. – Joao Figueiredo Jun 15 '11 at 11:17
  • There is also https://github.com/lukecyca/pyzabbix , which looks a bit better, than https://github.com/gescheit/scripts/tree/master/zabbix/ – Blin May 04 '12 at 12:35
3

Actually there is a python binding for zabbix_sender. http://pypi.python.org/pypi/zbxsend

Fatalerr
  • 291
  • 2
  • 6