0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Zabbix protocols builder/parser.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 3.0.0

Runtime

 Project Readme

ZabbixProtocol

Zabbix protocols builder/parser.

see http://www.zabbix.org/wiki/Docs/protocols

Gem Version Build Status

Installation

Add this line to your application's Gemfile:

gem 'zabbix_protocol'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zabbix_protocol

Usage

Zabbix 1.4 Passive checks

http://www.zabbix.org/wiki/Docs/protocols/zabbix_agent/1.4

require 'socket'
require 'zabbix_protocol'

AGENT_PORT = 10050

TCPSocket.open("127.0.0.1", AGENT_PORT) do |sock|
  data = "system.cpu.load[all,avg1]"

  sock.print ZabbixProtocol.dump(data)
  p ZabbixProtocol.load(sock.read) #=> 0.04
end

Zabbix 1.6 Active agents

http://www.zabbix.org/wiki/Docs/protocols/zabbix_agent/1.6

require 'socket'
require 'zabbix_protocol'

SERVER_PORT = 10051

TCPSocket.open("127.0.0.1", SERVER_PORT) do |sock|
  data = {"request" => "active checks", "host" => "my server"}

  sock.print ZabbixProtocol.dump(data)
  p ZabbixProtocol.load(sock.read)
  #=> {"response"=>"success", "data"=>[]}
end

Zabbix sender 1.8 protocol

http://www.zabbix.org/wiki/Docs/protocols/zabbix_sender/1.8

require 'socket'
require 'zabbix_protocol'

SERVER_PORT = 10051

TCPSocket.open("127.0.0.1", SERVER_PORT) do |sock|
  data = {
    "request" => "sender data",
    "data" => [{
      "host" => "my server",
      "key" => "my.key",
      "value" => "1"
    }]
  }

  sock.print ZabbixProtocol.dump(data)
  p ZabbixProtocol.load(sock.read)
  #=> {"response"=>"success", "info"=>"Processed 0 Failed 1 Total 1 Seconds spent 0.000018"}
end