lib/zabbix_pusher.rb in zabbix_pusher-0.0.4 vs lib/zabbix_pusher.rb in zabbix_pusher-0.0.6
- old
+ new
@@ -54,22 +54,27 @@
templates.each do |template|
template_items = Nokogiri::XML(File.open(template))
items = template_items.xpath('//item').map {|item| item.attributes['key'].text}.compact
items.each do |item|
parts = item.match(/([^\[]+)\[([^\]]+)/)
- key = parts[1]
- attributes = parts[2]
- (parsed_items[key.to_sym]) ? parsed_items[key.to_sym] << attributes : parsed_items[key.to_sym] = [attributes]
+ unless parts.nil?
+ key = parts[1].underscore.to_sym
+ attributes = parts[2]
+ (parsed_items[key]) ? parsed_items[key] << attributes : parsed_items[key] = [attributes]
+ else
+ puts "not evaluating: "+item
+ end
end
end
parsed_items
end
def send(items = :all)
return if @items.nil?
- pushers = ( items == :all) ? (@items.keys.map{ |key| "ZabbixPusher::#{key.to_s.camelize}".constantize}) : ["ZabbixPusher::#{items.camelize}".constantize]
+
+ pushers = ( items == :all) ? ( @items.keys.map{ |key| "ZabbixPusher::#{key.to_s.camelize}".constantize }) : ["ZabbixPusher::#{items.camelize}".constantize]
processed_items = Hash.new
pushers.map do |pusher|
pusher_key = pusher.to_s.demodulize.underscore.to_sym