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"]
rrd.py
Description: Text Data
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|