prtg 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,5 +1,3 @@
1
- require "prtg/sensor"
2
-
3
1
  module Prtg # :nodoc:
4
2
 
5
3
  # Proxy class to caspule request
@@ -21,7 +19,7 @@ module Prtg # :nodoc:
21
19
  # content is like a table
22
20
  # count is like LIMIT
23
21
  # start is like OFFSET
24
- VALUES = [:count, :start, :output, :id]
22
+ VALUES = [:count, :start, :output, :objid]
25
23
 
26
24
  VALUES.each do |key|
27
25
  define_method key do |value|
data/lib/prtg.rb CHANGED
@@ -1,11 +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 "happymapper"
4
-
5
- require "prtg/client"
6
- require "prtg/query"
7
- require "prtg/live_data_response"
8
- require "prtg/utils"
5
+ require "#{dir}/prtg/client"
6
+ require "#{dir}/prtg/query"
7
+ require "#{dir}/prtg/utils"
9
8
 
10
9
  # This is a wrapper for the api of paessler's prtg monitoring tool.
11
10
  #
@@ -17,5 +16,5 @@ require "prtg/utils"
17
16
  # client = Prtg::Client.new(:host => http, :username => "foo", :password => "bar")
18
17
  # p client.live_data(:sensors)
19
18
  module Prtg
20
- VERSION = "0.0.1"
19
+ VERSION = "0.0.3"
21
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.1
4
+ version: 0.0.3
5
5
  prerelease:
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: &70336738101360 !ruby/object:Gem::Requirement
16
+ requirement: &11295420 !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: *70336738101360
24
+ version_requirements: *11295420
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: []
@@ -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: