Class: Prtg::Client
- Inherits:
-
Object
- Object
- Prtg::Client
- Defined in:
- lib/prtg/client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
The host is a Net:Http(s) instance.
-
#passhash ⇒ Object
The
passhash
in comibnation with theusername
is used for authentication. -
#password ⇒ Object
writeonly
Password for prtg user.
-
#username ⇒ Object
Username of the prtg user.
Instance Method Summary collapse
- #auth_params ⇒ Object
- #devices ⇒ Object
- #getpasshash ⇒ Object
- #getstatus ⇒ Object
- #historicdata ⇒ Object
-
#initialize(args) ⇒ Client
constructor
A new instance of Client.
- #live_data(content) ⇒ Object
- #table ⇒ Object
Constructor Details
#initialize(args) ⇒ Client
Returns a new instance of Client.
25 26 27 28 29 30 31 |
# File 'lib/prtg/client.rb', line 25 def initialize(args) args.each do |k,v| send("#{k}=", v) end @host or raise ArgumentError.new("Need host") end |
Instance Attribute Details
#host ⇒ Object
The host is a Net:Http(s) instance
12 13 14 |
# File 'lib/prtg/client.rb', line 12 def host @host end |
#passhash ⇒ Object
The passhash
in comibnation with the username
is used for authentication. The passhash gets generated by the prtg instance.
If no passhash is set he gets lazy converted using password
37 38 39 |
# File 'lib/prtg/client.rb', line 37 def passhash @passhash end |
#password=(value) ⇒ Object (writeonly)
Password for prtg user
The password is just temporary because of the intension to use passhash
as auth method.
21 22 23 |
# File 'lib/prtg/client.rb', line 21 def password=(value) @password = value end |
#username ⇒ Object
Username of the prtg user
15 16 17 |
# File 'lib/prtg/client.rb', line 15 def username @username end |
Instance Method Details
#auth_params ⇒ Object
75 76 77 |
# File 'lib/prtg/client.rb', line 75 def auth_params {:username => @username, :passhash => passhash} end |
#devices ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/prtg/client.rb', line 52 def devices params = { :content => "devices", :output => "xml", :columns => %w( objid probe group device host downsens partialdownsens downacksens upsens warnsens pausedsens unusualsens undefinedsens).join(",") } api_request(params) end |
#getpasshash ⇒ Object
41 42 43 44 45 |
# File 'lib/prtg/client.rb', line 41 def getpasshash url = "/api/getpasshash.htm?"+ Utils.url_params(:username => @username, :password => @password) host.get(url, {"accept-encoding" => "gzip"}).body end |
#getstatus ⇒ Object
47 48 49 50 |
# File 'lib/prtg/client.rb', line 47 def getstatus url_params = Utils.url_params(auth_params) parse_response(host.get("/api/getstatus.xml" + url_params)) end |
#historicdata ⇒ Object
88 89 90 |
# File 'lib/prtg/client.rb', line 88 def historicdata Prtg::HistoricDataQuery.new(@host, auth_params) end |
#live_data(content) ⇒ Object
79 80 81 82 |
# File 'lib/prtg/client.rb', line 79 def live_data(content) warn "[DEPRECATION] Client#live_data is depricated. Please use 'Client#table.content(#{ content }) instead." table.content(content) end |
#table ⇒ Object
84 85 86 |
# File 'lib/prtg/client.rb', line 84 def table Prtg::TableQuery.new(@host, auth_params) end |