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:
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.
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.
Zabbix has a rich set of features to enable users to monitor database performance, availability, configuration changes.
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.
I can offer 2 suggestions to get the metrics into Zabbix:
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.
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
Actually there is a python binding for zabbix_sender. http://pypi.python.org/pypi/zbxsend
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With