prtg 0.0.1p2 → 0.0.1p3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/prtg/client.rb CHANGED
@@ -45,7 +45,8 @@ module Prtg # :nodoc:
45
45
  end
46
46
 
47
47
  def getstatus
48
- host.get("/api/getstatus.xml")
48
+ url_params = Utils.url_params(auth_params)
49
+ parse_response(host.get("/api/getstatus.xml" + url_params))
49
50
  end
50
51
 
51
52
  def devices
@@ -80,12 +81,27 @@ module Prtg # :nodoc:
80
81
  end
81
82
 
82
83
  def api_request(params)
83
- resp_body = host.get("/api/table.xml?" + Utils.url_params(auth_params.merge(params))).body
84
- XmlSimple.xml_in(resp_body)
84
+ url_params = Utils.url_params(auth_params.merge(params))
85
+ response = host.get("/api/table.xml?" + url_params)
86
+
87
+ parse_response(response)
85
88
  end
86
89
 
87
90
  def method_missing(*args)
88
91
  super(*args)
89
92
  end
93
+
94
+ private
95
+
96
+ def parse_response(response)
97
+ hash = XmlSimple.xml_in(response.body)
98
+
99
+ if hash["error"]
100
+ raise hash["error"]
101
+
102
+ else
103
+ hash["item"]
104
+ end
105
+ end
90
106
  end
91
107
  end
data/lib/prtg/query.rb CHANGED
@@ -19,7 +19,7 @@ module Prtg # :nodoc:
19
19
  # content is like a table
20
20
  # count is like LIMIT
21
21
  # start is like OFFSET
22
- VALUES = [:count, :start, :output, :id]
22
+ VALUES = [:count, :start, :output, :objid]
23
23
 
24
24
  VALUES.each do |key|
25
25
  define_method key do |value|
data/lib/prtg.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  # encoding: utf-8
2
+ dir = File.dirname(__FILE__)
3
+ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
2
4
  require "rubygems"
3
- require "prtg/client"
4
- require "prtg/query"
5
- require "prtg/utils"
5
+ require "#{dir}/prtg/client"
6
+ require "#{dir}/prtg/query"
7
+ require "#{dir}/prtg/utils"
6
8
 
7
9
  # This is a wrapper for the api of paessler's prtg monitoring tool.
8
10
  #
@@ -14,5 +16,5 @@ require "prtg/utils"
14
16
  # client = Prtg::Client.new(:host => http, :username => "foo", :password => "bar")
15
17
  # p client.live_data(:sensors)
16
18
  module Prtg
17
- VERSION = "0.0.1"
19
+ VERSION = "0.0.1p3"
18
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prtg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1p2
4
+ version: 0.0.1p3
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-13 00:00:00.000000000Z
12
+ date: 2012-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
16
- requirement: &70137843766000 !ruby/object:Gem::Requirement
16
+ requirement: &21831180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.1.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70137843766000
24
+ version_requirements: *21831180
25
25
  description: This gem is a wrapper around the prth http api.Prtg is an network monitoring
26
26
  solution which provides a api to retrieve several information about monitored devices.
27
27
  email: k@kanello.de
@@ -29,9 +29,9 @@ executables: []
29
29
  extensions: []
30
30
  extra_rdoc_files: []
31
31
  files:
32
- - lib/prtg/client.rb
33
- - lib/prtg/query.rb
34
32
  - lib/prtg/utils.rb
33
+ - lib/prtg/query.rb
34
+ - lib/prtg/client.rb
35
35
  - lib/prtg.rb
36
36
  homepage: http://github.com/ikaros/Prtg-for-Ruby
37
37
  licenses: []
@@ -44,7 +44,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.9.2
47
+ version: 1.8.7
48
48
  required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
@@ -58,3 +58,4 @@ signing_key:
58
58
  specification_version: 3
59
59
  summary: Wrapper for the prtg network monitor api (http://www.paessler.com/prtg)
60
60
  test_files: []
61
+ has_rdoc: