# ZabbixSender

Zabbix Sender Protocol client. Compatible with [Zabbix 4.0](

This library implements a simple TCP client as well as helper functions for encoding and decoding protocol messages.

## Installation

The package can be installed by adding `zabbix_sender` to your list of dependencies in `mix.exs`:

def deps do
    {:zabbix_sender, "~> 1.0.0"}

## Usage

Use functions from `ZabbixSender.Protocol` for building requests and decoding responses.
Use `ZabbixSender.Serializer` for writting and reading binary messages.
`ZabbixSender.send\3` will open connection, send request receive a response and then close the connection as the server won't allow it remain open.

### Example

value = ZabbixSender.Protocol.value("localhost", "some_key", 12.3, :os.system_time(:second))
request = ZabbixSender.Protocol.encode_request([value], :os.system_time(:second))
|> ZabbixSender.Serializer.serialize()

with {:ok, response} <- ZabbixSender.send(request, "localhost", 10051),
  {:ok, deserialized} <- ZabbixSender.Serializer.deserialize(response),
  {:ok, decoded} <- ZabbixSender.Protocol.decode_response(deserialized)
  if decoded.failed == 0 do"#{decoded.processed} values processed")
    Logger.warn("#{decoded.processed} values processed out of #{}")

## Documentation

Docs can be found at [](

## License

CashAddr source code is released under MIT License.
Check LICENSE file for more information.