[GH-ISSUE #245] There is any way i can add memory monitor of guest vm #165

Open
opened 2026-02-27 15:57:35 +03:00 by kerem · 1 comment
Owner

Originally created by @alshba7 on GitHub (Jun 22, 2019).
Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/245

There is any way i can add memory monitor of guest vm

my code for example

#!/usr/bin/env python

import libvirt
from libvirt import libvirtError
import time

def request_cred(credentials, user_data):
for credential in credentials:
if credential[0] == libvirt.VIR_CRED_AUTHNAME:
credential[4] = 'test'
elif credential[0] == libvirt.VIR_CRED_PASSPHRASE:
credential[4] = 'dddddddd'
return 0

auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], request_cred, None]
conn = libvirt.openAuth('qemu+{0}://{1}/system'.format('tcp','127.0.0.1'), auth, 0)
#conn = libvirt.open(optional_params['conn'])
guest = 'guest'
vm = conn.lookupByName(guest)
""" test with running vm """
memstats = vm.memoryStats()
percent = memstats['rss'] / memstats['actual'] * 100
pcentCurrMem = max(100.0,min(percent, 0.0))
print(percent)
print(int( float(int(memstats['rss'])) / float(int(memstats['actual'])) * 100 ))
time.sleep(1)
vm.setMemoryStatsPeriod(5, libvirt.VIR_DOMAIN_AFFECT_LIVE)
memstats = vm.memoryStats()
print(int( float(int(memstats['rss'])) / float(int(memstats['actual'])) * 100 ))

But the usage of memory the same 99% or 101%
how can i solve this problem

Originally created by @alshba7 on GitHub (Jun 22, 2019). Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/245 There is any way i can add memory monitor of guest vm my code for example #!/usr/bin/env python import libvirt from libvirt import libvirtError import time def request_cred(credentials, user_data): for credential in credentials: if credential[0] == libvirt.VIR_CRED_AUTHNAME: credential[4] = 'test' elif credential[0] == libvirt.VIR_CRED_PASSPHRASE: credential[4] = 'dddddddd' return 0 auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], request_cred, None] conn = libvirt.openAuth('qemu+{0}://{1}/system'.format('tcp','127.0.0.1'), auth, 0) #conn = libvirt.open(optional_params['conn']) guest = 'guest' vm = conn.lookupByName(guest) """ test with running vm """ memstats = vm.memoryStats() percent = memstats['rss'] / memstats['actual'] * 100 pcentCurrMem = max(100.0,min(percent, 0.0)) print(percent) print(int( float(int(memstats['rss'])) / float(int(memstats['actual'])) * 100 )) time.sleep(1) vm.setMemoryStatsPeriod(5, libvirt.VIR_DOMAIN_AFFECT_LIVE) memstats = vm.memoryStats() print(int( float(int(memstats['rss'])) / float(int(memstats['actual'])) * 100 )) But the usage of memory the same 99% or 101% how can i solve this problem
Author
Owner

@catborise commented on GitHub (Jun 22, 2019):

I have add that information to stats as graph for vm. Have you see that? You can search rss in instance/view.py and vrtmanager/instance.py

<!-- gh-comment-id:504695401 --> @catborise commented on GitHub (Jun 22, 2019): I have add that information to stats as graph for vm. Have you see that? You can search rss in instance/view.py and vrtmanager/instance.py
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtcloud#165
No description provided.