zabbix_sender_api 1.0.0 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -4
- data/lib/zabbix_sender_api/api.rb +5 -3
- data/lib/zabbix_sender_api/version.rb +1 -1
- data/zabbix_sender_api.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f768b8820795e99e87ea3af8ed4cdae063daef728e7c121d5bf9b51a155780b
|
4
|
+
data.tar.gz: b15a5dd5f1ead39e38edff158b35a1b015864c51dc1f4ac9907e1e6ac7f9e1cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc34a4e8f82f4c4ca922c65ee35e0ce998eaea72ad5f46138c016bb5226fc1c9387712d2668727fb0305494cc009f79ed1df48586dab81b66a9ad0cbb47c4e99
|
7
|
+
data.tar.gz: 9a24440d4b7d0002ccd331fb43a3c3278af279f3834adb77d17c119583acc63fda4e1af1e23873cd0fe6912a350aa104c24a69928ebc6fb16e702ad6f6040bea
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
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_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.
|
8
|
+
|
5
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.
|
6
10
|
|
7
11
|
* [Zabbix sender manpage](https://www.zabbix.com/documentation/4.0/manpages/zabbix_sender)
|
@@ -41,11 +45,11 @@ It is analogous to:
|
|
41
45
|
#!/usr/bin/env ruby
|
42
46
|
require 'zabbix_sender_api'
|
43
47
|
|
44
|
-
sender = Zabbix::Sender.new
|
48
|
+
sender = Zabbix::Sender::Pipe.new
|
45
49
|
|
46
50
|
rawdata = { :myFirstKey => 0, :mySecondKey => 100 }
|
47
51
|
|
48
|
-
data = Zabbix::Batch.new
|
52
|
+
data = Zabbix::Sender::Batch.new
|
49
53
|
|
50
54
|
rawdata.each_pair {|key,value|
|
51
55
|
data.addItemData(key: key,value: value)
|
@@ -67,7 +71,7 @@ puts data.to_senderinput
|
|
67
71
|
To do low level discovery:
|
68
72
|
|
69
73
|
```ruby
|
70
|
-
disco = Zabbix::Discovery.new(key: 'discoveryRuleKey')
|
74
|
+
disco = Zabbix::Sender::Discovery.new(key: 'discoveryRuleKey')
|
71
75
|
|
72
76
|
disco.add_entity(:SOMEUSEFULVALUE => 'aValue', :ANOTHERONE => 'somethingElse')
|
73
77
|
|
@@ -109,7 +113,7 @@ Low level discovery (LLD) is also possible with zabbix-sender; the format of the
|
|
109
113
|
"theHostBeingMonitored" discoveryRuleKey 1551719797 {"data":[{"{#SOMEUSEFULVALUE}":"aValue","{#ANOTHERONE}":"somethingElse"}]}
|
110
114
|
```
|
111
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
|
112
|
-
#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.
|
113
117
|
|
114
118
|
|
115
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,14 +195,14 @@ 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)
|
197
199
|
end
|
198
200
|
##
|
199
201
|
# Render this discovery instance as a zabbix_sender line.
|
200
202
|
#
|
201
203
|
def to_senderline
|
202
204
|
disco = { 'data'=>Array.new }
|
203
|
-
disco['data'] = @entities
|
205
|
+
disco['data'] = @entities.to_a
|
204
206
|
@value = disco.to_json
|
205
207
|
super
|
206
208
|
end
|
data/zabbix_sender_api.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
|
9
9
|
spec.summary = %q{Ruby frontend to the zabbix_sender command line tool}
|
10
10
|
spec.description = %q{This gem describes an api to the zabbix sender facility. It saves tons of hassle when you're cranking out custom polling logic}
|
11
|
-
spec.homepage = "https://
|
11
|
+
spec.homepage = "https://rubydoc.info/gems/zabbix_sender_api"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
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.5
|
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-
|
11
|
+
date: 2020-08-08 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
|
@@ -36,12 +36,12 @@ files:
|
|
36
36
|
- lib/zabbix_sender_api/version.rb
|
37
37
|
- zabbix-sender-help.md
|
38
38
|
- zabbix_sender_api.gemspec
|
39
|
-
homepage: https://
|
39
|
+
homepage: https://rubydoc.info/gems/zabbix_sender_api
|
40
40
|
licenses:
|
41
41
|
- MIT
|
42
42
|
metadata:
|
43
43
|
allowed_push_host: https://rubygems.org
|
44
|
-
homepage_uri: https://
|
44
|
+
homepage_uri: https://rubydoc.info/gems/zabbix_sender_api
|
45
45
|
source_code_uri: https://gitlab.com/svdasein/zabbix_sender_api
|
46
46
|
post_install_message:
|
47
47
|
rdoc_options: []
|