Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expose data to zabbix

Tags:

python

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.

like image 526
bitcycle Avatar asked Jun 14 '11 18:06

bitcycle


People also ask

How does Zabbix collect data?

With Zabbix distributed monitoring, remotely run scripts collect data from multiple devices in distributed locations and combine that data in one dashboard or report, such as server availability across the country.

Can Zabbix monitor database?

Zabbix has a rich set of features to enable users to monitor database performance, availability, configuration changes.

Does Zabbix have an API?

On top of all the goodies one may find in Zabbix, it also comes with an API that provides access to almost all functions available in Zabbix. Existence of a Zabbix API opens up a lot of opportunities for even greater efficiency in monitoring.


2 Answers

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

like image 191
Andy Shinn Avatar answered Sep 24 '22 03:09

Andy Shinn


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

like image 36
Fatalerr Avatar answered Sep 22 '22 03:09

Fatalerr