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 开发者_如何学Goone 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.
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 thezabbix_sender
binary.
Inside the Zabbix server interface, you would create items with the type ofZabbix trapper
. This is the item type which receives values send from thezabbix_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 yourzabbix_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
精彩评论