Giter Club home page Giter Club logo

zabbixapi's Introduction

zabbixapi's People

Contributors

bazilek avatar evtuhovich avatar hairmare avatar henrikjohansen avatar kenjiskywalker avatar mattiasgeniar avatar mechamogera avatar nsarno avatar scouratier avatar smartladka avatar vadv avatar verm666 avatar webdestroya avatar yves-vogl avatar zwily avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zabbixapi's Issues

API Version Error

For some reason the downloaded gem from rubygems.org still has the old version of zabbixapi.rb file and the gem errors out.
RuntimeError:
unknown Api version!

Here is the code:

case @client.api_version
when "1.3", "1.2"
apidir = "1.8"
when "2.0.4"
apidir = "2.0"
else
raise "unknown Api version!"

Create Method Clobbers Multiple List Values

It appears that the create method will collapse lists/arrays and only keep the last value. For example, I was trying to add a host to multiple hostgroups:

hostid = zabbix.hosts.create_or_update(
      :host => host.fqdn,
      :interfaces => interfaces,
      :groups => [ {:group_id => 1}, {:group_id =>2} ]
      )

With debug turned on, I could see the call create with multiple group hashes in the params:

[DEBUG] Call create with parametrs: {:host=>"foo", :interfaces=>[{:type=>1, :main=>1, :ip=>"192.168.1.1", :dns=>"foo", :port=>10050, :useip=>0}], :groups=>[{:groupid=>"1"}, {:groupid=>"2"}]}

but then I would see the request being created with just the second id group id:

[DEBUG] Send request: {"method":"host.create","params":[{"host":foo","interfaces":[{"type":1,"main":1,"ip":"192.168.1.1","dns":"foo","port":10050,"useip":0}],"status":0,"available":1,"groups":[{"groupid":"2"}], "auth":"......................", "id":69893, "jsonrpc":"2.0"}

I think I tracked it down to the merge_params in basic_func.rb (i'm using 2.0, but I presume 1.8 is like this too). I think this line is what does it ...

JSON.parse(result.gsub('},{', ','))

If I understand, the intent here is to let JSON do the merging of the default and given params into a single JSON doc and then reparse it. But it picks up and does the substiution on lists of hashes for things like groups, templates, macros, etc. ... and leaves only one in the list.

I know this isn't a proper PR, but this seems to work for me (and it gets JSON out of the picture too ... might be a little faster.)

    def stringify_keys(obj)
      return obj.inject({}){|memo,(k,v)| memo[k.to_s] =  stringify_keys(v); memo} if obj.is_a? Hash
      return obj.inject([]){|memo,v    | memo         << stringify_keys(v); memo} if obj.is_a? Array
      obj
    end

    def merge_params(params)
      stringify_keys(default_options.merge(params))
    end

I presume you were also using the JSON conversion for converting all the symbols to strings too. If I'm wrong about the reasoning behind the JSON maneuvers, then this works too:

    def merge_params(params)
      new_params = default_options.merge(params)
      JSON.parse(JSON.generate(new_params).to_s)
    end

ZabbixApi::Triggers.safe_data contains invalid regular expression(s) (0.5.6 gem)

When in instantiating ZabbixApi.connect in pry (an enhanced irb), I get the following exception.

zabbixapi-0.5.6/lib/zabbixapi/2.0/classes/triggers.rb:42: invalid regular expression; there's no previous pattern, to which '{' would define cardinality at 1: /{(\d_)}/
zabbixapi-0.5.6/lib/zabbixapi/2.0/classes/triggers.rb:47: invalid regular expression; there's no previous pattern, to which '{' would define cardinality at 1: /{._:/

No exception if I escape the curly braces and parens but I can't quite tell what was intended so escaping might be incorrect (at least in line 42).

ruby 1.8.7 (2012-06-29 patchlevel 370) [i686-darwin11.4.2]

undefined method use_ssl= in stdlib-1.8.7

Until someone releases ruby-1.9.3 rpms for the enterprise linux's they won't get newer than 1.8.7 if they can't use rvm

NoMethodError: undefined method use_ssl=' for #<#<Class:0x7f332fb12b78> zabbix.example.com:443 open=false> from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi/client.rb:55:inhttp_request'
from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi/client.rb:77:in _request' from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi/client.rb:83:inapi_request'
from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi/client.rb:23:in auth' from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi/client.rb:35:ininitialize'
from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi.rb:22:in new' from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi.rb:22:ininitialize'
from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi.rb:10:in new' from /usr/lib64/ruby/gems/1.8/gems/zabbixapi-0.5.7/lib/zabbixapi.rb:10:inconnect'
from (irb):4
from /usr/lib64/ruby/1.8/x86_64-linux/rbconfig.rb:169

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.