zabbix_protocol 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68192799b80b8e4af27e6cd775304e0566eec47c
4
- data.tar.gz: f327dd238150587052b9553adf9e9f17cc5350a4
3
+ metadata.gz: ba8ff0426cf78193691e25d0ca9e578beb0f8691
4
+ data.tar.gz: 4a66154c9a451c5b9f98b7fa680eca2042967d9e
5
5
  SHA512:
6
- metadata.gz: 9594e301b14992cc73313977997aa1517ebda8c61072651e521ea89613f18a6212710c6e6ab3a13a64b8836b712922d963a6f9151bdae8b061a64cf0a5fb12b0
7
- data.tar.gz: 4832ed560cc62c9c825bc83396e64261bcf45fc483330f0b4bbafd09f1686db83a63bed19513f199ee442bef9be18f0e907bf1b9f5a4d31ad88b5b68736494bf
6
+ metadata.gz: be5dd593ea6e29a70dfbad6ee50f6214b23ca175e7079436868c9ab353ac63b1c06e72ed9785b5af351acc022f34d25a2c4cab69540e02cf470ec3aedaec6ae3
7
+ data.tar.gz: e3a7099d791633c090684ab9c4c85e31e456d628b6731a47f8a692b3e48f1cd28904429a08c4a06a9e5c7079054f9281976521fcd48decf0e941afa1f0c00e58
@@ -1,3 +1,3 @@
1
1
  module ZabbixProtocol
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -6,23 +6,22 @@ module ZabbixProtocol
6
6
  class Error < StandardError; end
7
7
 
8
8
  # http://www.zabbix.org/wiki/Docs/protocols/zabbix_agent/1.4
9
- HEADER = "ZBXD"
10
- VERSION = "\x01"
9
+ ZABBIX_HEADER = "ZBXD"
10
+ ZABBIX_VERSION = "\x01"
11
11
  DATA_LEN_BYTES = 8
12
12
 
13
- MIN_RESPONSE_LEN = HEADER.length + VERSION.length + DATA_LEN_BYTES
13
+ MIN_RESPONSE_LEN = ZABBIX_HEADER.length + ZABBIX_VERSION.length + DATA_LEN_BYTES
14
14
 
15
15
  def self.dump(data)
16
16
  if data.is_a?(Hash)
17
17
  data = MultiJson.dump(data)
18
18
  else
19
19
  data = data.to_s
20
- data << "\n" unless data =~ /\n\z/
21
20
  end
22
21
 
23
22
  [
24
- HEADER,
25
- VERSION,
23
+ ZABBIX_HEADER,
24
+ ZABBIX_VERSION,
26
25
  [data.length].pack('Q'),
27
26
  data
28
27
  ].join
@@ -38,15 +37,15 @@ module ZabbixProtocol
38
37
  end
39
38
 
40
39
  data = res_data.dup
41
- header = data.slice!(0, HEADER.length)
40
+ header = data.slice!(0, ZABBIX_HEADER.length)
42
41
 
43
- if header != HEADER
42
+ if header != ZABBIX_HEADER
44
43
  raise Error, "invalid header: #{header.inspect}"
45
44
  end
46
45
 
47
- version = data.slice!(0, VERSION.length)
46
+ version = data.slice!(0, ZABBIX_VERSION.length)
48
47
 
49
- if version != VERSION
48
+ if version != ZABBIX_VERSION
50
49
  raise Error, "unsupported version: #{version.inspect}"
51
50
  end
52
51
 
@@ -4,8 +4,8 @@ describe ZabbixProtocol do
4
4
  context "when request" do
5
5
  it "should convert string to zabbix request" do
6
6
  res = subject.dump("system.cpu.load[all,avg1]")
7
- expect(res).to eq "ZBXD\x01\x1A\x00\x00\x00\x00\x00\x00\x00" +
8
- "system.cpu.load[all,avg1]\n"
7
+ expect(res).to eq "ZBXD\x01\x19\x00\x00\x00\x00\x00\x00\x00" +
8
+ "system.cpu.load[all,avg1]"
9
9
  end
10
10
 
11
11
  it "should convert hash to zabbix request" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbix_protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara