logstash-filter-zabbix 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/filters/zabbix.rb +6 -4
- data/lib/logstash/filters/zabbix/cache.rb +33 -5
- data/logstash-filter-zabbix.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78713a2817832a7c39002265d3c70038d749621d
|
4
|
+
data.tar.gz: 7bb406a24d3da2542497ff06747f9e40185e60cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f83bbe2c23237127827292856038c80ce33096cef94b212591a5e3624de58221ca6e1e5176ff503bc86cb91826249dbddc0c1288985725f839086af77dc7928a
|
7
|
+
data.tar.gz: 79783ba99a61d26e5e6214160daaea97259491e4139b76dfb5e641de0b7a4803590f75c9b6de87329b637b1b0a8872c8bb52c05e9de9226f372c1b7d7c46b017
|
@@ -16,14 +16,16 @@ class LogStash::Filters::Zabbix < LogStash::Filters::Base
|
|
16
16
|
|
17
17
|
public
|
18
18
|
def register
|
19
|
-
|
19
|
+
options = {
|
20
20
|
url: @url,
|
21
21
|
user: @user,
|
22
22
|
password: @password,
|
23
23
|
group_id: @group_id,
|
24
24
|
keys: @keys
|
25
|
-
|
26
|
-
|
25
|
+
}
|
26
|
+
|
27
|
+
@zabbix_updater = Cache.new(@logger, options)
|
28
|
+
@zabbix_updater.start
|
27
29
|
end # def register
|
28
30
|
|
29
31
|
public
|
@@ -32,7 +34,7 @@ class LogStash::Filters::Zabbix < LogStash::Filters::Base
|
|
32
34
|
|
33
35
|
if 'insert' == event.get('type')
|
34
36
|
data = event.get("data")
|
35
|
-
item = @items[data["itemid"]]
|
37
|
+
item = @zabbix_updater.items[data["itemid"]]
|
36
38
|
|
37
39
|
if item
|
38
40
|
metric = {
|
@@ -1,24 +1,52 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
3
|
+
REFRSH_INTERVAL = 6 * 36000 # every 6 hours
|
4
|
+
|
2
5
|
class LogStash::Filters::Zabbix::Cache
|
3
6
|
require 'zabbixapi'
|
4
7
|
|
5
|
-
|
6
|
-
|
8
|
+
attr_accessor :items
|
9
|
+
|
10
|
+
def initialize(logger, options)
|
11
|
+
@logger = logger
|
12
|
+
@options = options
|
13
|
+
@items = {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def start
|
17
|
+
self.fetch()
|
18
|
+
@wt = Thread.new do
|
19
|
+
# update zabbix hosts every 6 hours
|
20
|
+
while true
|
21
|
+
sleep(@options[:interval] || REFRSH_INTERVAL)
|
22
|
+
self.fetch()
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def end
|
28
|
+
@wt.kill
|
29
|
+
end
|
30
|
+
|
31
|
+
def fetch()
|
32
|
+
zbx = ZabbixApi.connect(@options)
|
7
33
|
response = zbx.query(
|
8
34
|
method: 'host.get',
|
9
35
|
params: {
|
10
|
-
groupids: options[:group_id],
|
36
|
+
groupids: @options[:group_id],
|
11
37
|
output: ['hostid', 'host'],
|
12
38
|
selectItems: ['itemid', 'key_', 'formula'],
|
13
39
|
selectInterfaces: ['ip'],
|
14
40
|
});
|
15
41
|
|
16
|
-
|
42
|
+
@items = parse(response, @options[:keys])
|
43
|
+
@logger.info("Got zabbix items", :size => @items.keys.size)
|
44
|
+
@items
|
17
45
|
end
|
18
46
|
|
19
47
|
private
|
20
48
|
|
21
|
-
def
|
49
|
+
def parse(hosts, keys)
|
22
50
|
hosts.reduce({}) do |memo, data|
|
23
51
|
data['items'].each do |item|
|
24
52
|
if keys.any? { |key| item['key_'].start_with?(key) }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-zabbix'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.2'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = %q{logstash-filter-zabbix - A filter to retain zabbix metrics you want to}
|
6
6
|
s.description = %q{This plugin will keep the specific items you want from zabbix history data stream}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-zabbix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hupu Devops
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|