Mailing List Archive

get 3 hosts real-time performing metrics and show them on the same page.
Hi all,
I build a pool includes 3 hosts : vGate7, vGate8 and vGate9. vGate9 is the
master, others are slaves.
I build a page to show the host and vm performing
metrics(e.g.cpu_utilization) on it. It works fine for the mater
(vGate9).But it cannot get the slave performing metrics.

As follows in picture 1 :



In python, I use the following codes to get the CPU Usage:

import XenAPI
url = "https://host_ip"
username = "hostname"
password = "self_password"

session = XenAPI.session(url)
session.xenapi.login_with_password(username,password)


cpu_usage =
session.xenapi.host.query_data_source("OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448"
, 'cpu_avg')
# OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448 is vGate7
(slave),
# and it will show XenAPI.Failure:*['HOST_OFFLINE']*


I attempt to make an API call to a slave (even someting trivial like
pool.get_all()),I get the *['HOST_IS_SLAVE'] *exception,along with the
master's IP address.


The main problem is to get 3 hosts real-time performing metrics and to show
them on the same page.
Is there any workaround to solve this problem?
The attachment is picture1, incase you cannot see it in the message.
Thank you in advance!


Thanks and Regards,
Will
Re: get 3 hosts real-time performing metrics and show them on the same page. [ In reply to ]
Hi Will,

To get performance metrics, the preferred mechanism is to use the RRD
interface - it's much more lightweight than using the API
'query_data_source'. Have a look here for some docs and sample code:

http://xenserver.org/partners/developing-products-for-xenserver/18-sdk-development/96-xs-dev-rrds.html

Jon

On 24/11/14 02:46, Will Sun wrote:
> Hi all,
> I build a pool includes 3 hosts : vGate7, vGate8 and vGate9. vGate9 is
> the master, others are slaves.
> I build a page to show the host and vm performing
> metrics(e.g.cpu_utilization) on it. It works fine for the mater
> (vGate9).But it cannot get the slave performing metrics.
>
> As follows in picture 1 :
>
>
>
> In python, I use the following codes to get the CPU Usage:
>
> import XenAPI
> url = "https://host_ip"
> username = "hostname"
> password = "self_password"
>
> session = XenAPI.session(url)
> session.xenapi.login_with_password(username,password)
>
>
> cpu_usage =
> session.xenapi.host.query_data_source("OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448"
> , 'cpu_avg')
> # OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448 is
> vGate7 (slave),
> # and it will show XenAPI.Failure:*['HOST_OFFLINE']** *
>
>
> I attempt to make an API call to a slave (even someting trivial like
> pool.get_all()),I get the *['HOST_IS_SLAVE'] *exception,along with the
> master's IP address.
>
>
> The main problem is to get 3 hosts real-time performing metrics and to
> show them on the same page.
> Is there any workaround to solve this problem?
> The attachment is picture1, incase you cannot see it in the message.
> Thank you in advance!
>
>
> Thanks and Regards,
> Will
>
>
> _______________________________________________
> Xen-api mailing list
> Xen-api@lists.xen.org
> http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
Re: get 3 hosts real-time performing metrics and show them on the same page. [ In reply to ]
Hi Jon,
Thanks very much. In fact ,I have used the RRD interface to get the
master's metrics,and it worked fine. The codes as follows:

https://github.com/hswayne77/CitrixXenserver-monitoring

But I cannot get the slave's metrics , unless I use the commands
"pool.designate_new_master" to make slave become master. If I do so, I
still cannot get the other two slaves metrics.
In the *Citrix XenServer Management API ,* I can only manage the slave
host by the master . In the session, the arguments "url" cannot be the
slave's ip, or it will show the failure: [HOST_IS_SLAVE].
I do not want to get just one host metrics, instead I want to get all 3
hosts metrics in the same pool and to show them in one page at the same
time.


Thanks and Regards

Will

2014-11-24 19:40 GMT+08:00 Jon Ludlam <jonathan.ludlam@citrix.com>:

