Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 70 lines (50 sloc) 2.391 kb
8fbbad2e »
2011-03-28 version 0.5.0; README updates
1 h1. zenoss_client: A Ruby library for JSON/REST access to Zenoss
2
3 This is a work-in-progress to create an easy to use client JSON/REST API for
4 Zenoss (http://www.zenoss.com) written in Ruby. I love Zenoss as a product,
5 but I am much more efficient in Ruby than Python so I decided to start
6 hacking this library together. It is very incomplete and I am just adding
7 functionality as I need it or it is requested.
8
9 Cheers,
10
11 Dan Wanek
12
13 h2. CHANGES SINCE THE 0.1.x BRANCH
14
15 Starting with 0.5.0 I am trying to incorporate as much of the new JSON API
16 into this library as possible because the type conversion hackery that was
17 present in the REST code is largely unnecessary. Please note that the
18 initialization is much different because we are using the sign-in form auth
19 instead of the Basic auth of the previous version. This is because the JSON
20 calls do not support Basic authentication.
21
22 There is still much work that needs to be done in order to fully implement
23 all of the JSON methods. For now many of the older features fall back to
24 REST and some of those will always rely on REST because they are not
25 currently supported in the JSON API.
26
27
28 h2. REQUIREMENTS:
29 Gems:
30
31 * tzinfo: For Python DateTime to Ruby DateTime conversion
32
33
34 h2. UNSUPPORTED REST METHODS:
35 Some methods within Zope are unsupported due to type conversion issues.
36 I have created a work-around but you must add a custom Python script
37 to Zope in order to do this. Please see this blog post for information
38 on how add the custom script:
39
40 http://distributed-frostbite.blogspot.com/2010/04/using-ruby-with-zenoss-part-1.html
41
42 UPDATE: The script itself is now part of the source tree and can be found here: tools/callZenossMethod.py
43 It should still be installed in the same fashion as the blog post steps through.
44
45 == TO USE:
46 A gem is now available. 'gem install zenoss_client'
47
feb1a8d1 »
2011-03-28 README formatting fix
48 <pre>
49 <code>
762ad19f »
2011-03-28 README formatting fix
50 require 'zenoss'
8fbbad2e »
2011-03-28 version 0.5.0; README updates
51 require 'date'
52
53 server = 'https://zenhost:port/zport/dmd'
54 user, pass = 'zuser', 'zpass'
55 @zen = Zenoss.connect server, user, pass
56 dev = (@zen.find_devices_by_name 'myservername').first
57
58 # Get RRD data for this device
59 rrdpts = dev.get_rrd_data_points
60 datapoints = dev.fetch_rrd_value rrdpts.first.name, (DateTime.now - 1)
61
762ad19f »
2011-03-28 README formatting fix
62 # Get the uptime of the device
63 dev.sys_uptime
8fbbad2e »
2011-03-28 version 0.5.0; README updates
64
65 # Get a list of events for this system
66 dev.get_events
feb1a8d1 »
2011-03-28 README formatting fix
67 </code>
68 </pre>
8fbbad2e »
2011-03-28 version 0.5.0; README updates
69
70 Have fun and let me know what needs to be fixed / added.
Something went wrong with that request. Please try again.