commit 92b07c910356a859d812ee808e7d99b475b1ebb2 Author: W. David Ashley w.david.ashley@gmail.com Date: Fri Jul 10 09:46:39 2015 -0500
Domain chapter - nodified example 35 to better explain the returned value from memoryStats method - modified the text to also explain the results returned from memoryStats method
en-US/Guest_Domains.xml | 5 ++--- en-US/extras/Domains-Example-35.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) --- diff --git a/en-US/Guest_Domains.xml b/en-US/Guest_Domains.xml index 14f2e3f..c420958 100644 --- a/en-US/Guest_Domains.xml +++ b/en-US/Guest_Domains.xml @@ -942,10 +942,9 @@ <programlisting language="Python"><xi:include href="extras/Domains-Example-35.py" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> </example> <para> - To find the percentage of memory used by the domain invoke the <literal>maxMemory</literal> - method an then perform the following calculation. + Note that the <literal>memoryStats</literal> returns a dictionary object. This object will + contain a variable number of entries depending on the hypervisor and guest domain capabilities. </para> - <programlisting language="Python">percentage = dom.memoryStats().value() / dom.maxMemory()</programlisting>
</section>
diff --git a/en-US/extras/Domains-Example-35.py b/en-US/extras/Domains-Example-35.py index f5d3252..123f33b 100644 --- a/en-US/extras/Domains-Example-35.py +++ b/en-US/extras/Domains-Example-35.py @@ -16,9 +16,9 @@ if dom == None: exit(1)
stats = dom.memoryStats() -print('memory used: '+str(stats['actual'])+' (actual)') -print(' '+str(stats['swap_in'])+' (swap_in)') -print(' '+str(stats['rss'])+' (rss)') +print('memory used:') +for name in stats: + print(' '+str(stats[name])+' ('+name+')')
conn.close() exit(0)