zabbix_sender_api 1.0.2 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 735a9614074e16380ab7d139fc9a06cf6e4095ad765757458a392226976f0e54
4
- data.tar.gz: 419cd69eb0abfd3523dc10466fccdf8361341aa1e2a23f4e701114830be747d5
3
+ metadata.gz: 89e13bebbddda9a40ec5990b685c876cccc4dc535d4f0aa71ee5e9e4c9ff0643
4
+ data.tar.gz: 5570e008ccdeae7d5f9866fa4edc6faf71bbc7968f1ee5a5a5f2a6d1c815131a
5
5
  SHA512:
6
- metadata.gz: f549209f14df37a878454f539c7cee19c505010e919c31ba10e7a163b062e3b4f167ee775fc627a845672fbe99dfd0285bcdb26057cbe54a99c8b495d55ff922
7
- data.tar.gz: 0b362402db258d1e2f297b243521e9a3e02c2a1573fec8c095470eb9abe5ea2c4d36095e0d8bcc216baae30b45fdd670470c7f951a55f6cb65bbbdbefda7b244
6
+ metadata.gz: 614555a8b2dd25f742140504eae44f84d28a977888ba7d3583ad8db818ecc646a3302a33893c5a46b92215e744f1e0ce7bed0126b4cfc1ac15d03c8657dd7880
7
+ data.tar.gz: 8ca65d78ae038b7ac78a093c9b85df976d3f969d3e115e50c0301f72d4a4664834adc3a2e0cbc79ab38180c4b0e4ea9412ff998aaea51a16ad3c687163808d40
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ Gemfile.lock
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /_yardoc/
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  This gem describes an api that takes some of the drudgery out of the task of putting together bulk data for the zabbix_sender utility.
4
4
 
5
- Detailed documentation for this library is at [rubydoc.info](https://rubydoc.info/gems/zabbix_sender_ap)
5
+ **Detailed documentation for this library is at [rubydoc.info](https://rubydoc.info/gems/zabbix_sender_api)**
6
+
7
+ Look at [the source for the zfstozab gem](https://gitlab.com/svdasein/zfstozab/-/blob/master/exe/zabbix-zfs.rb) for a practical example how to use this api.
6
8
 
7
9
  zabbix_sender is a command line utility for sending monitoring data to Zabbix server or proxy. On the Zabbix server an item of type Zabbix trapper should be created with corresponding key.
8
10
 
@@ -43,11 +45,11 @@ It is analogous to:
43
45
  #!/usr/bin/env ruby
44
46
  require 'zabbix_sender_api'
45
47
 
46
- sender = Zabbix::Sender.new
48
+ sender = Zabbix::Sender::Pipe.new
47
49
 
48
50
  rawdata = { :myFirstKey => 0, :mySecondKey => 100 }
49
51
 
50
- data = Zabbix::Batch.new
52
+ data = Zabbix::Sender::Batch.new
51
53
 
52
54
  rawdata.each_pair {|key,value|
53
55
  data.addItemData(key: key,value: value)
@@ -69,7 +71,7 @@ puts data.to_senderinput
69
71
  To do low level discovery:
70
72
 
71
73
  ```ruby
72
- disco = Zabbix::Discovery.new(key: 'discoveryRuleKey')
74
+ disco = Zabbix::Sender::Discovery.new(key: 'discoveryRuleKey')
73
75
 
74
76
  disco.add_entity(:SOMEUSEFULVALUE => 'aValue', :ANOTHERONE => 'somethingElse')
75
77
 
@@ -60,6 +60,7 @@ class AgentConfiguration
60
60
  end
61
61
 
62
62
  module Sender
63
+ require 'set'
63
64
 
64
65
  ##
65
66
  # Pipe instances encapsulate communication to a running instance of zabbix_sender
@@ -172,12 +173,13 @@ end
172
173
  # then pass the discover instance into a Batch via addDiscovery(), which
173
174
  # includes it in the batch of data just like an ordinary ItemData instance.
174
175
  class Discovery < ItemData
176
+ attr_reader :entities
175
177
  ##
176
178
  # The only required parameter is key:, which is the discovery rule key.
177
179
  #
178
180
  def initialize(key: nil,value: nil, timestamp: nil, hostname: nil)
179
181
  super
180
- @entities = Array.new
182
+ @entities = Set.new
181
183
  end
182
184
  ##
183
185
  # This is how you pass data to zabbix that you use to construct items from item templates. Pass in
@@ -193,15 +195,22 @@ class Discovery < ItemData
193
195
  aHash.each_pair { |key,value|
194
196
  zabbified[%Q({##{key.to_s.upcase}})] = value
195
197
  }
196
- @entities.push(zabbified)
198
+ @entities.add(zabbified)
199
+ end
200
+ ##
201
+ # Render this discovery as the structure an external discovery script should return. You can use this
202
+ # if you're writing custom external discovery logic
203
+ #
204
+ def to_discodata
205
+ disco = { 'data'=>Array.new }
206
+ disco['data'] = @entities.to_a
207
+ return disco.to_json
197
208
  end
198
209
  ##
199
210
  # Render this discovery instance as a zabbix_sender line.
200
211
  #
201
212
  def to_senderline
202
- disco = { 'data'=>Array.new }
203
- disco['data'] = @entities
204
- @value = disco.to_json
213
+ @value = self.to_discodata
205
214
  super
206
215
  end
207
216
  end
@@ -260,6 +269,12 @@ class Batch
260
269
  @data.unshift(aDiscovery)
261
270
  end
262
271
 
272
+ ##
273
+ # Append another batch's data into this one.
274
+ def appendBatch(aBatch)
275
+ @data.append(*aBatch.data)
276
+ end
277
+
263
278
  ##
264
279
  # Render this batch of data as a sequence of lines of text appropriate
265
280
  # for sending into zabbix_sender
@@ -1,3 +1,3 @@
1
1
  module ZabbixSenderApi
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbix_sender_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Parker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-02 00:00:00.000000000 Z
11
+ date: 2021-06-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem describes an api to the zabbix sender facility. It saves tons
14
14
  of hassle when you're cranking out custom polling logic
@@ -21,7 +21,6 @@ extra_rdoc_files: []
21
21
  files:
22
22
  - ".gitignore"
23
23
  - Gemfile
24
- - Gemfile.lock
25
24
  - LICENSE.txt
26
25
  - README.md
27
26
  - Rakefile
@@ -58,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
57
  - !ruby/object:Gem::Version
59
58
  version: '0'
60
59
  requirements: []
61
- rubygems_version: 3.1.2
60
+ rubygems_version: 3.1.6
62
61
  signing_key:
63
62
  specification_version: 4
64
63
  summary: Ruby frontend to the zabbix_sender command line tool
data/Gemfile.lock DELETED
@@ -1,30 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- zabbix_sender_api (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- byebug (11.1.3)
10
- coderay (1.1.3)
11
- method_source (1.0.0)
12
- pry (0.13.1)
13
- coderay (~> 1.1)
14
- method_source (~> 1.0)
15
- pry-byebug (3.9.0)
16
- byebug (~> 11.0)
17
- pry (~> 0.13.0)
18
- rake (12.3.3)
19
-
20
- PLATFORMS
21
- ruby
22
-
23
- DEPENDENCIES
24
- pry
25
- pry-byebug
26
- rake
27
- zabbix_sender_api!
28
-
29
- BUNDLED WITH
30
- 2.1.4