Zabbix Ruby agent readme

This is a pure Ruby implementation of the Zabbix agent. The agent supports both the 1.1 and 1.4 (default) agent protocols. Presently the agent only supports passive connections. The agent is multi threaded and will spawn a new thread for each incoming connection. After a timeout period (default 30s) the thread will be killed and the associated socket closed. Effort has been made to make the agent itself thread safe, however the agent makes no effort to ensure the functions it calls are thread safe. Thus it is important that the end user be aware they are responsible for their functions being thread safe.

Required Gems: bit-struct

Use: Use of the agent is pretty straight forward.

agent = ZabbixAgent.new(nil,10060)

This will instantiate a new agent listening on all interfaces on port 10060. The key thing to note is that this will not start the agent’s main thread.

agent.register(“myfunc”,self.method(:myfunc))

This will register a new key/item with the agent. Behind the scenes all keys are stored in a Hash which in turn is used to look up which function to call, the resul from this function called is then passed back to the Zabbix server. The return value must be in string format. The function will be passed whatever arguments were received from the Zabbix server, for instance if the agent received the following from the server: myfunc A string of ‘1,2,3,“str”’ would be passed to the function.

Starting the agent is as simple as: agent.start

This method will return as it will spawn two threads, the main loop and the watchdog.

After the agent has started it is possible to register more items dynamically. The item zbx_available will return the current list of items the agent supports.