> Hi Will,
>
> To get performance metrics, the preferred mechanism is to use the RRD
> interface - it's much more lightweight than using the API
> 'query_data_source'. Have a look here for some docs and sample code:
>
>
> http://xenserver.org/partners/developing-products-for-xenserver/18-sdk-development/96-xs-dev-rrds.html
>
> Jon
>
>
> On 24/11/14 02:46, Will Sun wrote:
>
> Hi all,
> I build a pool includes 3 hosts : vGate7, vGate8 and vGate9. vGate9 is the
> master, others are slaves.
> I build a page to show the host and vm performing
> metrics(e.g.cpu_utilization) on it. It works fine for the mater
> (vGate9).But it cannot get the slave performing metrics.
>
> As follows in picture 1 :
>
>
>
> In python, I use the following codes to get the CPU Usage:
>
> import XenAPI
> url = "https://host_ip"
> username = "hostname"
> password = "self_password"
>
> session = XenAPI.session(url)
> session.xenapi.login_with_password(username,password)
>
>
> cpu_usage =
> session.xenapi.host.query_data_source("OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448"
> , 'cpu_avg')
> # OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448 is vGate7
> (slave),
> # and it will show XenAPI.Failure:*['HOST_OFFLINE']*
>
>
> I attempt to make an API call to a slave (even someting trivial like
> pool.get_all()),I get the *['HOST_IS_SLAVE'] *exception,along with the
> master's IP address.
>
>
> The main problem is to get 3 hosts real-time performing metrics and to
> show them on the same page.
> Is there any workaround to solve this problem?
> The attachment is picture1, incase you cannot see it in the message.
> Thank you in advance!
>
>
> Thanks and Regards,
> Will
>
>
> _______________________________________________
> Xen-api mailing listXen-api@lists.xen.orghttp://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
>
>
>
> _______________________________________________
> Xen-api mailing list
> Xen-api@lists.xen.org
> http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
>
>
Re: get 3 hosts real-time performing metrics and show them on the same page. [ In reply to ]
Hi Will,

It looks like what the code is doing is trying to create the session on
the slave before doing the RRD GET call. Sessions are handled by the
pool master, so that's why you get the HOST_IS_SLAVE error.

What you should do is create one session on the master, then use that
one session for querying the RRD data on each slave.

HTH,

Jon



On 24/11/14 13:05, Will Sun wrote:
> Hi Jon,
> Thanks very much. In fact ,I have used the RRD interface to get the
> master's metrics,and it worked fine. The codes as follows:
>
> https://github.com/hswayne77/CitrixXenserver-monitoring
>
> But I cannot get the slave's metrics , unless I use the commands
> "pool.designate_new_master" to make slave become master. If I do so, I
> still cannot get the other two slaves metrics.
> In the /Citrix XenServer Management API ,/ I can only manage the
> slave host by the master . In the session, the arguments "url" cannot
> be the slave's ip, or it will show the failure: [HOST_IS_SLAVE].
> I do not want to get just one host metrics, instead I want to get
> all 3 hosts metrics in the same pool and to show them in one page at
> the same time.
>
>
> Thanks and Regards
>
> Will
>
> 2014-11-24 19:40 GMT+08:00 Jon Ludlam <jonathan.ludlam@citrix.com
> <mailto:jonathan.ludlam@citrix.com>>:
>
> Hi Will,
>
> To get performance metrics, the preferred mechanism is to use the
> RRD interface - it's much more lightweight than using the API
> 'query_data_source'. Have a look here for some docs and sample code:
>
> http://xenserver.org/partners/developing-products-for-xenserver/18-sdk-development/96-xs-dev-rrds.html
>
> Jon
>
>
> On 24/11/14 02:46, Will Sun wrote:
>> Hi all,
>> I build a pool includes 3 hosts : vGate7, vGate8 and vGate9.
>> vGate9 is the master, others are slaves.
>> I build a page to show the host and vm performing
>> metrics(e.g.cpu_utilization) on it. It works fine for the mater
>> (vGate9).But it cannot get the slave performing metrics.
>>
>> As follows in picture 1 :
>>
>>
>>
>> In python, I use the following codes to get the CPU Usage:
>>
>> import XenAPI
>> url = "https://host_ip"
>> username = "hostname"
>> password = "self_password"
>>
>> session = XenAPI.session(url)
>> session.xenapi.login_with_password(username,password)
>>
>>
>> cpu_usage =
>> session.xenapi.host.query_data_source("OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448"
>> , 'cpu_avg')
>> # OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448
>> is vGate7 (slave),
>> # and it will show XenAPI.Failure:*['HOST_OFFLINE']** *
>>
>>
>> I attempt to make an API call to a slave (even someting trivial
>> like pool.get_all()),I get the *['HOST_IS_SLAVE']
>> *exception,along with the master's IP address.
>>
>>
>> The main problem is to get 3 hosts real-time performing metrics
>> and to show them on the same page.
>> Is there any workaround to solve this problem?
>> The attachment is picture1, incase you cannot see it in the message.
>> Thank you in advance!
>>
>>
>> Thanks and Regards,
>> Will
>>
>>
>> _______________________________________________
>> Xen-api mailing list
>> Xen-api@lists.xen.org <mailto:Xen-api@lists.xen.org>
>> http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
>
>
> _______________________________________________
> Xen-api mailing list
> Xen-api@lists.xen.org <mailto:Xen-api@lists.xen.org>
> http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
>
>
Re: get 3 hosts real-time performing metrics and show them on the same page. [ In reply to ]
Hi Jon,
Thanks very much. As you said, I create one session on the master,(the code
I give in last email is also firstly creates one session on the master ),
then I use that session for querying the RRD data on one slave.But it shows
failure* ['HOST_OFFLINE'], *that means I attempted an operation which
involves a host which cannot be contacted.

