[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] python class for "vm_rrds" and "host_rrds" and class for "rrd_updates"

  • To: xen-api@xxxxxxxxxxxxxxxxxxx
  • From: Alberto González Rodríguez <alberto@xxxxxxxxxxxxx>
  • Date: Thu, 20 May 2010 15:42:46 +0200
  • Delivery-date: Thu, 20 May 2010 06:46:55 -0700
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

I want share with list this file, it contains two classes:

from rrd import RRD, XPORT

- RRD class: Used for "http://ip/host_rrds"; and "http://ip/vm_rrds";
            for host:
              urllib.urlretrieve("http://%s/host_rrds?session_id=%s"; %
(ip, self.session_uuid), "host_rrds.rrd")
              rrd = RRD("host_rrds.rrd")
            for vm:
% (ip, self.session_uuid, uuid), "vm_rrds.rrd")

            Create an object:
            rrd = RRD("vm_rrds.rrd")

            rrd will contains a dict:
                rrd["version"] -> rrrd version
                rrd["step"] -> seconds between data
                rrd["lastupdate"] -> timestamp of last update
                rrd["ds"] -> will contains the keys and values (memory, cpu, ..)
                                  -> "type"
                                  -> "minimal_heartbeat"
                                  -> "min"
                                  -> "max"
                                  -> "last_ds"
                                  -> "value"
                                  -> "unknown_sec"
                                  -> "values" (empty array)

            then you get data (fill rrd[ds][key]["values"] for each key):
                rrdinfo = rrd.get_data(period)

             If you want loop over rrdinfo:
                for key in rrdinfo.keys():
                     print key
                     print rrdinfo[key]["values"]

- XPORT  class: Used for "http://ip/rrd_updates
% (ip, self.session_uuid, int(time.time())-10, uuid), "update.rrd")
            rrd = XPORT("update.rrd")
            rrdxport = rrd.get_data()
            for key in rrdxport.keys():
                     print key
                     print rrdxport[key]["values"]

Attachment: rrd.py
Description: Text Data

xen-api mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.