WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

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

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] python class for "vm_rrds" and "host_rrds" and class for "rrd_updates"
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
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
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";
  Usage:
            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:
              urllib.urlretrieve("http://%s/vm_rrds?session_id=%s&uuid=%s";
% (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
Example:
            
urllib.urlretrieve("http://%s/rrd_updates?session_id=%s&start=%s&cf=AVERAGE&interval=5&vm_uuid=%s";
% (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
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] python class for "vm_rrds" and "host_rrds" and class for "rrd_updates", Alberto González Rodríguez <=