I want to confirm one thing: where is the RRD of slave stored? master host
or slave host itself? I think it's slave.
How do I use the session on the master to query the RRD data on each slave?
Can you give me a sample?


Thanks and Regards,

Will

2014-11-24 23:17 GMT+08:00 Jon Ludlam <jonathan.ludlam@citrix.com>:

> Hi Will,
>
> It looks like what the code is doing is trying to create the session on
> the slave before doing the RRD GET call. Sessions are handled by the pool
> master, so that's why you get the HOST_IS_SLAVE error.
>
> What you should do is create one session on the master, then use that one
> session for querying the RRD data on each slave.
>
> HTH,
>
> Jon
>
>
>
>
> On 24/11/14 13:05, Will Sun wrote:
>
> Hi Jon,
> Thanks very much. In fact ,I have used the RRD interface to get the
> master's metrics,and it worked fine. The codes as follows:
>
> https://github.com/hswayne77/CitrixXenserver-monitoring
>
> But I cannot get the slave's metrics , unless I use the commands
> "pool.designate_new_master" to make slave become master. If I do so, I
> still cannot get the other two slaves metrics.
> In the *Citrix XenServer Management API ,* I can only manage the
> slave host by the master . In the session, the arguments "url" cannot be
> the slave's ip, or it will show the failure: [HOST_IS_SLAVE].
> I do not want to get just one host metrics, instead I want to get all
> 3 hosts metrics in the same pool and to show them in one page at the same
> time.
>
>
> Thanks and Regards
>
> Will
>
> 2014-11-24 19:40 GMT+08:00 Jon Ludlam <jonathan.ludlam@citrix.com>:
>
>> Hi Will,
>>
>> To get performance metrics, the preferred mechanism is to use the RRD
>> interface - it's much more lightweight than using the API
>> 'query_data_source'. Have a look here for some docs and sample code:
>>
>>
>> http://xenserver.org/partners/developing-products-for-xenserver/18-sdk-development/96-xs-dev-rrds.html
>>
>> Jon
>>
>>
>> On 24/11/14 02:46, Will Sun wrote:
>>
>> Hi all,
>> I build a pool includes 3 hosts : vGate7, vGate8 and vGate9. vGate9 is
>> the master, others are slaves.
>> I build a page to show the host and vm performing
>> metrics(e.g.cpu_utilization) on it. It works fine for the mater
>> (vGate9).But it cannot get the slave performing metrics.
>>
>> As follows in picture 1 :
>>
>>
>>
>> In python, I use the following codes to get the CPU Usage:
>>
>> import XenAPI
>> url = "https://host_ip"
>> username = "hostname"
>> password = "self_password"
>>
>> session = XenAPI.session(url)
>> session.xenapi.login_with_password(username,password)
>>
>>
>> cpu_usage =
>> session.xenapi.host.query_data_source("OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448"
>> , 'cpu_avg')
>> # OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448 is
>> vGate7 (slave),
>> # and it will show XenAPI.Failure:*['HOST_OFFLINE']*
>>
>>
>> I attempt to make an API call to a slave (even someting trivial like
>> pool.get_all()),I get the *['HOST_IS_SLAVE'] *exception,along with the
>> master's IP address.
>>
>>
>> The main problem is to get 3 hosts real-time performing metrics and to
>> show them on the same page.
>> Is there any workaround to solve this problem?
>> The attachment is picture1, incase you cannot see it in the message.
>> Thank you in advance!
>>
>>
>> Thanks and Regards,
>> Will
>>
>>
>> _______________________________________________
>> Xen-api mailing listXen-api@lists.xen.orghttp://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
>>
>>
>>
>> _______________________________________________
>> Xen-api mailing list
>> Xen-api@lists.xen.org
>> http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
>>
>>
>
>
Re: get 3 hosts real-time performing metrics and show them on the same page. [ In reply to ]
Here's a sample:

