Sha256: 81549aff2d79e4bd25086eae79d564962cd5a849dfe30c75924e681d949c2889

Contents?: true

Size: 1.39 KB

Versions: 11

Compression:

Stored size: 1.39 KB

Contents

class ZabbixApi
  class Graphs < Basic

    def method_name
      "graph"
    end

    def indentify
      "name"
    end

    def get_full_data(data)
      log "[DEBUG] Call get_full_data with parametrs: #{data.inspect}"

      @client.api_request(
        :method => "#{method_name}.get",
        :params => {
          :search => {
            indentify.to_sym => data[indentify.to_sym]
          },
          :output => "extend"
        }
      )
    end

    def get_ids_by_host(data)
      ids = []
      graphs = Hash.new
      result = @client.api_request(:method => "graph.get", :params => {:filter => {:host => data[:host]}, :output => "extend"})
      result.each do |graph|
        num  = graph['graphid']
        name = graph['name']
        graphs[name] = num
        filter = data[:filter]

        unless filter.nil?
          if /#{filter}/ =~ name
            ids.push(graphs[name])
          end
        else
            ids.push(graphs[name])
        end
      end
      ids
    end

    def get_items(data)
      @client.api_request(:method => "graphitem.get", :params => { :graphids => [data], :output => "extend" } )
    end

    def create_or_update(data)
      graphid = get_id(:name => data[:name], :templateid => data[:templateid])
      graphid ? _update(data.merge(:graphid => graphid)) : create(data)
    end

    def _update(data)
      data.delete(:name)
      update(data)
    end

  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/zabbixapi-2.4.9/lib/zabbixapi/classes/graphs.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/zabbixapi-2.4.9/lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.9 lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.8 lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.7 lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.6 lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.5 lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.4 lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.3 lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.2 lib/zabbixapi/classes/graphs.rb
zabbixapi-2.4.1 lib/zabbixapi/classes/graphs.rb