zabbix_sender_api 1.0.1 → 1.0.6
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -5
- data/lib/zabbix_sender_api/api.rb +14 -5
- data/lib/zabbix_sender_api/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8047acf4e23279eaeccd8c815bc8066957291f396b67ffbc640b3ecc5cadfd7b
|
4
|
+
data.tar.gz: dbffe9d1733b4d17bdb30c8aafc931b2693f4a3d9d724d3a7cf38d84fbfdbff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c4f066506376ef8ac762775b67ef5f37d5bf211583cea9121b3566512b0ddda64b8df94bdadb61d5a17ff095d64c169d13aed7a9c719499883a0bad2d56d437
|
7
|
+
data.tar.gz: 540dcdcadcc73689eccfe0a0b4256ef34cf6e91ff60eaad9a8132c51eb8c123f1034691344dc2b91f0a534ce8af0b4e5afdc2f1afb95cef289416cf8122da262
|
data/Gemfile.lock
CHANGED
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/
|
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
|
|
@@ -111,7 +113,7 @@ Low level discovery (LLD) is also possible with zabbix-sender; the format of the
|
|
111
113
|
"theHostBeingMonitored" discoveryRuleKey 1551719797 {"data":[{"{#SOMEUSEFULVALUE}":"aValue","{#ANOTHERONE}":"somethingElse"}]}
|
112
114
|
```
|
113
115
|
The above line sends an LLD discovery structure (formatted as json) to the [discovery rule](https://www.zabbix.com/documentation/4.0/manual/discovery/low_level_discovery#discovery_rule) whose key is discoveryRuleKey. It describes one entity by passing the macro values
|
114
|
-
#SOMEUSEFULVALUE and #ANOTHERONE to the discovery rule. These '[lld macros](https://www.zabbix.com/documentation/4.0/manual/config/macros/lld_macros)' are available for use in item,trigger, and graph prototypes.
|
116
|
+
{#SOMEUSEFULVALUE} and {#ANOTHERONE} to the discovery rule. These '[lld macros](https://www.zabbix.com/documentation/4.0/manual/config/macros/lld_macros)' are available for use in item,trigger, and graph prototypes.
|
115
117
|
|
116
118
|
|
117
119
|
If you wished to use the above lld to actually do some discovery, you'd set things up in zabbix roughly like this:
|
@@ -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 =
|
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.
|
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
|
-
|
203
|
-
disco['data'] = @entities
|
204
|
-
@value = disco.to_json
|
213
|
+
@value = self.to_discodata
|
205
214
|
super
|
206
215
|
end
|
207
216
|
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.
|
4
|
+
version: 1.0.6
|
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-
|
11
|
+
date: 2020-12-16 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
|
@@ -58,7 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
|
-
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.7.6
|
62
63
|
signing_key:
|
63
64
|
specification_version: 4
|
64
65
|
summary: Ruby frontend to the zabbix_sender command line tool
|