[vagrant@localhost ~]$ python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmlrpclib
>>> import urllib2


>>>
s=xmlrpclib.Server("http://169.254.0.20/")

>>>
sess=s.session.login_with_password("root","xenroot")['Value']

>>> resp =
urllib2.urlopen("http://169.254.0.23/rrd_updates?session_id=%s&start=1417006800"
% sess)
>>> resp.read()
'<?xml version="1.0"
encoding="UTF-8"?>\n<xport><meta><start>1417006860</start><step>60</step><end>1417008180</end><rows>24</rows><columns>2</columns><legend><entry>AVERAGE:vm:7d3f9b63-82b1-4328-b475-f85417c6fe82:cpu0</entry><entry>AVERAGE:vm:7d3f9b63-82b1-4328-b475-f85417c6fe82:memory</entry></legend></meta><data><row><t>1417008180</t><v>0.0307</v><v>788529152.0000</v></row><row><t>1417008120</t><v>0.0348</v><v>788529152.0000</v></row><row><t>1417008060</t><v>0.0301</v><v>788529152.0000</v></row><row><t>1417008000</t><v>0.2650</v><v>788529152.0000</v></row><row><t>1417007940</t><v>0.0647</v><v>788529152.0000</v></row><row><t>1417007880</t><v>0.0452</v><v>788529152.0000</v></row><row><t>1417007820</t><v>0.1465</v><v>525686112.0000</v></row><row><t>1417007760</t><v>NaN</v><v>NaN</v></row><row><t>1417007700</t><v>NaN</v><v>NaN</v></row><row><t>1417007640</t><v>NaN</v><v>NaN</v></row><row><t>1417007580</t><v>NaN</v><v>NaN</v></row><row><t>1417007520</t><v>NaN</v><v>NaN</v></row><row><t>1417007460</t><v>NaN</v><v>NaN</v></row><row><t>1417007400</t><v>NaN</v><v>NaN</v></row><row><t>1417007340</t><v>NaN</v><v>NaN</v></row><row><t>1417007280</t><v>NaN</v><v>NaN</v></row><row><t>1417007220</t><v>NaN</v><v>NaN</v></row><row><t>1417007160</t><v>NaN</v><v>NaN</v></row><row><t>1417007100</t><v>NaN</v><v>NaN</v></row><row><t>1417007040</t><v>NaN</v><v>NaN</v></row><row><t>1417006980</t><v>NaN</v><v>NaN</v></row><row><t>1417006920</t><v>NaN</v><v>NaN</v></row><row><t>1417006860</t><v>NaN</v><v>NaN</v></row><row><t>1417006800</t><v>NaN</v><v>NaN</v></row></data></xport>'
>>>

Jon


On 25/11/14 13:19, Will Sun wrote:
> Hi Jon,
> Thanks very much. As you said, I create one session on the master,(the
> code I give in last email is also firstly creates one session on the
> master ), then I use that session for querying the RRD data on one
> slave.But it shows failure*['HOST_OFFLINE'], *that means I attempted
> an operation which involves a host which cannot be contacted.
> *
> *
> I want to confirm one thing:**where is the RRD of slave stored? master
> host or slave host itself? I think it's slave.
> How do I use the session on the master to query the RRD data on each
> slave? Can you give me a sample?
>
>
> Thanks and Regards,
>
> Will
>
> 2014-11-24 23:17 GMT+08:00 Jon Ludlam <jonathan.ludlam@citrix.com
> <mailto:jonathan.ludlam@citrix.com>>:
>
> Hi Will,
>
> It looks like what the code is doing is trying to create the
> session on the slave before doing the RRD GET call. Sessions are
> handled by the pool master, so that's why you get the
> HOST_IS_SLAVE error.
>
> What you should do is create one session on the master, then use
> that one session for querying the RRD data on each slave.
>
> HTH,
>
> Jon
>
>
>
>
> On 24/11/14 13:05, Will Sun wrote:
>> Hi Jon,
>> Thanks very much. In fact ,I have used the RRD interface to
>> get the master's metrics,and it worked fine. The codes as follows:
>>
>> https://github.com/hswayne77/CitrixXenserver-monitoring
>>
>> But I cannot get the slave's metrics , unless I use the
>> commands "pool.designate_new_master" to make slave become master.
>> If I do so, I still cannot get the other two slaves metrics.
>> In the /Citrix XenServer Management API ,/ I can only manage
>> the slave host by the master . In the session, the arguments
>> "url" cannot be the slave's ip, or it will show the failure:
>> [HOST_IS_SLAVE].
>> I do not want to get just one host metrics, instead I want to
>> get all 3 hosts metrics in the same pool and to show them in one
>> page at the same time.
>>
>>
>> Thanks and Regards
>>
>> Will
>>
>> 2014-11-24 19:40 GMT+08:00 Jon Ludlam <jonathan.ludlam@citrix.com
>> <mailto:jonathan.ludlam@citrix.com>>:
>>
>> Hi Will,
>>
>> To get performance metrics, the preferred mechanism is to use
>> the RRD interface - it's much more lightweight than using the
>> API 'query_data_source'. Have a look here for some docs and
>> sample code:
>>
>> http://xenserver.org/partners/developing-products-for-xenserver/18-sdk-development/96-xs-dev-rrds.html
>>
>> Jon
>>
>>
>> On 24/11/14 02:46, Will Sun wrote:
>>> Hi all,
>>> I build a pool includes 3 hosts : vGate7, vGate8 and vGate9.
>>> vGate9 is the master, others are slaves.
>>> I build a page to show the host and vm performing
>>> metrics(e.g.cpu_utilization) on it. It works fine for the
>>> mater (vGate9).But it cannot get the slave performing metrics.
>>>
>>> As follows in picture 1 :
>>>
>>>
>>>
>>> In python, I use the following codes to get the CPU Usage:
>>>
>>> import XenAPI
>>> url = "https://host_ip"
>>> username = "hostname"
>>> password = "self_password"
>>>
>>> session = XenAPI.session(url)
>>>
>>> session.xenapi.login_with_password(username,password)
>>>
>>>
>>> cpu_usage =
>>> session.xenapi.host.query_data_source("OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448"
>>> , 'cpu_avg')
>>> #
>>> OpaqueRef:35ad218e-09e2-4117-e93d-0de371265448 is vGate7
>>> (slave),
>>> # and it will show
>>> XenAPI.Failure:*['HOST_OFFLINE']** *
>>>
>>>
>>> I attempt to make an API call to a slave (even someting
>>> trivial like pool.get_all()),I get the *['HOST_IS_SLAVE']
>>> *exception,along with the master's IP address.
>>>
>>>
>>> The main problem is to get 3 hosts real-time performing
>>> metrics and to show them on the same page.
>>> Is there any workaround to solve this problem?
>>> The attachment is picture1, incase you cannot see it in the
>>> message.
>>> Thank you in advance!
>>>
>>>
>>> Thanks and Regards,
>>> Will
>>>
>>>
>>> _______________________________________________
>>> Xen-api mailing list
>>> Xen-api@lists.xen.org <mailto:Xen-api@lists.xen.org>
>>> http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
>>
>>
>> _______________________________________________
>> Xen-api mailing list
>> Xen-api@lists.xen.org <mailto:Xen-api@lists.xen.org>
>> http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api
>>
>>
>
>
>
>
> _______________________________________________
> Xen-api mailing list
> Xen-api@lists.xen.org
> http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api